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

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,041
Reaction score
679
First Language
English
Primarily Uses
RMVXA
this part of the skills menu
What part? by default there is only one skills screen.
a skill section called Feats
What script does this? How do you have it added in? (how is the screen called?) If it is a new scene then just using the SceneManager.call command will work, but if it is a subscreen of the skills scene, then maybe Theo has an option.
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
325
Reaction score
302
First Language
English
Primarily Uses
RMVXA
What part? by default there is only one skills screen.

What script does this? How do you have it added in? (how is the screen called?) If it is a new scene then just using the SceneManager.call command will work, but if it is a subscreen of the skills scene, then maybe Theo has an option.
Sorry, I described it badly. The "Feats" section is just one of the "Skill Types" in the Terms database. I want the script call to open to this skill type.

skill page.png
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,041
Reaction score
679
First Language
English
Primarily Uses
RMVXA
I want the script call to open to this skill type
I don't know about a script call, but a small script snippet will do.
Ruby:
module R2_Skill_Select
  Switch = 1
end
class Scene_Skill < Scene_ItemBase
  alias r2_skill_start_select start
  def start
    r2_skill_start_select
    @command_window.select(1) if $game_switches[R2_Skill_Select::Switch] == true
  end
end
turn switch on and when loading scene it will highlight command 1 not 0
SceneManager.call(Scene_Skill)
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
I am wondering if you can store a constructed $game_party script call into a variable and then recall the script call via the variable. Let me explain below.

I have defined a new method in the $game_party class called "actor_mp_levels_actor1"
Ruby:
def actor_mp_levels_actor1
    return [$game_variables[900], $game_variables[901], $game_variables[902], $game_variables[903]]
end

Within a window I have created, I am trying to do something fancy with a variable
Ruby:
@testmethod = "$game_party.actor_mp_levels_actor" + "1"
draw_text(rect, @test, 2)

When it is placed in the draw_text and I start the game, the $game_party method is not actually called, it is viewed as static string that has no meaning and displays "actor_mp_levels_actor1". The same is shown in the console as well. And yes there is a reason I am wanting to append a number on the end like I am doing. This number will ultimately be another variable which indicates a number that I will append.

Is there a way to store the script call into a variable and recall it as the original script call?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
690
Reaction score
448
First Language
English
Primarily Uses
RMVXA
@FamilyGamer7 You can do $game_party.send("actor_mp_levels_actor#{id}"), where id is the integer you want to use.
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
I have fairly large list being thrown into a definition that goes all the way to game variable 939 (At least right now). I know I can loop game variable 900 through 939, but every 4 variables has @actorlevel1.. 2.. 3..4. You get the point.

How would I go about looping 900 through 939 with the complexity of my @actorlevel1-4? It's more or less syntax I do not know.

Ruby:
$game_variables[900] = @actorlevel1
$game_variables[901] = @actorlevel2
$game_variables[902] = @actorlevel3
$game_variables[903] = @actorlevel4
$game_variables[904] = @actorlevel1
$game_variables[905] = @actorlevel2
$game_variables[906] = @actorlevel3
$game_variables[907] = @actorlevel4
$game_variables[908] = @actorlevel1
$game_variables[909] = @actorlevel2
$game_variables[910] = @actorlevel3
$game_variables[911] = @actorlevel4
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,168
Reaction score
7,374
First Language
Indonesian
Primarily Uses
RMVXA
Easiest to understand syntax
Code:
def actor_level(mod)
  case mod
  when 0
    @actorlevel1
  when 1
    @actorlevel2
  when 2
    @actorlevel3
  when 3
    @actorlevel4
  end
end
40.times do |i|
  $game_variables[i + 900] = actor_level(i % 4)
end
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
Easiest to understand syntax
Code:
def actor_level(mod)
  case mod
  when 0
    @actorlevel1
  when 1
    @actorlevel2
  when 2
    @actorlevel3
  when 3
    @actorlevel4
  end
end
40.times do |i|
  $game_variables[i + 900] = actor_level(i % 4)
end

Just tried and works. Thanks.
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
I am looking to disable my equipment slots if inventory reaches a certain max limit. So, if my inventory reach 30/30, then it would disable my equipment slots on my actors. Okay, I have implemented this. But, I would still like the ability for the user to be able to equip in a slot that is "nil = nothing". But, once they equip the item in that slot, it will disable until the item inventory is below the max limit (Ex 29/30). So, this creates a.. I can add items in my equipment slot, but cannot remove until inventory is under max limit.

I already have the logic for the item inventory limit, but I just need the logic to disable the equip slot if an item is in the slot. My current logic attempt disables all slots if one of the slots meets the condition, which I only want it to disable that specific slot.

*I am using the default VX Ace "Window_EquipSlot" script.

1610906630844.png
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,041
Reaction score
679
First Language
English
Primarily Uses
RMVXA
the default VX Ace "Window_EquipSlot" script.
Impossible. You have something else that is modifying the equip slots.
There is only 1 extra in the default
1610909528268.png

Unless you modified this default script.

How are you making the extra slots? This would be necessary to know in order to identify what slot is being queried.
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
Impossible. You have something else that is modifying the equip slots.
There is only 1 extra in the default
View attachment 176054

Unless you modified this default script.

How are you making the extra slots? This would be necessary to know in order to identify what slot is being queried.

Technically you are correct, but the other slots that I have created can be excluded from the equation as all I have done is extend my equip slots. The index number of the slot is still treated the same whether it be equip_slot[1] or equip_slot[7]. Same still applies to the logic also. So, if you supplied logic with using just the "out of the box" VX Ace scripts, then that would be sufficient. I'm sure I am not your typical user asking for assistance....

Overall, I am only using the "Window_EquipSlot" script that is already provided in the engine in terms of how the slots are displayed and if they are enabled or disabled. No other external script is changing this behavior.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,041
Reaction score
679
First Language
English
Primarily Uses
RMVXA
the other slots that I have created can be excluded from the equation as all I have done is extend my equip slots
Fair enough.
looking into a way to check this I see that Hime has an inventory size script that does what you want. Perhaps you can make something from that or use it.
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
Fair enough.
looking into a way to check this I see that Hime has an inventory size script that does what you want. Perhaps you can make something from that or use it.

I took a look around and I found the script you are referring too.. but, I cannot find a valid link or download for the script to take a look at. Unfortunately I am not by my computer the moment. Any luck finding a valid link?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,041
Reaction score
679
First Language
English
Primarily Uses
RMVXA
cannot find a valid link
True, seems to be lost. I uploaded it to the RPGMakerCentral formus in the thread there.
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
True, seems to be lost. I uploaded it to the RPGMakerCentral formus in the thread there.

Thank you. Glad it wasn't me just over looking. This should be what I am needing. I will more likely strip out from the script what I need.

*Edit: So, I was able to strip out the necessary code to solve my question. I just wanted to post as it may help others. Below is the code from "Hime - Inventory Size" script...

Ruby:
  # Can't remove equips if inventory is full
  alias :th_inventory_size_trade_with_party :trade_item_with_party
  def trade_item_with_party(new_item, old_item)
    return false if new_item.nil? && $game_party.inventory_full?
   
    # hack because the default method adds before removing, which is silly
    $game_party.change_inventory_size(1)
    res = th_inventory_size_trade_with_party(new_item, old_item)
    $game_party.change_inventory_size(-1)
    return res
  end

  return false if new_item.nil? && $game_party.inventory_full? # This is the piece you want

Here is my simple insertion into my project.. (Override Method)

Ruby:
 def trade_item_with_party(new_item, old_item)
    return false if new_item.nil? && $game_party.inventory_count_full? # My insertion
    $game_party.gain_item(old_item, 1)
    $game_party.lose_item(new_item, 1)
    return true
  end

As you can see, not much changed.. except I already had a inventory count check similar to the inventory size script.

*Edit 2: To take it a step further within the Equip_Scene. Now you will essentially get a buzzer sound if the inventory is full. This helps let your player know something is at least wrong.

Ruby:
  def on_item_ok
    if $game_party.inventory_count_full?
      Sound.play_buzzer
    else
      Sound.play_equip
    end
    @actor.change_equip(@slot_window.index, @item_window.item)
    @slot_window.activate
    @slot_window.refresh
    @item_window.unselect
    @item_window.refresh
  end
 
Last edited:

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
So, I am trying to create my own basic rune system and so far, I have been very successful. But, I am running into an issue where I have created a duplicate Window_EquipSlot and I am trying to filter out all of the equipment slots except for my last 4. When I got into this new scene with the duplicated Window_EquipSlot, it should only show those 4 slots to be selected.

My current equip_slot order: (I am trying to go after 8, 9, 10, 11)
  • [2, 1, 3, 5, 6, 7, 0, 8, 9, 10, 11]
*Note: My equip_slot order cannot change or be re-arranged

For reference, I am using Custom Equipment Slots by Fomar0153 to extend my slots:
Ruby:
=begin
Custom Equipment Slots Script
by Fomar0153
Version 1.2
----------------------
Notes
----------------------
No requirements
Allows you to customise what equipment characters can equip
e.g. add new slots or increase the number of accessories.
----------------------
Instructions
----------------------
You will need to edit the script in two locations both are near
the top of the script look for:
Slots[7] = "Spell Tomes"
return [0,0,2,3,4,4,4,7] if dual_wield?
and follow the instructions where they are.
----------------------
Changle Log
----------------------
1.0 -> 1.1 : Fixed a bug that caused a crash when equipping a weapon.
1.1 -> 1.2 : Fixed a bug with optimisation and remove all
             Increased compatibility
----------------------
Known bugs
----------------------
None
=end
#--------------------------------------------------------------------------
# ● New Module Extra_Slots
#--------------------------------------------------------------------------
module Extra_Slots

  Slots = []
  # Edit here to add new slot types
  # Slots[armour_type_id] = "name"
  # I know it is named in the database but I don't believe you can access
  # that name through Vocab
  Slots[5] = "extra"
  Slots[6] = "extra"
  Slots[7] = "extra"
  Slots[8] = "fh."
  Slots[9] = "lw."
  Slots[10] = "rw."
  Slots[11] = "wpn."

end

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● Rewrites equip_slots
  #--------------------------------------------------------------------------
  # Edit here to change what slots are available to your characters
  # 0 - Weapon
  # 1 - Shield
  # 2 - Head
  # 3 - Body
  # 4 - Accessory
  # 5+ a custom slot
  def equip_slots
    return [2, 1, 3, 5, 6, 7, 0, 8, 9, 10, 11]
  end
end

class Window_EquipSlot < Window_Selectable
  #--------------------------------------------------------------------------
  # ● Rewrites slot_name
  #--------------------------------------------------------------------------
  def slot_name(index)
    if @actor.equip_slots[index] >= 5
      Extra_Slots::Slots[@actor.equip_slots[index]]
    else
      @actor ? Vocab::etype(@actor.equip_slots[index]) : ""
    end
  end
end

class Scene_Equip < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● Aliases create_slot_window
  #--------------------------------------------------------------------------
  alias custom_slots_create_slot_window create_slot_window
  def create_slot_window
    custom_slots_create_slot_window
    @slot_window.create_contents
    @slot_window.refresh
  end
  #--------------------------------------------------------------------------
  # ● Aliases on_actor_change
  #--------------------------------------------------------------------------
  alias custom_slots_on_actor_change on_actor_change
  def on_actor_change
    custom_slots_on_actor_change
    @slot_window.create_contents
    @slot_window.refresh
  end
end


module RPG
  class Armor
  #--------------------------------------------------------------------------
  # ● I wish I'd done this originally.
  #--------------------------------------------------------------------------
    def etype_id
      if Extra_Slots::Slots[self.atype_id] == nil
        return @etype_id
      else
        return self.atype_id
      end
    end
  end
end
 

FamilyGamer7

Veteran
Veteran
Joined
Jan 4, 2021
Messages
33
Reaction score
6
First Language
English
Primarily Uses
RMVXA
This looks like it could definitely be in its own thread.

I was debating putting into it's own thread, but this should be a change within the Window_EquipSlot to filter out all slots except the above mentioned. I only referenced the other script to put in perspective for the extended slots.

In reality, we could put this to bare bones and I want to filter off specific default equip slots. The same applies, I have just given a little more context in my post. I guess I am looking for the logic/syntax?
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,168
Reaction score
7,374
First Language
Indonesian
Primarily Uses
RMVXA
To get the value of an array starting from the last index, you use -1 and so on
For example,
Code:
array = [2, 1, 3, 5, 6, 7, 0, 8, 9, 10, 11]
array[-1] # 11
array[-2] # 10
array[-3] # 9
array[-4] # 8
array[-5] # 0
 

Latest Threads

Latest Posts

Latest Profile Posts

Just a reminder to back your projects up. Do it now! :yamero:
If there was an award for best game dev procrastination, I'd say 'meh, I'll pick it up tomorrow' >_>
Honestly though, I've been staring at the same half-made map for a while now haha! Ahhh, I'm so tired of mapping!
Time to add the support for import/export default RMXP maps. Maybe there will be customized tileset support later. In theory, I can reimplement the entire RMXP inside this RMXP-made game to make more RMXP games. :kaojoy:RMXPFORMATSUPPORT.jpg
Gonna make a story driven game someday in RPG Maker about this diseased character in my head. Will keep you posted, although I was warned by the authorities that posting too much would be considered 'spamming' so I WON'T SPAM. It'll be before I go in anyways. It's gonna be messed up but it won't be explicitly pornographic so don't worry, I'll give all the content warnings. :barf::barf::barf:
If you're a RM plugin developer, and you're reading this...

Thank you. You're awesome. Even if I haven't used your plugin, your work is appreciated.

Forum statistics

Threads
111,266
Messages
1,059,750
Members
144,565
Latest member
Clash1210
Top