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

Is there any way to modificate galv's group manager script to 1) have only one group in the home base where you can add max 7 members
2) when a party member is joining and the party is full, to drop it automatically to the group of the home base instead of making you to add him by yourshelf 3) When you add a member in the home base group, a specific variable's constant is being substracted by 1 and added by 1 as removing it from the group. And 4) Remove the 0/8 (in my case will be 0/7) letters in the right side of the group window, so the player will not know how many of how members are in.
Hello, I have run into a strange error in creating my own script.

How the script is supposed to work is, when you press the 'Enter/Confirm' button in a skill window, instead of using the skill, the script checks whether the Actor has a particular State, and then either applies the State if they don't, or removes the State if they do. The purpose of this is to have passive skills, which can be toggled on or off.

I have got the code doing what I want on the first try, but on my second attempt to toggle the skill on, the ".add_state(x)" command seems to stop working. The code and accompanying screenshots illustrating the error are in the spoilers below. I have managed to replicate the problem in a new project, so the error does seem to stem from the code I have written.

Spoiler: The Code
class Game_Actor < Game_Battler

attr_reader :ap #Ability Points

#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias ajjg_init initialize
def initialize(actor_id)
ajjg_init(actor_id)
@ap = init_ap
end
#--------------------------------------------------------------------------
# * Get Maximum Value of Parameter
#--------------------------------------------------------------------------
def param_max(param_id)
return 9999 if param_id == 0 # MHP
return 999 if param_id == 1 #MMP
return super
end
#--------------------------------------------------------------------------
# * Initialize Actor AP
#--------------------------------------------------------------------------
def init_ap
self.ap = self.max_ap
end
#--------------------------------------------------------------------------
# * Change AP
#--------------------------------------------------------------------------
def ap=(ap)
@ap = [[ap, max_ap].min, 0].max
end
#--------------------------------------------------------------------------
# * Get Maximum Value of AP
#--------------------------------------------------------------------------
def max_ap
return [9 + (self.level / 3) + (self.mmp / 16), 99].min
end
#--------------------------------------------------------------------------
# * Get Percentage of AP
#--------------------------------------------------------------------------
def ap_rate
@ap.to_f / self.max_ap
end
#--------------------------------------------------------------------------
# * Calculate Skill's AP Cost
#--------------------------------------------------------------------------
def skill_ap_cost(skill)
skill.ap_cost
end
#--------------------------------------------------------------------------
# * Get Skill's attached State ID
#--------------------------------------------------------------------------
def skill_st_id(skill)
skill.skill_st
end

end #Game_Actor
#--------------------------------------------------------------------------
class RPG::Skill
#LOAD SKILL NOTETAGS
#------------------------------------------------------------------------------
# * AP-Cost. Set using <ap x> notetag.
#------------------------------------------------------------------------------
def ap_cost
if @note =~ /<ap (.*)>/i
return $1.to_i
else
return 0
end
end
#--------------------------------------------------------------------------
# * Skill's attached State ID
#--------------------------------------------------------------------------
def skill_st
if @note =~ /<st (.*)>/i
return $1.to_i
else
return 0
end
end

end #RPG::Skill

class Window_SetSkills < Window_SkillList
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
@stype_id = 15
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
rect.width -= 4
draw_item_name(skill, rect.x + 8, rect.y, set_skill_able(skill))
draw_skill_cost(rect, skill)
draw_item_icon(skill, rect.x + 8, rect.y)
end
end
#--------------------------------------------------------------------------
# * Check if Actor has enough AP for skill
#--------------------------------------------------------------------------
def set_skill_able(skill_id)
if @actor.state?(@actor.skill_st_id(skill_id)) || @actor.ap >= @actor.skill_ap_cost(skill_id)
return true
else
return false
end
end
#--------------------------------------------------------------------------
# * Draw Icon indicating whether a skill is on or not
#--------------------------------------------------------------------------
def draw_item_icon(skill_id, x, y)
if @actor.state?(@actor.skill_st_id(skill_id))
draw_icon(536, x, y)
else
draw_icon(535, x, y)
end
end
#--------------------------------------------------------------------------
# * Overwritten Method: Draw Skill Use Cost
#--------------------------------------------------------------------------
def draw_skill_cost(rect, skill)
draw_text(rect, @actor.skill_ap_cost(skill), 2)
end
#--------------------------------------------------------------------------
# * Overwritten Method: Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
make_item_list
create_contents
draw_all_items
end

end #Window_SetSkills
#--------------------------------------------------------------------------
class Scene_SetSkills < Scene_ItemBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_help_window
create_status_window
create_item_window
end
#--------------------------------------------------------------------------
# * Create Status Window
#--------------------------------------------------------------------------
def create_status_window
y = @help_window.y + (@help_window.height + 4)
@status_window = Window_SkillStatus.new(16, y)
@status_window.x = (Graphics.width - @status_window.width) / 2
@status_window.viewport = @viewport
@status_window.actor = @actor
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
def create_item_window
wx = 16
wy = @status_window.y + (@status_window.height)
ww = @status_window.width
wh = Graphics.height - (wy + 24)
@item_window = Window_SetSkills.new(wx, wy, ww, wh)
@item_window.x = (Graphics.width - @item_window.width) / 2
@item_window.actor = @actor
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.activate
@item_window.select_last
@item_window.set_handler🙂ok, method🙂toggle_skill))
@item_window.set_handler🙂cancel, method🙂return_scene))
@item_window.set_handler🙂pagedown, method🙂next_actor))
@item_window.set_handler🙂pageup, method🙂prev_actor))
end
#--------------------------------------------------------------------------
# * Toggle Currently Highlighted Skill
#--------------------------------------------------------------------------
def toggle_skill
@actor.last_skill.object = item
state_id = @actor.skill_st_id(item)
ap_cost = @actor.skill_ap_cost(item)
if @actor.state?(state_id)
@actor.remove_state(state_id)
@actor.ap += ap_cost
elsif [email protected]?(state_id) && @actor.ap >= ap_cost
@actor.add_state(state_id)
@actor.ap -= ap_cost
elsif @actor.ap < ap_cost
Sound.play_buzzer
end
@item_window.refresh
@status_window.refresh
@item_window.activate
end
#--------------------------------------------------------------------------
# * Change Actors
#--------------------------------------------------------------------------
def on_actor_change
@status_window.actor = @actor
@item_window.actor = @actor
@item_window.activate
end

end #Scene_SetSkills

This particular method (which applies/removes the state as applicable) seems to be where the error lies, but I can't see what is causing it.

Spoiler: Code
#--------------------------------------------------------------------------
# * Toggle Currently Highlighted Skill
#--------------------------------------------------------------------------
def toggle_skill
@actor.last_skill.object = item
state_id = @actor.skill_st_id(item)
ap_cost = @actor.skill_ap_cost(item)
if @actor.state?(state_id)
@actor.remove_state(state_id)
@actor.ap += ap_cost
elsif [email protected]?(state_id) && @actor.ap >= ap_cost
@actor.add_state(state_id)
@actor.ap -= ap_cost
elsif @actor.ap < ap_cost
Sound.play_buzzer
end
@item_window.refresh
@status_window.refresh
@item_window.activate
end

Spoiler: The Screen Shots
The Scene by default:
Screen1.png


The Skill correctly toggles on, as evidenced by the appearance of the red icon beside the skill, the State icon, and the deduction of points from the Actor's total:
Screen2.png


The Skill correctly toggles off, everything reverts to as it was before:
Screen3.png


The State fails to apply on the second attempt to toggle on, but the points are still deducted:
Screen4.png


At this point, pressing the button again will continue to drain the Actor's points, without adding the State. This continues until they no longer have enough points to toggle the skill.

I am sorry if I have posted in the wrong place, or the error is something simple/a really obvious oversight on my part, and any help/direction to the correct place would be very much appreciated 🙂
@AJJG_1995 It might be that this query does, in fact, deserve its own thread in Script Support. I shall have to wait and see what sort of response is made by experienced scripters as to whether this is something simple or complex.
Thank you, Kes. 🙂
@AJJG_1995 Check out passive skills here and passive states here. Maybe you can get an idea on what you need to do for your own script.
And if you need more help beyond that, I would agree that you need to make your own thread under script support.

BTW, looks nice. Well done.
@Roninator2 Thank you for your advice 🙂 I managed to get toggling to work by changing from an ".add_state()" command to sending the state ID along to a "@states.push()" command in Game_Actor instead, and as far as I can see, it's working so far 🙂

As for now, I'm going to work on making the states permanent until manually removed via the menu. And thank you for the compliment. 🙂
Hey guys, learning to script in VXA and i was just seeing the code for the "Cache" module and saw a thing i didn't understand.

def self.normal_bitmap(path)
@cache[path] = Bitmap.new(path) unless include?(path)
@cache[path]
end

What i don't understand is the "unless" part. I know that since the receiver isn't explicitly mentioned here, it's "self" by implicit. However "self" in this case should point to the module itself and not to the hash "cache" ? Shouldn't it refer to the cache explicitly by
@cache.include?(path)

Tried to do the same thing online and as expected it threw the error
Wrong Argument type String (Expected Module)

Sorry i am new to Ruby ;s
As you'll see on line 123, Cache defines a method called self.include? which is the one being called on line 106. You don't need to explicitly refer to it because "self" does indeed point to the module itself, which is exactly what was intended.
As you'll see on line 123, Cache defines a method called self.include? which is the one being called on line 106. You don't need to explicitly refer to it because "self" does indeed point to the module itself, which is exactly what was intended.

Totally missed that, lol. Like the C++ style better could see all those method definitions at the start.
@Trihan Sorry to bother you again but I wanted to ask if i am interpreting this correctly.

The main entry point is the main script
rgss_main { SceneManager.run }

The run function is defined as
def self.run
DataManager.init
Audio.setup_midi if use_midi?
@scene = first_scene_class.new
@scene.main while @scene
end

And the main function of the Scene is defined as
def main
start
post_start
update until scene_changing?
pre_terminate
terminate
end

Am i correct to interpret that this is somewhat the actual main game loop. The "main" function draws the main windows first then keeps calling "update" until there is a change in the scene (i.e scene transitions from map to shop or battle etc.) The update function itself calls "Graphics.update" which according to the official docs refreshes the screen so i am assuming this does the job of "clear()" as in clearing everything drawn. This goes on until the scene changes at which the main windows are disposed of and new ones are created.
Your interpretation is correct.
What script call would you use the check if an item is being used, rather than if it is just in inventory?
Hi guys!
I've been trying to use this presumable lines of code:
Spoiler: Code
# * `module DataManager`
# - `self.check_language`
# - `self.set_language`
It's from SES External Text(Multilang add-on)but it's not actual code :/
I thought these might have been script calls but I've tried to use them and didn't work.
Can you guys tell me what is this supposed to be used for?

Thank you 🙂
What would the eval be for checking if an actor has one of two armor types equipped?
I'm basically trying to get something that returns true if the actor has either a small shield or a large shield, and false if they've got neither.
@SaburoX
Code:
shield_slot = $game_actors[id].equips[1]
shield_slot.nil? ? false : [5, 6].include?(shield_slot.atype_id)
Set the actor ID.
5, 6 are the default armor type IDs for small and large shields respectively.
That'll do it. Thanks a lot.
Does anyone know the script commands to detect if any save game exists already for the game?
Does anyone know how to check which language is being used in game by SES External Text?
@bgillisp Try this out:
Code:
DataManager.save_file_exists?
@Rinobi : Appears to be working! Thanks!

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