Author Topic: Why is it not echoing %pl.rads  (Read 1510 times)

if(%object.getDatablock() == ScrapElectronicsBrickData)
That's like comparing %obj.getDatablock() == 0. The compiler will optimize the operands and think it's an integer (and non-numeric strings default to 0)

if(%object.getDatablock() == nameToID("ScrapElectronicsBrickData"))

(or .getID(), up to you, but nameToID is a smidgen faster)
« Last Edit: July 09, 2015, 10:00:56 PM by Val »

That's like comparing %obj.getDatablock() == 0. The compiler will optimize the operands and think it's an integer (and non-numeric strings default to 0)

if(%object.getDatablock() == nameToID("ScrapElectronicsBrickData"))

(or .getID(), up to you)

Whoops. You're right. I forgot that Torque doesn't tokenize identifiers because it was made by monkeys. Edited the original code.

Im going to memorize this stuff lol

You should learn to check your own code, a lot of these errors were very simple and easily fixed. Learning how to debug it fully might help. Learn how to use trace to see if functions are being called correctly, and echo at the right places to see what section of the code is messing up.

echo at the right places to see what section of the code is messing up.
that's probably the most useful one
knowing how to debug with a printout of what your code is doing

The thing about torquescript that sucks is that there's no debugger.

I mean, there was one made, but it costs money, and you need TGE to use it. It's not exactly convenient

I find the debugger is the coder, and that works pretty well for me