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

I'm trying to work MAT and MDF into the success rate of inflicting states on enemies. I'm wondering if I have this logic right, particularly in referencing the target's MAT stat. (I just looked at how luk_effect_rate does it.)

(Yes, it's meant to be the user's MDF against the target's MAT. Because repurposed stats.)

Code:
  #--------------------------------------------------------------------------  # * [Add State] Effect: Normal  #--------------------------------------------------------------------------  def item_effect_add_state_normal(user, item, effect)    chance = effect.value1    chance *= state_rate(effect.data_id) if opposite?(user)    chance = [chance * (1.00 + (user.mdf - mat / (user.mdf + mat)), chance * 1.5].min if opposite?(user) && user.mdf > mat    chance = [chance * (1.00 + (user.mdf - mat / (user.mdf + mat)), chance * 0.5].max if opposite?(user) && user.mdf < mat    if rand < chance      add_state(effect.data_id)      @result.success = true    end  end
when setting a handler for a command, is there a way to pass to the method an argument?  (specifically the :ext of the command, which I know is just window_of_the_command.current_data[:ext])
You could always just extract it from the command window data itself... Look at how the main menu does it, it uses same handler for some of the commands..

If you really need to pass an arg to the handler, you need to edit the way handlers are called.. You could always overwrite the method that calls the handlers anyway
Hello,

Is there a way to hide a Skill type in combat?

I have a Skill type called Passives and I don't want them to be present during combat.
Solved.

For those who are facing this problem, here's a link: http://www.rpgmakervxace.net/topic/30178-hide-skill-types-from-battle/
Is there a way to get the entire player/enemy party's HP total, like "$game_troop.agi"/"$game_party.agi" does for Agility? Replacing "agi" with "hp" just results in a crash.
That 'agi' method gets the average agi of the party/troop.


Do you need the average HP of the party/troop or the total HP of the members only?


This is how to get the total current HP of the entire party/troop:


class Game_Unit

def hp
return 0 if members.size == 0
return members.inject(0) {|r, member| r += member.hp }
end

end


If you want the average HP, just divide the value with 'members.size'.


You can call this method on the party and troop alike, just like with the 'agi' method, so '$game_party.hp' and '$game_troop.hp'.
If I wanted to setup a defense model that just removed a % of the damage based on its value, either by being set to a % amount or having relative values (1 -10%, 5 - 50% etc) would I need to have a script to do so?
If you simply want to reduce the damage taken with a fixed %, you can use the "Physical/Magic Damage Rate" S-param. Those do exactly that. The lower these params are, the lower % of the damage will be taken from attacks, and the higher they get, the more damage will be taken.


These stats start on 100%, which means that the full damage is taken when attacked. 


If an actor gets this stat to 80%, that means that the player will get 20% less damage (so, it is 80% of the total damage).


If an actor gets this stat to 200%, the damage taken will be doubled.


Just take note that these are multipliers and any feature adding these stats will stack on top of the others.


So, an armor with 80% PDR feature combined with a state which got a 60% PDR feature will yield you: 80% * 60% = 0.8 * 0.6 = 0.48, which is 48%, so the total PDR will be 48%.


If you add a helmet which got a 50% PDR feature, this will be reduced even further (to 24%).


If this is not what you meant, than yes, you will most probably need a script for it.
@Sixth you're a star, thanks friend!
RMXP question here, though I guess it could apply to any RM.


You know when you open the menu, you can see a bit of the map in the background, like so?

Spoiler
Spoiler





fKC9yVJ.png





How would I change that to show an image from the Pictures folder instead? I really wanna add fancy borders there but I know nothing about scripting.


EDIT: Nevermind, got it solved by the great bufkusking @Ralph_Cielrus.
What's the protocol for getting commercial script support? SOURCE seems to have leaped off the edge of a cliff, and Effectus, one of his paid scripts, is broken. I have an issue, but I think I know what's causing it, but at the same time, I don't wanna step on any toes.
Silly question! ^^


~ How to remove a mark from a certain position in a string? ~


To add a mark to the string, I have this:


@string.insert(@cursor_position, @sym)
# where @string is for example @string = "A random string!!";
# @cursor_position is the position of the cursor;
# @sym is the pressed key



~ but now how to remove them in a similar way?


I know how to remove first/last mark, but can't figure out how to make it based on the cursor's position.


Of course there is a way to achieve this with using some logic here and there, but I wanted to ask if there is a simple function for that first.


I've tried to use delete_at, but it seems that it's not intended for use in strings.


Thank you!
By "mark" you mean a character from the string at a specific position?


Each character in the string got an index, much like the element in an array.


So, you can do:


string = "This is a string, yay!"
p string # => "This is a string, yay!"
string[11] = "(t)"
p string # => "This is a s(t)ring, yay!"


In the example above, the 11th character, which is "t" got replaced by "(t)".


So, just use the index of the character.


Note that the string will change permanently for that instance object (if the string is stored in an instance variable). 


If you want to keep the original string, clone it and store it somewhere else or do the change on the cloned string.


I don't know how did you tie your cursor's position to the characters in the string, but I guess you already did that somehow, seeing that you tried to do this with the 'delete_at' method.
@Sixth That works, thank you! =3


And yeah, I meant character, sorries.


-------[ *quote because there is no such a thing in this editor* ]---------------------


<Rikifive:>


Of course there is a way to achieve this with using some logic here and there


---------------------------------------------------------------------------------------------------


As I said, I've came up with some solution that I was using temporarily (because I knew there has to be a simple way, that I've overlooked):


if @cursor_position > 0
a = @string[0, @cursor_position - 1]
b = @string[@cursor_position, @string.size - 1]
@string = a + b
@cursor_position -= 1
else
a = @string[1, @string.size - 1]
@string = a
end


And it's working perfectly, but the one you've suggested looks neater.


if @cursor_position > 0
@string[@cursor_position - 1] = ""
@cursor_position -= 1
else
@string[@cursor_position] = ""
end




Silly me, thank you! ^^


I needed that for that:


lkOXqcc.gif
class MyWindow < Window_Base
  def initialize
    super(0,0,150,50)
    refresh
  end
  
  
  
  
  def refresh
  pls_work=$game_variables[1]
    draw_text(x,y,200,line_height,"Health: #{pls_work}")
  end
  end
class MyWindow < Window_Base
  def initialize
    super(0,0,150,50)
    refresh
  end
  
  
  
  
  def refresh
  pls_work=$game_variables[1]
    draw_text(x,y,200,line_height,"Health: #{pls_work}")
  end
  end

Hey noob question, but I don't not really know  how to make text boxes i make with this script go away. 
I assume you make them like this:


@custom_win = MyWindow.new


So, you can make them go away with the dispose method.


@custom_win.dispose


Note that this will permanently get rid of that instance object!


If you simply want to hide/show your window, you can use:


@custom_win.hide # For hiding the window.

@custom_win.show # For showing the window.


The hide method will just hide the window without getting rid of it for real.
So, you can make them go away with the dispose method.


The hide method will just hide the window without getting rid of it for real.

I keep on getting an this error when I use one of these methods

Script 'Game_interpreter' line 1411: noMethodError occurred.

undefined method 'the method' for nil:NilClass
I have no idea is "the method" in your code, so I can't help without seeing your code + eventing.


Just to note this here:


You should never make any window/sprite objects with script calls without storing them in an instance/global variable, or else you will not be able to dispose them!
I have no idea is "the method" in your code, so I can't help without seeing your code + eventing.


Just to note this here:


You should never make any window/sprite objects with script calls without storing them in an instance/global variable, or else you will not be able to dispose them!

Sorry I meant the methods you suggested. dispose and hide.
I still can't help without seeing your script call and eventing. 


Show me a screenshot of the event page where you do the script call for these windows.

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