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

Yes it does matter; incompatibility is exactly what you want to be avoiding. You have no idea if another script someone would use would want to be saving something in this sense.

If you're able to alias a method instead of overwriting it, that's always the alternative you should be taking 🙂
yea thats exactly what i thought, i was only really wondering if one method was doing more for me than another, i dont think that any of them is though
Nice the way my questions were skipped.
then ask them again 🙂 It's not as if anyone's deliberately ignoring you - just that people answer what they know, and it doesn't take long for posts to get lost.

The stack level too deep is probably because of the number of times a single method is aliased. Do you REALLY need to use all of those scripts in a single project?

I think that script letting you use regions as an additional layer was on the VXAce forum. I know it came out before the English version was released (even before the English trial), prior to this forum being set up.
i do know that not all of yanflys scripts are compatable. the stack error i think is caused by a re-used alias name. there is also some minor conflicts beween other yanfly scripts, subclass and script im sure was one of them but its been a long while and i cannot remember what it was it was incompatable with. and it was only something minor like a visual thing on a menu or something.

i realise this isnt much help really, but hopefully this will give some insight about why you have the error
Hey there!

I have a small issue with the Yanfly battle script, whenever I use buffs or states; say if I was raising defense, it pops up saying Defense but theres a little square and { next to it.

I wonder if this is a quick fix for something I've likely done?

I think the thing that controls it is on lines 313 and 314, but I don't want to change anything lest I completely destroy something.

If someone could help me I'd really appreciate it!

And an explanation so I can slowly learn to understand scripts would be uber appreciated!
i was just wondering if anyone has done any "anti-hack" type methods or if anyone has even thought about how to implement any kind of anti hack method.

i was also wondering if rpgvx ace can play .midi files ? if it can how would i access the synthesizer and would i be able to plug in my own synthesizer ( i have the knowladge of how to make vsti's ect)? if it cannot how easy would it be to impliment ?
What kind of hacks are you thinking of? I don't know anything about hacks but I imagine they are typically low-level stuff and deal with things like memory-editing (like using cheat engine, attaching debuggers to the process, disassembling the exe, ... )
i was mostly thinking of low level "begginer" hacks like cheat engine, modifying things like values, level, exp, money. things of that nature.

i mean obviously if someone is experienced enough and determined to hack it they will, regardless of the protection implemented.
i was mostly thinking of low level "begginer" hacks like cheat engine, modifying things like values, level, exp, money. things of that nature.

i mean obviously if someone is experienced enough and determined to hack it they will, regardless of the protection implemented.
You meant like "Hex Editor"?
ive never really used Hex Editor before, but from what i know about it it would be similar yes.
I think you should open a separate thread to discuss ways to protect your data (save files, or game data) from being tampered.
anyways, I wanna ask if any among you tried Ruby with Gosu yet? There was a pure Ruby structure and codes for RPG Template, means its not the RGSS of RPG Maker, its purely Ruby using the Gosu Library. Happy to see its like RPG Maker XP even.
I'm attempting to make a few small edits to the basic Window_Base script. Right now it looks like this:

Spoiler
Code:
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x      : window x-coordinate
  #     y      : window y-coordinate
  #     width  : window width
  #     height : window height
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super()
    @windowskin_name = $game_system.windowskin_name
    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.z = 100
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    # Dispose if window contents bit map is set
    if self.contents != nil
      self.contents.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # * Get Text Color
  #     n : text color number (0-7)
  #--------------------------------------------------------------------------
  def text_color(n)
    case n
    when 0
      return Color.new(255, 255, 255, 255)
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    else
      normal_color
    end
  end
  #--------------------------------------------------------------------------
  # * Get Normal Text Color
  #--------------------------------------------------------------------------
  def normal_color
    return Color.new(255, 255, 255, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Disabled Text Color
  #--------------------------------------------------------------------------
  def disabled_color
    return Color.new(255, 255, 255, 128)
  end
  #--------------------------------------------------------------------------
  # * Get System Text Color
  #--------------------------------------------------------------------------
  def system_color
    return Color.new(192, 224, 255, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Crisis Text Color
  #--------------------------------------------------------------------------
  def crisis_color
    return Color.new(255, 255, 64, 255)
  end
  #--------------------------------------------------------------------------
  # * Get Knockout Text Color
  #--------------------------------------------------------------------------
  def knockout_color
    return Color.new(255, 64, 0)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # Reset if windowskin was changed
    if $game_system.windowskin_name != @windowskin_name
      @windowskin_name = $game_system.windowskin_name
      self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Draw Name
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 200, 32, actor.name)
  end
  #--------------------------------------------------------------------------
  # * Draw Class
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_class(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y + 32, 236, 32, actor.class_name)
  end
  #--------------------------------------------------------------------------
  # * Draw Level
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_level(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 46, 32, "Level")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 40, y, 34, 32, actor.level.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Make State Text String for Drawing
  #     actor       : actor
  #     width       : draw spot width
  #     need_normal : Whether or not [normal] is needed (true / false)
  #--------------------------------------------------------------------------
  def make_battler_state_text(battler, width, need_normal)
    # Get width of brackets
    brackets_width = self.contents.text_size("[]").width
    # Make text string for state names
    text = ""
    for i in battler.states
      if $data_states[i].rating >= 1
        if text == ""
          text = $data_states[i].name
        else
          new_text = text + "/" + $data_states[i].name
          text_width = self.contents.text_size(new_text).width
          if text_width > width - brackets_width
            break
          end
          text = new_text
        end
      end
    end
    # If text string for state names is empty, make it [normal]
    if text == ""
      if need_normal
        text = "[Normal]"
      end
    else
      # Attach brackets
      text = "[" + text + "]"
    end
    # Return completed text string
    return text
  end
  #--------------------------------------------------------------------------
  # * Draw State
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_state(actor, x, y, width = 120)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    self.contents.draw_text(x - 90, y + 32, width, 32, text)
  end
  #--------------------------------------------------------------------------
  # * Draw EXP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  #def draw_actor_exp(actor, x, y)
  #  self.contents.font.color = system_color
  #  self.contents.draw_text(x, y, 24, 32, "EXP")
  #  self.contents.font.color = normal_color
 #   self.contents.draw_text(x + 24, y, 84, 32, actor.exp_s, 2)
  #  self.contents.draw_text(x + 108, y, 12, 32, "/", 1)
  #  self.contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)
  #end
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Draw "HP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    # Draw HP
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    # Draw MaxHP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Draw "SP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # Draw SP
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Parameter
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 4
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 5
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Item Name
  #     item : item
  #     x    : draw spot x-coordinate
  #     y    : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y)
    if item == nil
      return
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name)
  end
end
In my game there are only 2 types of status effects that remain on characters out of battle: (1) Positive Statuses found on armor and (2) different types of poison.

I want to change the color of the status text to yellow for positive effects and green for poison.

I tried adding:

def poison_color

return Color.new (etc etc)

end

But I got an error so I'm obviously missing a few steps.

If someone could post the correct code assuming Poison is on State 002 (or show me where to edit), I can probably figure the rest out from there.

Thanks.

edit:

Also, I'm trying to move the position of the Status (and other things) around the screen. What is determining the original x and y for each thing?

This this fore example:



Code:
  def draw_actor_class(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 236, 32, actor.class_name)
  end
It's simply just x and y for the coordinates, but something else is telling it to begin to the right of the actor name.

This is important because when I try to shift the x and y's for the status down and to the left, the status then disappears from the battle screen. I can get it to the right place in the menu screen, but not in both the menu and battle without figuring out the origin.
@ Chad Sexington, you would have to modify each window individually if you wanted it to look perfect ( at least thats what i would do ) e.g modify Window_BattleStatus.

I was just wondering how efficient this code is



Code:
#==============================================================================
class Scene_Title < Scene_Base
#==============================================================================

  alias :cng_ALIAS :command_new_game
  def command_new_game
    trigger_thing
  end

  def trigger_thing
    # method code goes here
    push_new_game # when new code is done
  end

  def push_new_game
    cng_ALIAS # old command_new_game
  end

end
it obviously aliases new game , runs another method instead of new game then finnally calls the aliased new game method from a third method.

my question really is, is it efficient to alias a method and then use the "old method" in a completely different method ? ( different from the origional method )
Trying to use regexp to pick up a number or * from a string:

\e[1] => 1

\e[20] => 20

\e[*]=> *

It works okay for a single character, but anything with 2 characters it does not pick up. Can someone tell me what is the correct exp<b></b>ression?



Code:
(/\\e\[([\d+\*])\]/i)
mmm ... never mind. This works:



Code:
(/\\e\[(.*)\]/i)
though I would have preferred something that would only accept digits and * - this will do the job.
I am currently using Yanfly's Party System that lets you change members during battle, and MogHunter's Advanced Battle Hud.

The problem is, when I switch the characters in my party during battle, their faces on the hud won't change. Even when I remove them, the hud is still there. The characters do get switched out, but their huds won't update.

Is there anyway I could fix this ?

http://www.atelier-rgss.com/RGSS/Battle/ACE_BAT03.html

http://yanflychannel.wordpress.com/rmvxa/core-scripts/party-system/

http://yanflychannel.wordpress.com/rmvxa/core-scripts/party-system/command-party/
Hey all, just wondering how I'd write this in a damage formula - attacker.atk² ? Am I just over thinking it and it's as easy as a.atk^2?
There's a Math.sqrt(x) to do the opposite, but I don't see one for squaring a number.

I'd just go with a.atk * a.atk
Thank you.

Quick question, how do I use a random number in a battle formula? I know it begins with 'rand' but after that I'm a little lost. I'm going for -

a.hp / rand(1~10)
a.hp / (rand(10) + 1)


rand(x) will give you a number between 0 and x-1. So if you want 1-10, you'll have to do rand(10) which will give you 0-9 then add 1 to it.

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