i need some help with making a couple of scripts, my RGSS skills are basic and though i know the logic, i'm not sure of the methods (i would be if the classes was constructed using arrays of classes), anyway, here's what i need to know how to do,
- How to check if an actor knows a skill or not (eg. check to see if Actor 1 knows Skill 547)
- How to check if an actor is inflicted with a certain state (eg. Actor 3 is inflicted with State 14)
- How to add and remove skills like the event command
- How to check if an item is in the inventory
- How to check if every index in an array is True without having to use a loop (cause the array i want to check would have over 500 indexes, something is bound to stuff up if i have a running loop)
Here are the ones I'm pretty sure on, although I didn't test.
1. if $game_actor[1].skills.include?(547)
3.$game_actor[1].learn_skill(547) / $game_actor[1].forget_skill(547)
4. $game_party.item_number(547)
Quote from: Memor-X on February 16, 2011, 06:44:10 pm
- How to check if an actor knows a skill or not (eg. check to see if Actor 1 knows Skill 547)
- How to check if an actor is inflicted with a certain state (eg. Actor 3 is inflicted with State 14)
- How to add and remove skills like the event command
- How to check if an item is in the inventory
- How to check if every index in an array is True without having to use a loop (cause the array i want to check would have over 500 indexes, something is bound to stuff up if i have a running loop)
- the include? method of arrays can test if an array contains a value
- same as above
- look at the Game_Actor class for the right method
- look at the Game_Party class
if !array.include?(false) && !array.include?(nil)
or if your array is going to include values other than true, false, and nil
ary.uniq.size == 1 && ary[0] == true
In order:
$game_party.actors[INDEX].skill_learn?(SKILL_ID)
Actor at INDEX learns the skill with SKILL_ID
$game_party.actors[INDEX].state?(STATE_ID)
Returns true/false if actor at INDEX is inflicted with the state with STATE_ID
$game_party.actors[INDEX].learn_skill(SKILL_ID)
$game_party.actors[INDEX].forget_skill(SKILL_ID)
Actor at INDEX learns/forgets skill with SKILL_ID
$game_party.item_number(ITEM_ID) > 0
Returns true/false if party has item in inventory with quantity greater than 0
If you are simply checking for all "true" you can simply do that. A block has to be supplied if you are checking conditions with this method.
... I though there was an all? method but when I went looking for it to make sure I couldn't find it.... then I looked at the enumerable module ?*facepalm*