Game Development Community

Type Casting maybe?

by Michael Cozzolino · in Torque Game Engine · 12/03/2004 (8:04 am) · 4 replies

Ok bear with me. I think I have done what i'm asking in other languages. It's been a while. Looked though my books and nothing is popping out at me.

Here is what i'm trying to do.

I have pickups that have a value in there datablock. ie.

value = 5;

value = "*";


I'm trying to get the value of a pickup and then take the value of another pickup that is either a (*, /, +, or -) and apply that operand to a third pickup or other value.

Any examples or anything would be greatly appreciated.

Thanks,
Coz

About the author

Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489


#1
12/03/2004 (8:07 am)
This in script right? If you feel like creating a massive security hole, try this:

eval("%finalValue =" SPC value1 SPC valueModifier SPC value2 SPC ";");
#2
12/03/2004 (8:27 am)
Well the second value is treated as a string. Also since your are trying to do math you need to set that second value differently..


value = 5;

value = "++" // Add 1
value = "--"; // Subtract 1
value = "\ 2"; // Divide by 2
value = "* 2; // Multiply by 2

%endValue = db1.value @ db2.value;

This should work. You can also probably get away with..

value = 5;

value = "+=" 
value = "-=";
value = "\";
value = "*;

%endValue = db1.value @ db2.value @ db1.value;

I am not 100% sure this will work but try it before resorting to eval()
#3
12/03/2004 (8:39 am)
Thanks Zod. I will try. How is the eval() a security hole?
#4
12/03/2004 (9:10 am)
Because someone could maliciously change one of the values to execute any code on the server. Tribes 2 had a vote-eval hole. For instance, if one of the object's values was changed to:

"; runMyMaliciousFunction();"

Then the eval would run that code. Tribes 2 had an eval hole in it's voteing method.

Ian

PS: Is this the Zod of Tribes 2 mod/mapping fame? If so I'm honoured to be in the same thread as you :)