Jump to content
  • 0
MukkiesftKies

save setarray after end;

Question

setarray [email protected][0],501,502;

switch(select("Adjust Effect:Close")) {

case 1:
    for( set [email protected],0; [email protected] < getarraysize([email protected][[email protected]]); set [email protected],[email protected] + 1 )
        set [email protected]$,[email protected]$+getitemname([email protected][[email protected]])+":";
        [email protected] = select( [email protected]$ ) - 1;
    end;
}

L_Check:
if( countitem ([email protected][[email protected]]) ) goto L_NotEnough;
        delitem [email protected][[email protected]],1;
mes" Ok, Your effect";

Countitem can not find item, what problem with my script ?

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

since you are using a scope variable([email protected]) for the array, it will end when the script ends. You can try to use a temporary character variable (@) instead to pass the array. Just make sure that the variable name is a unique one.

Quote

"[email protected]"     - A scope variable.
           They are unique to the instance and scope. Each instance has its
           own scope that ends when the script ends. Calling a function with
           callsub/callfunc starts a new scope, returning from the function
           ends it. When a scope ends, its variables are converted to values
           ('return [email protected];' returns a value, not a reference).

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

Double check this:

if( countitem ([email protected][[email protected]]) ) goto L_NotEnough;

If I have this item then I go to L_NotEnough?

Probably should be:

if( !countitem ([email protected][[email protected]]) ) goto L_NotEnough;

 

Link to comment
Share on other sites

  • 0
12 hours ago, Jarek said:

Double check this:

if( countitem ([email protected][[email protected]]) ) goto L_NotEnough;

If I have this item then I go to L_NotEnough?

Probably should be:

if( !countitem ([email protected][[email protected]]) ) goto L_NotEnough;

 

yaa i already try. can count.
but when i choose Yellow Potion. my map show this

[Error]: buildin_delitem: failed to delete 1 items (AID=2000000 item_id=501).

Link to comment
Share on other sites

  • 0

setarray [email protected][0],501,502;

switch(select("Use Super Power:Set Super Power:Close")) {
case 1:
if (isequipped( )) goto L_Check;

case 2:
for( set [email protected],0; [email protected] < getarraysize([email protected][[email protected]]); set [email protected],[email protected] + 1 )        
set [email protected]$,[email protected]$+getitemname([email protected][[email protected]])+":";       
[email protected] = select( [email protected]$ ) - 1;
end;  << if i remove this countitem can detect what item i choose but straight to L_Check, without select USE SUPER POWER.
}

L_Check:
if( !countitem ([email protected][[email protected]]) ) goto L_NotEnough;
delitem [email protected][[email protected]],1;
mes "You got Meteor Storm Skill";

Link to comment
Share on other sites

  • 0

setarray [email protected][0],501,502;

switch(select("Use Super Power:Set Super Power:Close")) {
case 1:
if (isequipped( )) goto L_Check;

case 2:
for( set [email protected],0; [email protected] < getarraysize([email protected][[email protected]]); set [email protected],[email protected] + 1 )        
set [email protected]$,[email protected]$+getitemname([email protected][[email protected]])+":";       
[email protected] = select( [email protected]$ ) - 1;
end;  << if i remove this countitem can detect what item i choose but straight to L_Check, without select USE SUPER POWER.
}

L_Check:
if( !countitem ([email protected][[email protected]]) ) goto L_NotEnough;
delitem [email protected][[email protected]],1;
mes "You got Meteor Storm Skill";

Link to comment
Share on other sites

  • 0

To help you first, I need to understand. I can not understand your logic (since you're not passing the whole script). Does the player choose to use an item and then take the meteor stomer? choose "set super power", will do what?

Link to comment
Share on other sites

  • 0
19 hours ago, Zell said:

To help you first, I need to understand. I can not understand your logic (since you're not passing the whole script). Does the player choose to use an item and then take the meteor stomer? choose "set super power", will do what?

i just want to make array pass from end; when the script ends.

for example :-
 

setarray [email protected]$[0], "Warp","Fly","Shit";
 
set @menu$,"";
for (set @i,0; @i < getarraysize([email protected]$); set @i,@i+1) {
    if (@i) set @menu$,@menu$+":";
    set @menu$,@[email protected]$[@i];
}
set @selection,select(@menu$)-1;

i take this from https://rathena.org/board/topic/87190-how-to-use-array-as-a-menu/. 
but when i try to put end; to the end script. array can not be read.  because i change menu to id number. like my first post.


@Technoken

Quote

since you are using a scope variable([email protected]) for the array, it will end when the script ends. You can try to use a temporary character variable (@) instead to pass the array. Just make sure that the variable name is a unique one.

can you show me some example ? hehe

Edited by MukkiesftKies
Link to comment
Share on other sites

  • 0
2 hours ago, MukkiesftKies said:

i just want to make array pass from end; when the script ends.

for example :-
 

setarray [email protected]$[0], "Warp","Fly","Shit";
 
set @menu$,"";
for (set @i,0; @i < getarraysize([email protected]$); set @i,@i+1) {
    if (@i) set @menu$,@menu$+":";
    set @menu$,@[email protected]$[@i];
}
set @selection,select(@menu$)-1;

i take this from https://rathena.org/board/topic/87190-how-to-use-array-as-a-menu/. 
but when i try to put end; to the end script. array can not be read.  because i change menu to id number. like my first post.


@Technoken

can you show me some example ? hehe

Ok, got it.

Like Technoken sayed, just change [email protected] to @items.
 

This will work, but still is a ugly approach. If you need a player to handle a setarray with a @ ou permanent variable you are making something wrong in your logic. If exists some situation which you need to make something like this, to create a new table is the go.

  • Love 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.