Lil Troll Posted August 28, 2013 Group: Members Topic Count: 38 Topics Per Day: 0.01 Content Count: 276 Reputation: 24 Joined: 07/06/13 Last Seen: April 19, 2014 Share Posted August 28, 2013 Hi guys, i just need to clarify something, is OnInit: works like this case below even no global vars used? - script blahblah -1,{ OnInit: setarray .blahblah,501,502,503,504,505; setarray .blah,1,2,3,4,5; end; } function script blah1 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah2 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah3 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah4 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah5 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah6 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah7 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah8 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } function script blah9 { for(.@i=0; .@i < getarraysize(.blahblah) .@i++){ if(isequipped(.blahblah[.@i]) mes .@i+". "+getitemname(.blahblah[.@i)+" "+blah[.@i]+" "; } return; } Quote Link to comment Share on other sites More sharing options...
Patskie Posted August 28, 2013 Group: Members Topic Count: 50 Topics Per Day: 0.01 Content Count: 1702 Reputation: 241 Joined: 09/05/12 Last Seen: 10 hours ago Share Posted August 28, 2013 · Hidden by Euphy, August 28, 2013 - This is not correct. Hidden by Euphy, August 28, 2013 - This is not correct. That wouldn't work since OnInit will only trigger on the current script where they are. Link to comment
Euphy Posted August 28, 2013 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Share Posted August 28, 2013 OnInit will always run in an enabled script. The issue is that you're setting NPC variables, which can only be directly referenced in that one NPC. Since your functions are external, you have to use the Getvariableofnpc command to access them. Quote Link to comment Share on other sites More sharing options...
Lil Troll Posted August 28, 2013 Group: Members Topic Count: 38 Topics Per Day: 0.01 Content Count: 276 Reputation: 24 Joined: 07/06/13 Last Seen: April 19, 2014 Author Share Posted August 28, 2013 Thanks sir Euphy, am more enlightened. Quote Link to comment Share on other sites More sharing options...
Skorm Posted August 29, 2013 Group: Forum Moderator Topic Count: 33 Topics Per Day: 0.01 Content Count: 1282 Reputation: 393 Joined: 02/03/12 Last Seen: April 11 Share Posted August 29, 2013 Thanks sir Euphy, am more enlightened. Alternatively including the function inside the npc will allow it to access npc variables... but you have to remember each function takes it's own scope... Also returning from a function inside an npc will reinstate your old scope variables, but the function will only be available to that npc. prontera,152,152,5 script Test 100,{ function f_func; set .@Scope_Variable, 2; set .NPC_Variable, 1; f_func(); dispbottom ""+.@Scope_Variable; //Will display 2. end; function f_func { dispbottom ""+.NPC_Variable; //Will display 1. dispbottom ""+.@Scope_Variable; //Will display 0. return; } } Quote Link to comment Share on other sites More sharing options...
Question
Lil Troll
Hi guys, i just need to clarify something, is OnInit: works like this case below even no global vars used?
Link to comment
Share on other sites
4 answers 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.