Changing Player Attributes
by Wendell Smith · in Torque Game Engine · 08/24/2002 (4:40 pm) · 9 replies
I am trying to create an item that when picked up will double the players jumpForce variable for X amount of seconds.
How do I access and manipulate such variables(ones found in player.cs) using the TGE Scripting language?
thx in advance...
How do I access and manipulate such variables(ones found in player.cs) using the TGE Scripting language?
thx in advance...
About the author
#2
08/25/2002 (12:09 pm)
I'm not exactly positive, but I don't think you can change datablock values like that on the fly. Not sure though.
#3
You'll have to change the engine code to search for the person's assigned variable instead of his datablock value for the jump ... so you gotta define a variable on the person (for the default datablock value), then add whatever changes you want.
Haha, I probably just wrote all this for no reason :/.
08/25/2002 (12:39 pm)
sure you can - absolutelly. However BIG problem .. it changes it and it will change it for all the people that respawn AFTER the change has been made :/. Theres a submition in the code snipits section about this really far back somewhere. However it's old and directions arent very clear either. (I got it to work), and do it quite a lot now, but a lot of it was on my own account.You'll have to change the engine code to search for the person's assigned variable instead of his datablock value for the jump ... so you gotta define a variable on the person (for the default datablock value), then add whatever changes you want.
Haha, I probably just wrote all this for no reason :/.
#4
any code you could hook me up with would rock!
edit: I found this
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2698
08/25/2002 (12:42 pm)
yes.... i see...any code you could hook me up with would rock!
edit: I found this
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2698
#5
08/25/2002 (1:33 pm)
yes .. and that tutorial DOES work, you just gotta figure out where to put things lol. just kinda play around with it, you'll understand it after a while.
#6
So you have 2 problems there, the only way is to edit the values in the player class.
Regards,
Xavier
08/25/2002 (3:21 pm)
Trevor, you are absolutely wrong, you can't change values in the datablocks, well you CAN, but it wont work, datablocks are sent when the client connects and stored in the client... so changing the values in the server will only affect the datablock in the server, but the client will still have an old version of the datablock, so you will have sync problems, and also, that yes, datablocks are used as a 'template' to create instances of that object.So you have 2 problems there, the only way is to edit the values in the player class.
Regards,
Xavier
#7
08/25/2002 (4:13 pm)
oh yeah ... i'm used to t2 and having a datablock distribution update dealie ... but in all in all, changing the datablock wont work.
#8
try creating a new datablock.one that defines your jump.
and switch between them.
08/25/2002 (6:09 pm)
easy pie ..try creating a new datablock.one that defines your jump.
and switch between them.
#9
08/25/2002 (6:26 pm)
@BadGuy: that won't work either, because the datablock is read only when the object is created, once the object is created you can't change it's datablock unless you delete and recreate the object... only way is to make the changes inside the player class... Daniel Neilsen did a good easy tutorial about this...
Torque Owner Wendell Smith
Not everyone at once!
%datablock = %player.getDatablock();
%datablock.maxForwardSpeed = %datablock.maxForwardSpeed * %somemultipier;