MORE SCRIPTING QUESTIONS (ACE)
Posts
Pages:
1
I am trying to learn how to script for RPG maker vx ace, so I can create some more complex events. I want to do a bunch of tricky item modifications by referencing their ID numbers with a variable. I know I need to use the $game_party object, but where can I find a list of functions I can call on it? The help text hasn't proven to be too helpful.
At the very least I need to be able to check if the party has an item X in their inventory. I also need to know how to remove items, of a referenced variable.
Thanks,
equnax
At the very least I need to be able to check if the party has an item X in their inventory. I also need to know how to remove items, of a referenced variable.
Thanks,
equnax
Look in the Game_Party script within the Script Editor.
Anything with 'def' infront of it is a callable function. The breakdown of a function is
def function_name(arguments)
In the Call Script command, you can reference any Game_Party function by using $game_party.function_name
and adding (arguments) if it requires arguments. These are usually described by what the arguments are called in the function. Things like "item_id", "number" etc.
vxAce uses actual RPG::Item/RPG::Weapon/RPG::Armor objects instead of just IDs for most of the functions, so lets take Game_Party#gain_item() for an example.
The function is defined like so:
item in this case is an RPG::Item or RPG::Weapon or RPG::Armor. To get this, the easiest way is: $data_items[id] or $data_weapons[id] or $data_armors[id] where id is the ID in the Database Editor (the number to the left of the entry in the list.)
amount is the amount of the item you wish to add. This number can also be a negative number if you wish to remove the item (or you can use the function lose_item)
include_equip is an additional flag which will let you remove items from the inventory, even if the item is equipped to someone. This is useful if you want to remove key items that the heroes might have equipped. This is false by default (as indicated by the = false following it;) which means you can either omit the argument entirely, or use the boolean term 'true' to let it remove items from the heroes equipped items.
As an example, here I am adding 10 of the 5th Item in the database:
Call Script:
or, here I am removing 40 of the 17th Armor in the database, including anything equipped.
Call Script:
You could also use
or
but if the line of code is split up into two lines in the Call Script field, it won't process properly.
Anything with 'def' infront of it is a callable function. The breakdown of a function is
def function_name(arguments)
In the Call Script command, you can reference any Game_Party function by using $game_party.function_name
and adding (arguments) if it requires arguments. These are usually described by what the arguments are called in the function. Things like "item_id", "number" etc.
vxAce uses actual RPG::Item/RPG::Weapon/RPG::Armor objects instead of just IDs for most of the functions, so lets take Game_Party#gain_item() for an example.
The function is defined like so:
def gain_item(item, amount, include_equip = false)
item in this case is an RPG::Item or RPG::Weapon or RPG::Armor. To get this, the easiest way is: $data_items[id] or $data_weapons[id] or $data_armors[id] where id is the ID in the Database Editor (the number to the left of the entry in the list.)
amount is the amount of the item you wish to add. This number can also be a negative number if you wish to remove the item (or you can use the function lose_item)
include_equip is an additional flag which will let you remove items from the inventory, even if the item is equipped to someone. This is useful if you want to remove key items that the heroes might have equipped. This is false by default (as indicated by the = false following it;) which means you can either omit the argument entirely, or use the boolean term 'true' to let it remove items from the heroes equipped items.
As an example, here I am adding 10 of the 5th Item in the database:
Call Script:
item = $data_items[5] $game_party.gain_item(item, 10)
or, here I am removing 40 of the 17th Armor in the database, including anything equipped.
Call Script:
item = $data_armors[17] $game_party.gain_item(item, -40, true)
You could also use
$game_party.gain_item($data_items[5], 10)
$game_party.gain_item($data_armors[17], -40, true)
Thanks again Prexus, this is immensely helpful. I think some of your examples got screwed up because of the square brackets, but I get the drift. Someone should sticky this post. It is a good overview and it might help others.
author=equnax
Thanks again Prexus, this is immensely helpful. I think some of your examples got screwed up because of the square brackets, but I get the drift. Someone should sticky this post. It is a good overview and it might help others.
Yes they did. Sorry I wrote it and then went to bed without checking it over. I'll fix it with some code tags.
Pages:
1














