Page 1 of 1

*SOLVED* correct syntax for custom key/value

Posted: Sun Mar 20, 2005 11:08 pm
by wacko
I got lots of waypoints with targetnames from twp1_1 to twp1_62, twp2_1 to twp2_62 and twp3_1 to twp3_62. All of them got a key/value of #dir/1, #dir/2, #dir/3 or #dir/4. Now, in the script, I want to read that value, as u can see in the iprintln line, but it's NULL, so obviously I do wrong.

Code: Select all

tw_run:
while (1) 
{
local.path = randomint 3 + 1  
for (local.i = 0; local.i <=62; local.i++) 
{ 
iprintln_noloc $("twp" + local.path + "_" + local.i + ".dir")
...
} 
...
}
end
How would it be working?

Code: Select all

$thing moveto $("twp" + local.path + "_" + local.i)
is working perfectly and for example

Code: Select all

iprintln_noloc $twp1_5.dir
gives me the value like I want, so it's the '+ ".dir"' that seem to cause the problem!?

Posted: Sun Mar 20, 2005 11:58 pm
by lizardkid
well, key/values are just variables added to an instantiation of a class. the generic class is given properties according to the .tik file and that's that, .dir would just be one more variable.

your problem, i think, is quotation.

iprintln_noloc $("<word>twp<end of word>"<output number> + local.path + <end of output number>"_" + local.i + "<word>.dir<word>")

so it should say .dir, but you need to specify $targetname.dir i think. not completely sure.

Posted: Mon Mar 21, 2005 12:09 am
by wacko
sorry, dont get it. :? :cry:
and did u see the 2nd and 3rd piece of code? these are working... it's just that last bit :roll:

Posted: Mon Mar 21, 2005 12:15 am
by lizardkid
it should have said the words ".dir" on the screen as well, and i think you need specify the entity's .dir that you're using, like $entity.dir

so this ought to work.

iprintlnbold_noloc "His .dir ist" $thing.dir " at check number " local.i "

Posted: Mon Mar 21, 2005 12:20 am
by wacko
lizardkid wrote:it should have said the words ".dir" on the screen as well, and i think you need specify the entity's .dir that you're using, like $entity.dir

so this ought to work.

iprintlnbold_noloc "His .dir ist" $thing.dir " at check number " local.i "
that's what I'm trying to do :wink: it's just the '$thing' isn't just $thing but a combination of '$twp' + the path number + underscore + waypoint number. And all this is working perfectly. It's just I can't add the '.dir' in a way that is accepted :cry:

Posted: Mon Mar 21, 2005 12:22 am
by wacko
i can do

Code: Select all

local.tempwp = $("twp" + local.path + "_" + local.i)
iprintln_noloc local.tempwp.dir
but there ought to be an easier way

Posted: Mon Mar 21, 2005 8:05 am
by jv_map
.dir is not part of the targetname of the object so put it outside the targetname operator ($) :wink:

$("twp" + local.path + "_" + local.i).dir

Posted: Mon Mar 21, 2005 11:17 am
by wacko
ooo :oops: I knew it was so simple. Thanks, m8!