No idea why you get that error, but I would do it like this instead:
Spoiler
Code:
class Game_Interpreter
#--------------------------------------------------------------------------
# ● Edit Here
# when handle
# $game_message.choices.push("a choice")
#--------------------------------------------------------------------------
def more_choice(p)
case p
when "Eat Food2"
# The numbers here are item IDs from your database.
# Change them, remove them, add more, etc to suit your need.
[11,12,13,14,15,16].each do |item_id|
# $data_items[item_id] will load an Item from your database.
# $data_weapons[item_id] will load a Weapon from your database.
# $data_armors[item_id] will load an Armor from your database.
item = $data_items[item_id]
next unless $game_party.has_item?(item) # Don't add if the player got no such item.
txt = "#{item.name}: #{$game_party.item_number(item)}" # Shown text.
$game_message.choices.push(txt)
end
if $game_message.choices.empty? # No food items in inventory
# This choice shows up only when the player got no items
# from the above item list.
$game_message.choices.push("Bollocks, I got no food! o.O")
else
# And this shows up if the player got some of the listed items.
# Obviously, you can use this as a Cancel handler.
$game_message.choices.push("Cancel")
end
else
$game_message.choices.push(p)
end
end
#--------------------------------------------------------------------------
# ● Long Choices - Don't edit this bit
#--------------------------------------------------------------------------
def setup_choices(params)
for s in params[0]
more_choice(s)
end
$game_message.choice_cancel_type = params[1]
$game_message.choice_proc = Proc.new {|n| @branch[@indent] = n }
end
end
class Window_ChoiceList < Window_Command
#--------------------------------------------------------------------------
# ● Feel free to change the 1 to another variable that you'd prefer
#--------------------------------------------------------------------------
alias mc_call_ok_handler call_ok_handler
def call_ok_handler
# Changed to store the selected choice's text instead of it's index.
$game_variables[81] = $game_message.choices[index]
mc_call_ok_handler
end
end
I changed the script a bit, and made another editable place, because with dynamic lists such as yours, if there is a cancel option, it would be kinda hard to get when the player actually cancelled the selection.
You can add more choice selection checks in the call_ok_handler method to make sure when a specific choice is selected, you set the variable to something unique so that you know for sure, which enables you to make your conditional branches for the choice variable actually useful for these lists with dynamic choice positions.
I tried to explain how the method at the choice creation works. Basically, you won't need to use any variables for that list you wanted to make this way, and it will automatically name your choices correctly too. Just change the item IDs in the array, and it will work how you wanted.
I tested this, and it works how it should. But if you still get that stack error, show us your event where these choice options happen, maybe something went wrong there (although that is not very likely, unless you made some recursive methods in a script call).
Either that, or you installed this script more than one time, in which case, you should remove the extra ones.
Edit:
Ohh, scratch that, I realized that the way I did it, the whole list becomes a big dynamic choice list, which makes the index of choices basically useless. You would need to set the choice text itself for the variable and check that in your conditional branches after the choice command in your events. That is still fairly easy to do, just use the "Script" option in the "Conditional Branch" event command, and type in something like:
$game_variables[81].include?("item name here")
For the item based choices.
And for static choices, you can simply use this:
$game_variables[81] == "choice text here"
So, instead of checking the index of the choices, you check for the name of the choices, which works, even for dynamic choice lists.
I have changed the above edited script to store the direct choice text for the variable instead of the choice index.