Ruby/RGSSx questions that don't deserve their own thread

That means you passed the wrong object as an argument for your skill requirements object.
You need the Game_Actor object, not the RPG::Actor object, they are different.

The Game_Actor class actually got an actor method that returns the database object of the actor (that is the RPG::Actor object).
To get the Game_Actor object, you should use self for the argument there.
That appears to be the issue, thanks a lot!
I'm trying to use scripting to edit paramters, xparameters and sparameters. For the parameters I'm using the add_param function defined in Game_BattlerBase. For the xparameters and sparameters I've created two arrays to keep track of the modifications, and edited the xparam() and sparam() functions as shown below:
#-------------------------------------------------------------------------- # * Get Ex-Parameter #-------------------------------------------------------------------------- def xparam(xparam_id) return features_sum(FEATURE_XPARAM, xparam_id)+@xparam_Boost[xparam_id] end #-------------------------------------------------------------------------- # * Get Sp-Parameter #-------------------------------------------------------------------------- def sparam(sparam_id) features_pi(FEATURE_SPARAM, sparam_id)+@sparam_Boost[sparam_id] end

The parameter changes seem to survive loading the game, but the x and s parameters don't. I think I might be able to find a workaround, but I was just wondering if someone could explain this to me, or had any thoughts on the easiest fix?

Edit: I think I've got it working now. I had also edited the clear_param_plus() function to wipe the xparam_Boost and sparam_Boost arrays. I had thought that since the clear_param_plus() wiped the param_plus variable it would reset any changes I made to parameters, therefore I figured anywhere clear_param_plus() would be called I should also reset changes to xparameters and sparamters. I guess I was wrong, removing that reset seems to have fixed it. I'm a bit confused as to how my changes to parameters survive clear_param_plus() being called though.
I am using ace, and if i do this code:
w = $game_party.members[0].weapons[0].id
@player_weapon = $data_weapons[w]

it crashes, but if I put:
return if $game_party.members.empty?

then it opens without crashing. So the game thinks my party members are nil. How can it think the party is nil when the game starts with 2 members? Im very confused
the party is not filled with actors until after you start the game.
if you're running that code right at the beginning, the party will always be empty.
oh ok thanks. Do you know what i could use to get the players current weapon?
You already posted that solution, @alyssabat
It still doesnt work though, the console shows that the $game_party part is working and returns the weapon id, but the variable I made for it is nil. Is there a certain place I should put it? I tried putting it in the game_player update but that didnt work either
If at a certain point in game the leader isn't wielding a weapon, the ID will be 0 and you are unable to create one in the slot number 0 in the database; thus it will return nil or throw an error message.
I have it start the game with a weapon equipped, maybe it doesn't notice at first. Ill just keep playing with it.
Is there a formula for centering the window horizontally? Not the text, but the window containing it.

think I found it-
pos_x = Graphics.width - window_width
new_x = pos_x - (pos_x/2)
then you use new_x
How do you check variables from another map that is not the one you're in? For example, something like $game_map[2].display_name to check the display name of map of id 2, in case player is in map of id 1.
You need to load the map data.

map_data = load_data(map_filename)
map_data.display_name
I am looking to do an "Auto" battle function in my battle scene. I currently have a working command below where it checks for all battle members alive and they do an auto attack - which works fine.

Ruby:
$game_party.alive_members.each {|a| a.make_auto_battle_actions}

But.. I now want only the first 3 actors alive in my party to do auto battle function instead of all battle members alive. I am not sure how to piece the code together. Any assistance would be appreciated.

*Edit: I ended up figuring it out. Below is the code to help anyone else.

Ruby:
$game_party.alive_members[0..2].each {|a| a.make_auto_battle_actions}
I am looking to do an "Auto" battle function in my battle scene. I currently have a working command below where it checks for all battle members alive and they do an auto attack - which works fine.

Ruby:
$game_party.alive_members.each {|a| a.make_auto_battle_actions}

But.. I now want only the first 3 actors alive in my party to do auto battle function instead of all battle members alive. I am not sure how to piece the code together. Any assistance would be appreciated.

*Edit: I ended up figuring it out. Below is the code to help anyone else.

Ruby:
$game_party.alive_members[0..2].each {|a| a.make_auto_battle_actions}
Yet, I suspect it could throw an error if any of those 3 actors isn't alive because the alive_members iterator returns just 1 or 2 living members. Perhaps adding .compact before calling the .each method could prevent you from getting headaches in the future.
Yet, I suspect it could throw an error if any of those 3 actors isn't alive because the alive_members iterator returns just 1 or 2 living members. Perhaps adding .compact before calling the .each method could prevent you from getting headaches in the future.
Just to clarify, I am also using RPG Maker VX Ace.

So I put one of the 3 actors in a death state and did not receive an error at all. But, when one of those 3 actors are dead, it moves to the next "alive" ones which deviates from the first 3 to the 4th... 5th.. etc.

The below code works for me without issue now and I am not receiving any errors when any of the first 3 actors are dead.

Ruby:
$game_party.battle_members[0..2].each {|a| a.make_auto_battle_actions}

*Btw, I saw the same results with the .compact parameter so I left that out, but I appreciate the possible heads up.
Just to clarify, I am also using RPG Maker VX Ace.

So I put one of the 3 actors in a death state and did not receive an error at all. But, when one of those 3 actors are dead, it moves to the next "alive" ones which deviates from the first 3 to the 4th... 5th.. etc.

The below code works for me without issue now and I am not receiving any errors when any of the first 3 actors are dead.

Ruby:
$game_party.battle_members[0..2].each {|a| a.make_auto_battle_actions}

*Btw, I saw the same results with the .compact parameter so I left that out, but I appreciate the possible heads up.
Well, if it's working fine, who cares right? But I was talking about an "edge case" where there were not enough living members alias battle_members to fill in the places of any of the 3 battlers you are expecting to show up there. Of course, it might get complicated to cause such an error if you got like 12 members including reservists in your team. Just saying.
What is the easiest way to check all state names currently on actor? The area I am working in, I have access to @actor = actor. So, I just need the line of code to perform this action.

I have tried:
Ruby:
@actor.states
and it works, but I cannot pull the name when I try to append '.name", even though it is visible through the console.

*Using VX Ace

Edit: I ended up figuring it out. Maybe it will be useful for someone else as well.
Ruby:
# Grabs all state names on the current actor
@actor.states.collect { |state| state.name }
I am looking to do something clever with a new method under $game_system. My method below does not work because I am trying to demonstrate what I want to achieve with the script call.

Ruby:
class Game_System
  #--------------------------------------------------------------------------
  # * New Method:
  #--------------------------------------------------------------------------
  def unlock_achievement_slot(value)=(string)
    @unlock_achievement_slot = string
    $game_switches[value] = @unlock_achievement_slot
  end
end

So, when I go to use the script call, I want to be able to do something like this..

Ruby:
# Here is how the setup should work
# value =  a game switch number
# string = a game switch equal "true" or "false"
$game_system.unlock_achievement_slot(value) = (string)

# Here is what I want it to look like when I do the script call
$game_system.unlock_achievement_slot(1) = true

Any insight/help is greatly appreciated.
You can only pass a single argument if the method name includes an equal sign.
You gotta pass two arguments (value, string) instead.
You can only pass a single argument if the method name includes an equal sign.
You gotta pass two arguments (value, string) instead.
Okay, that makes sense. I have seen this approach on other methods as well.

Sounds like what I was looking for and I will give a go. Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/