*SOLVED* correct syntax for custom key/value

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

*SOLVED* correct syntax for custom key/value

Post 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!?
Last edited by wacko on Mon Mar 21, 2005 4:14 pm, edited 1 time in total.
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post 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:
Last edited by wacko on Mon Mar 21, 2005 12:15 am, edited 1 time in total.
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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 "
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post 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:
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post 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
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

ooo :oops: I knew it was so simple. Thanks, m8!
Post Reply