Sephus 203 Posted August 23, 2015 (edited) Is this possible on hercules? I only ask because the wiki states it isn't. - Edit - nvm, tested this, doesn't work. - Edit 2 - Also, is there a way to check if an getarg(n) exists, if say the variable .@abc is 0 in callfunc "abc",.@abc; ? Edited August 23, 2015 by Smokexyz Quote Share this post Link to post Share on other sites
0 Emistry 145 Posted August 23, 2015 yes, possible. Example: http://pastebin.com/raw.php?i=sgTq0gQR Quote Share this post Link to post Share on other sites
0 Sephus 203 Posted August 23, 2015 (edited) Sorry I didn't explain precisely, I'm talking about something along the lines of this for example - - script test 123,{ OnWhisperGlobal: setarray .@test[0],1,12,123; callfunc "abc",.@test; end;}function script abc { copyarray .@test,getarg(0); dispbottom ""+.@test[1]; return;} This works, just not for npc variables, like .test Edited August 23, 2015 by Smokexyz Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted August 23, 2015 (edited) Sorry I didn't explain precisely, I'm talking about something along the lines of this for example - - script test 123,{ OnWhisperGlobal: setarray .@test[0],1,12,123; callfunc "abc",.@test; end;}function script abc { copyarray .@test,getarg(0); dispbottom ""+.@test[1]; return;} This works, just not for npc variables, like .test example: - script testnpc 123,{ OnWhisperGlobal: setarray .test[0],1,12,123; callfunc "abc"; end;}function script abc { dispbottom ""+getelementofarray(getvariableofnpc(.test,"testnpc"),1); return;} Edited August 23, 2015 by Angelmelody Quote Share this post Link to post Share on other sites
0 Sephus 203 Posted August 23, 2015 (edited) yeah but then you'd have to use a loop to re-create that array by adding each element, instead of copying from reference. Also what is getarg(0) in that? Edited August 23, 2015 by Smokexyz Quote Share this post Link to post Share on other sites
0 GmOcean 92 Posted August 23, 2015 She meant to place .test as arg(0), which would make it pass the info from .test. But if I'm not mistaken, only .test[0]. If you REALLY need to copy an array over to a function for w/e reason, turn it into a temp global array $@test. You can also use setd/getd to dynamically create these names so they are unique each time you make them, so they don't overlap with one another and cause errors. 1 Sephus reacted to this Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted August 23, 2015 (edited) yeah but then you'd have to use a loop to re-create that array by adding each element, instead of copying from reference. Also what is getarg(0) in that? you don't need a loop to copy array you can directly access the .test array get value from array: getelementofarray(getvariableofnpc(.test,"testnpc"), index); set value to array: set( getelementofarray(getvariableofnpc(.test,"testnpc"),index), value); Edited August 23, 2015 by Angelmelody Quote Share this post Link to post Share on other sites
0 Sephus 203 Posted August 23, 2015 Well for the time being i'm using a temporary npc variable .@ , but if I wanted to set it as an NPC variable it's quite inconvenient. yeah but then you'd have to use a loop to re-create that array by adding each element, instead of copying from reference. Also what is getarg(0) in that? you don't need a loop to copy array you can directly access the .test arrayget value from array: getelementofarray(getvariableofnpc(.test,"testnpc"), index); set value to array: set( getelementofarray(getvariableofnpc(.test,"testnpc"),index), value); I know what you're saying, but if I needed to use the entire array conveniently in the function i'd have to recreate it using a loop within the function and assign the elements to a new array. Using that new array would also avoid calling many functions (getelement/variable) repeatedly. It would be nice to be able to pass a direct npc variable reference, I'm not sure what the source on this is yet, I will check it out. Quote Share this post Link to post Share on other sites
0 Winterfox 83 Posted August 24, 2015 - script testnpc 123,{ OnWhisperGlobal: setarray .test[0],1,12,123; callfunc "abc"; end;}function script abc { copyarray .@test, getvariableofnpc(.test,"testnpc"), getarraysize( getvariableofnpc(.test,"testnpc") ); return;} 1 Sephus reacted to this Quote Share this post Link to post Share on other sites
0 Sephus 203 Posted August 24, 2015 Thank you, that works. Quote Share this post Link to post Share on other sites
0 Dastgir 1246 Posted August 24, 2015 Thank you, that works. You could just pass npc and use copyarray - script testnpc 123,{ OnWhisperGlobal: setarray .test[0],1,12,123; callfunc("abc",.test); end;}function script abc { copyarray .@var[0],getarg(0),getarraysize(getarg(0)); // Use .@var as Array now... return;} Quote Share this post Link to post Share on other sites
Is this possible on hercules? I only ask because the wiki states it isn't.
- Edit -
nvm, tested this, doesn't work.
- Edit 2 -
Also, is there a way to check if an getarg(n) exists, if say the variable .@abc is 0 in callfunc "abc",.@abc; ?
Edited by SmokexyzShare this post
Link to post
Share on other sites