How do I add a new input function?
by MaxAntinone · in Torque Game Engine · 03/31/2008 (12:54 am) · 7 replies
Hello again,
I want to add a function that returns the player to the starting point whenever they hit a certain button, and I don't really know where to start. I've searched around on the TDN, but couldn't find instructions in the basic TGE scripters area, and I'm not even sure how to phrase the question for a search. Do I need to change things in my game folder, or do I have to go up to the engine code to add in something new?
I'm working independently on a school project and there's no one around who knows Torque. I am about a week from my final deadline. I have some programming experience with java; I can program alright in c++, but I've never really had to deal with file structures like this and it's really confusing me. The only programming I've done so far has been adding some stuff in the basic triggers code and changing the keys for the movement functions already present.
Could someone please walk me through how to program this function and what .cs files I need to change?
I want to add a function that returns the player to the starting point whenever they hit a certain button, and I don't really know where to start. I've searched around on the TDN, but couldn't find instructions in the basic TGE scripters area, and I'm not even sure how to phrase the question for a search. Do I need to change things in my game folder, or do I have to go up to the engine code to add in something new?
I'm working independently on a school project and there's no one around who knows Torque. I am about a week from my final deadline. I have some programming experience with java; I can program alright in c++, but I've never really had to deal with file structures like this and it's really confusing me. The only programming I've done so far has been adding some stuff in the basic triggers code and changing the keys for the movement functions already present.
Could someone please walk me through how to program this function and what .cs files I need to change?
#2
I know just putting it in the default.bind.cs file doesn't work.
03/31/2008 (9:26 am)
Where do I put the takeMeHome code? That's the part that really has me confused.I know just putting it in the default.bind.cs file doesn't work.
#3
I tried putting it in default.bind.cs with the keybinding and nothing happened. I've been searching around for where the code for the other basic movements are and, besides what's in default.bind.cs I can't find anything.
HELP!
04/02/2008 (9:23 am)
Will someone please respond here? I need to know this today. I just can't figure out WHERE to put this code!I tried putting it in default.bind.cs with the keybinding and nothing happened. I've been searching around for where the code for the other basic movements are and, besides what's in default.bind.cs I can't find anything.
HELP!
#4
1. The first function would be right under your moveMap.bind in client/scripts/default.bind.cs.
2. The server function would be in server/scripts/commands.cs.
From the server function you could just respawn the player.
Example script I made that use's a button to do something: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13640.
04/02/2008 (9:55 am)
I'd make a function that calls the server and then have the server do whatever. 1. The first function would be right under your moveMap.bind in client/scripts/default.bind.cs.
2. The server function would be in server/scripts/commands.cs.
From the server function you could just respawn the player.
Example script I made that use's a button to do something: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13640.
#5
I've looked through some finished games, and I know they all have those files. In fact, their server folders all look completely different than what I have here. Do I just add those files in? What step am I missing here?
04/02/2008 (12:50 pm)
My server folder doesn't have a scripts folder or a commands.cs file. There also isn't any player.cs file.I've looked through some finished games, and I know they all have those files. In fact, their server folders all look completely different than what I have here. Do I just add those files in? What step am I missing here?
#6
04/02/2008 (1:13 pm)
I based that off the starter.fps directory.
#7
Also, after all of that, I found a workaround. Just calling "dropPlayerAtCamera" essentially does exactly what I need.
04/02/2008 (1:22 pm)
Will this program still run normally outside the SDK with just the scripts in the tutorial.base folder (with my meager additions)?Also, after all of that, I found a workaround. Just calling "dropPlayerAtCamera" essentially does exactly what I need.
Torque Owner Mike Rowley
Mike Rowley
Parent::onEnterTrigger(%this,%trigger,%obj); %obj.setTransform("-402.573 -349.095 211.693");If you want to use a buttton, you could write a function, and add a keybinding for it.
could be something like:
function takeMeHome() { %player.setTransform(" x y z:); // change x y z to your start position. I use the player drop points coords }Then for your keybinding, just do something like: (you can put the keybinding at the bottom of your movement script)
This should work, altho I haven't tried it with a button press.
Hopefully, I've at least given you a direction to look.