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

archon325

Villager
Member
Joined
Mar 31, 2021
Messages
11
Reaction score
0
First Language
english
Primarily Uses
RMVXA
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!
 

archon325

Villager
Member
Joined
Mar 31, 2021
Messages
11
Reaction score
0
First Language
english
Primarily Uses
RMVXA
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.
 
Last edited:

alyssabat

Villager
Member
Joined
Jul 19, 2016
Messages
21
Reaction score
8
First Language
English
Primarily Uses
RMVXA
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
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
3,140
Reaction score
2,272
First Language
Spanish
Primarily Uses
RMVXA
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.
 

alyssabat

Villager
Member
Joined
Jul 19, 2016
Messages
21
Reaction score
8
First Language
English
Primarily Uses
RMVXA
oh ok thanks. Do you know what i could use to get the players current weapon?
 

alyssabat

Villager
Member
Joined
Jul 19, 2016
Messages
21
Reaction score
8
First Language
English
Primarily Uses
RMVXA
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
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
1,158
Reaction score
546
First Language
English
Primarily Uses
RMXP
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.
 

alyssabat

Villager
Member
Joined
Jul 19, 2016
Messages
21
Reaction score
8
First Language
English
Primarily Uses
RMVXA
I have it start the game with a weapon equipped, maybe it doesn't notice at first. Ill just keep playing with it.
 

alyssabat

Villager
Member
Joined
Jul 19, 2016
Messages
21
Reaction score
8
First Language
English
Primarily Uses
RMVXA
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
 
Last edited:

Ebanyle

what
Veteran
Joined
Sep 2, 2016
Messages
377
Reaction score
241
First Language
Portuguese
Primarily Uses
RMVXA
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.
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
1,158
Reaction score
546
First Language
English
Primarily Uses
RMXP
You need to load the map data.

map_data = load_data(map_filename)
map_data.display_name
 

FG7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
76
Reaction score
27
First Language
English
Primarily Uses
RMVXA
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}
 
Last edited:

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
1,158
Reaction score
546
First Language
English
Primarily Uses
RMXP
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.
 

FG7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
76
Reaction score
27
First Language
English
Primarily Uses
RMVXA
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.
 
Last edited:

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
1,158
Reaction score
546
First Language
English
Primarily Uses
RMXP
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.
 

FG7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
76
Reaction score
27
First Language
English
Primarily Uses
RMVXA
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 }
 
Last edited:

FG7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
76
Reaction score
27
First Language
English
Primarily Uses
RMVXA
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.
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
1,158
Reaction score
546
First Language
English
Primarily Uses
RMXP
You can only pass a single argument if the method name includes an equal sign.
You gotta pass two arguments (value, string) instead.
 

FG7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
76
Reaction score
27
First Language
English
Primarily Uses
RMVXA
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.
 

Latest Threads

Latest Profile Posts

With this, I'm gonna have a good night sleep
Damn. We’ve gotten so close to 0 reports, 0 approvals a few times over the past couple weeks. Does it matter? No. Is it realistic. No? Do I rely on your reports and want everyone to keep posting. Yes. Do I 100% games? …sigh… Yes.

Ah yes, all three of my moods all at once.
Here's a tutorial I did on how I made my Leonardo A.I.-assisted artworks for my game's recent update. :rhappy:

Disclaimer: This is meant to be a band-aid solution for people like me who aren't good artists or don't have the financial means to hire an amazing artist. If you have the means, please buy commissions and support your fav artists.:yhappy:

Forum statistics

Threads
131,755
Messages
1,223,006
Members
173,518
Latest member
Tiagrun
Top