kotsumu Posted June 19, 2012 Group: Members Topic Count: 5 Topics Per Day: 0.00 Content Count: 13 Reputation: 1 Joined: 05/31/12 Last Seen: March 11, 2024 Share Posted June 19, 2012 (edited) I have some questions about temporary NPC variables. Lets say I use .@r to store a variable in a NPC would that variable exist only within that NPC? Now lets say, I have something like... main { .@r = 0; call somefunc; } somefunc() { .@r = 2; } will .@r exist within 2 namespaces? namely main and somefunc or just the npc's namespace? Also, Is there any problems with nested switches? Anything to watch out for? switch(select("1","2","3")) { case 1: switch(select("2","3")) { case 1: .... case 2: ..... } case 2: switch(selec... .... ...... } Edited June 19, 2012 by kotsumu Quote Link to comment Share on other sites More sharing options...
KeyWorld Posted June 19, 2012 Group: Members Topic Count: 9 Topics Per Day: 0.00 Content Count: 379 Reputation: 304 Joined: 11/10/11 Last Seen: December 2, 2014 Share Posted June 19, 2012 If it can help - script var -1,{ function inside_func { // own namespace // .@b: 0 set .@c, 5; } // <- clean .@c OnInit: set .@a, 5; end; // <- clean .@a OnEvent: // Custom event // .@a: 0 set .@b, 3; inside_func(); // .@c: 0 // .@b: 3 goto OnTest; OnTest: // goto keep variables // .@b: 3 set .@c, 8; callsub OnTest2; // .@b: 3 // .@c: 8 // .@d: 0 end; // clean .@b, .@c OnTest2: // .@b: 0 // .@c: 0 set .@d, 5; return; // <- clean .@d } .@var are limited to their namespaces and not copy to their inside function/callsub. But you can modify them in a function using getarg(): - script var -1,{ function double { set getarg(0), getarg(0) * 2; } OnInit: set .@b, 10; double(.@; // .@b: 20 } No problem with switch in switch. You can even do function in function without problem Quote Link to comment Share on other sites More sharing options...
Question
kotsumu
I have some questions about temporary NPC variables.
Lets say I use .@r to store a variable in a NPC would that variable exist only within that NPC?
Now lets say, I have something like...
will .@r exist within 2 namespaces? namely main and somefunc or just the npc's namespace?
Also,
Is there any problems with nested switches? Anything to watch out for?
Edited by kotsumuLink to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.