Fun with eval
by Dumbledore · in Torque Game Engine · 08/14/2008 (2:40 pm) · 3 replies
Does this have any merit at all?
I get a parse error, but I thought you could do something like this.
// global
$VehicleType::MotorCycle::Cost = 50;
function getCost(%vehicleType)
{
eval("%cost = $VehicleType:: @ %vehicleType @ ::Cost");
return %cost;
}
function main()
{
echo( getCost("MotorCycle");
}I get a parse error, but I thought you could do something like this.
Torque Owner Nathan Kent
eval("%cost = " @ $VehicleType @ "::" @ %vehicleType @ "::Cost");