Jump to content
Sign in to follow this  
rannade3rd

About Script Box, Variable & Separated Inventory

Recommended Posts

Hi, I'm pretty basic in scripting, so here is a problem i encounter last night,

so i decided to make two(or more) main character in my game and will tells their story respectively. and of course it need a separated inventory.

the way i am doing it is by collecting all the item that gotten so far from the inventory and save it to variables (a lot of variables) and subtract all the item in my inventory by the amount of their own value so it will erase them (giving 0 value). and whenever i need it, i will just add all the item by the amount that saved in the variables.

my problem is: the way i am doing item save is using a loop and increase in variable. err.. maybe i will show you the event script instead

 

post-70036-0-00852900-1490055726_thumb.png

 

So by the logic i use there, 

Variable 24 = 22
Variable 25 = 1
So they will add variable 24 and 25 by 1 as long as variable 24 is less than 24(value)


and the script will results in as far as i know
$game_variables[22] = $game_party.item_number($data_items[1]);
$game_variables[23] = $game_party.item_number($data_items[2]);

and so on.

*variable 22 and 23 is variables to save the amounts of certain item. on above, i uses it to save Potion and Hi-Potion.

but somehow when i play test it, it will return

 

post-70036-0-36194000-1490055724_thumb.png

 

My real question is:

1. Am i doing it wrong on implementing my logic into the above script?
2.
 Is the script box use default concatenation or it read each line as different line? since the script was like:
line n: $game_variables[$game_variables[24]] =

line n+1: $game_party.item_number($data_items
line n+2: [$game_variables[25]])
3. Is there any efficient way to implement lots of inventory save, inventory delete, or inventory add?


Any help is appreciated.

Share this post


Link to post
Share on other sites

since no one answer me until now, i learned my mistake and how to solve it from someone.

 

in case a noob like me happen to have same problem as me and wondering how to solve it, i will just share it.

 

The error happened because i allowed the linebreak at the wrong positionthe interpreter doesn't understand that it needs to continue on the next line, and the array bracket needs to begin on the line of data_items.

 

so this how i solve it,

 

since the box script somehow have limitation on how many character in each line, they break by theirself

 

this is what i input into the script

$game_variables[$game_variables[24]] = $game_party.item_number($data_items[$game_variables[25]])
 

and become this:

$game_variables[$game_variables[24]] =
$game_party.item_number($data_items
[$game_variables[25]])

 
and i fixed it by using concatenation method \ (backslash)

line 1: $game_variables[$game_variables[24]] =
line 2: $game_party.item_number\
line 3: ($data_items[$game_variables[25]])

 
and i learned from some other guy the easier method by using basic iteration like:
v = $game_variables
p = $game_party
i = $game_items
v[v[24]] = p.item_number(i[v[25]])
 
and result the same way as the previous script.
 
hope it help any noob out here such as me.
Edited by rannade3rd

Share this post


Link to post
Share on other sites

Closing as solved. If you'd like it reopened for any reason then PM me or report the thread.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted