Changing features in-game

Status
Not open for further replies.

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Thank you Fomar :) I'm not going to spend much more time on this tonight, but I'll play around with your snippet and will come back if I still have issues.

BTW - what if I wanted to CHANGE a feature, rather than adding or removing one?
 

Fomar0153

Arkz
Restaff
Joined
Mar 13, 2012
Messages
1,327
Reaction score
473
First Language
English
Primarily Uses
RMMZ
Sorry you'd have to remove it and add a new version.

Code:
f = $game_actors[1].features_with_id(code, id)g = f.select {|ft| ft.value == 1.0}$game_actors[1].del_features += g
And then add it again with a new value:
Code:
f = RPG::BaseItem::Feature.new(code, data_id, value)$game_actors[1].add_features.push(f)
Only thing to watch is this will override feautres added by states but I don't think it's likely states will have the features you want to change on the fly.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I am not sure whether changing features in objects is a good idea.

At least, when I was writing an API for it, I ran into various issues. Maybe I over-thought the problem and fomar's solution is optimal. Not sure.

If you want features to be temporary, use states. Use permanent states or passive states that can be removed using event calls.

That's what states are for: "changing" features on your actors by simply adding or removing them. You can manage the state easily through the database editor and no need for sketchy script calls that are brute-forcing an array of features that could be obtained from arbitrary sources.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
mmm ... so in this case I could add a state that has an equip lock to my character, and remove it when I add her to the party the second time? That's much more simple. Thanks - I'll give that a go first, and if it doesn't work, I'll use the script mod :)


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,570
Latest member
fgfhdfg
Top