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

@The007who Meant to answer you sooner...
Code:
DataManager.check_language
DataManager.set_language
Meant to answer you sooner...
Well, how do I use those?
@The007who check_language will return a string (text) of the default language or whatever was set in Game.ini
Code:
DataManager.check_language #=> "Italian"

set_language does just that, sets the current language.
Code:
DataManager.set_language("English")
@The007who check_language will return a string (text) of the default language or whatever was set in Game.ini
Mmmhm... Is there anyway to use this in a conditional branch? 🙂

P.S. Thank you for the reply
@The007who On the fourth tab of the conditional branch selection, there's an option for script input. From there you have the same options (and much more) as any variable or switch conditional. A couple of examples:
Code:
DataManager.check_language == "English" # Returns true if the current language is set to English
DataManager.check_language != "Italian" # Returns true if the current language is not set to Italian.
@Rinobi Thank you so much! 🙂
Have a good day!
hi, i want to ask something. please take a look at this.
Spoiler: menu
FSzoLI3.png
i've managed to erase the window that display gold, and i've also erased some command like skills and equipment there.
but does anyone knows how to erase the part that i circled with black ?

tl;dr i want to get rid a part of status window, i only want it to show the actor pictures and name.
@RizukiKei Adding this to your script list should do it.
Code:
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a super class of all windows within the game.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Overwrite: Draw Simple Status
  #--------------------------------------------------------------------------
  def draw_actor_simple_status(actor, x, y)
    draw_actor_name(actor, x, y)
    draw_actor_icons(actor, x, y + line_height * 2)
    draw_actor_class(actor, x + 120, y)
  end
end
@RizukiKei Adding this to your script list should do it.
Spoiler: CODE
Code:
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a super class of all windows within the game.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Overwrite: Draw Simple Status
  #--------------------------------------------------------------------------
  def draw_actor_simple_status(actor, x, y)
    draw_actor_name(actor, x, y)
    draw_actor_icons(actor, x, y + line_height * 2)
    draw_actor_class(actor, x + 120, y)
  end
end

wow thanks, thank you very very much. have been looking for this by myself since the start of my project lol
I want to edit Hit rate so it will based Luk and Agi (I rename my Luk to dex).
For my own reason, I want to put it on damage formula bar.
I read how to create custom damage formula and to get extra space for my formula, I use script instead.
For example, in my damage formula I put this :
a.actordmgformula(a,b,base,lv)
I also create
class Game_Battler < Game_BattlerBase
def actordmgformula(a,b,base,lv)
#insert my custom formula
end
end


Everything working fine (the damage calculated is correct).
until I want to alter Hit rate.
I'm new to script so I just copy this from GameBattler and edit it
def item_hit(user, item)
rate = item.success_rate * 0.01 # Get success rate
rate *= (100+self.luk)/(100+target.agi) #under 1.0
return rate

The game error because they cant read Agi.
But agi is attribute successor from Game_BattlerBase.
What should I do ?
@ashm you're getting that error because "target" is undefined. Just use agi for the target battler.

also, you should use user.luk.

(100 + user.luk) / (100 + agi)
@ashm you're getting that error because "target" is undefined. Just use agi for the target battler.

also, you should use user.luk.
(100 + user.luk) / (100 + agi)
Okay, that doesnt throw error.
But I found new trouble.
I can't make the rate like i want to.

Example : User dex is 100, target agi is 100, result 100% hit rate
User dex is 10, Target Agi is 100, Result 55% hit rate.
But in my troop test, the enemy can't hit from 10 of 10 atk.
Is my formula not correct ?

Another question is, about decimal. Correct me if im wrong
but I think they can't read decimal for certain place (mainly battlerbase ?)
My evidence example is the previous.
With 10 dex and 100 Agi, the game decide to round it down (so it became (100+10) / (100+100) => 0% ?
Another evidence is my damage formula keep rounding down because i used defense value using %.
I can make it work by multiple it by 100 and then divide it with 100 on later though.
@ashm Decimals are called float values and whole numbers are integers. If you wish to convert an integer to a float, you can use: .to_f

(100 + user.luk) / (100 + agi).to_f

That should fix it.

.to_i converts to integer. It's best to call .round before doing so for more accurate results.
Nice. But how to and when to put . Round?
Actually, you either use round or to_i, never both, it would be redundant code.
round already converts the number to integer unless you use a specific decimal amount for rounding using the arguments of the mentioned method.

But to be on point, there is absolutely no reason to do any of them in your case.
That method (hit_rate) needs a float value, where 0.0 means 0% and 1.0 means 100%.
If you did what Rinobi wrote (using to_f on one of the values), your formula should work exactly how you wanted it to work.

For future reference, in coding:
Doing something with 2 integers will always return integer values. So, 1 / 2 is NOT equal 0.5 in this case, it will be 0 instead.
Doing something with 2 floats will always return float values. So, 1.0 / 2.0 will be 0.5 here, as expected normally in math.
Doing something with 1 integer and 1 float will always return float values. So, both 1.0 / 2 or 1 / 2.0 will get you 0.5 in the end.
So, even if only one number in the whole calculation is a float value, the final value of the method will be a float value as well, unless you explicitly convert it with the appropriate methods (with round or to_i).

Spoiler
Not directly related, but it might be good to know...
Be aware that rounding errors may happen with float values.
This is mostly an issue when you want to display these numbers somewhere and not in the actual calculations, so you can safely ignore them.
For example, sometimes when you expect 1.0 as the final value, you might end up with 0.999999999999 or something similar.
Even if you want to display these numbers, if your display method is right (which means not putting silly round calls or even worse, to_i calls all over the place), you won't have a problem with this.
Hi.
I'm trying to make a custom battle engine by using other .exe file.
My problem is how to read info from a .ini file and write to it.
So far i have made this:
Spoiler: Event
system("battle.exe")
Thread.new do
while true do
sleep 1
def find_process
status = `tasklist | find "battle.exe"`
if status.empty?
stop
end
end
end
end
So now, before i launch battle.exe i need to write Some values (Like Current HP,Max HP, Number of items ID001 etc.)
And after its closed it needs to set everything to what current values are in ini file.
My stats.ini format is this:
Spoiler: stats.ini
[]
HP=50
MAXHP=50
MANA=20
MAXMANA=20
XP=0
Item.1=0
#No spaces are here
Also if HP = 0 then show game over screen.
Would anybody help me ? I just want only the things i've written here.
I could adjust the code for the rest of things i need.
I am also very new to this since i got the VX ACE from Humble Bundle.
I would be very grateful, and thank you for your effort.
Been searching everywhere and can't seem to find the answer to this: is there a way to check the region id of the tile next to an event? E.g. the tile behind an event?
Been searching everywhere and can't seem to find the answer to this: is there a way to check the region id of the tile next to an event? E.g. the tile behind an event?
I want to say yes? Depends on the context, I'd imagine. If the player is interacting with the event in question, we could store the players location into two variables, check which way they're facing, and then adjust the proper axis by 2 (one for the event, one for the actual location), then use "get location info" feeding the altered variables in.

Or just store the events location and then adjust the axis by the proper amount (or check all 4 sides if you're feelin spritzy)
Ahh, I couldn't for the life of me find the 'get location info' option! Thanks heaps. I was trying to do it all with script calls and kept getting heaps of errors.

If anyone else is interested, this is what I did (to find the Region ID of the tile behind an event, based on which way the player is interacting with said event):
Control Variables: [VAR1] = the event's X coordinate
Control Variables: [VAR2] = the event's Y coordinate
Script call:
Code:
if $game_player.direction == 2 #down
$game_variables[VAR2] += 1
elsif $game_player.direction == 4 #left
$game_variables[VAR1] -= 1
elsif $game_player.direction == 6 #right
$game_variables[VAR1] += 1
else #up
$game_variables[VAR2] -= 1
end
Get location info: [VAR3] Region ID [VAR1], [VAR2]
And then a conditional branch using the Region ID stored in [VAR3].
Hello, I've been working on a farming system and decided to try something new; using arrays for variables that control crops' growth etc, with each part of the array being dedicated to a certain crop. I did this:
Spoiler: Image
scripterror1.PNG

scripterror2.PNG

My intention was for the NPC to tell me how many entries are in the array (I wanted to check if there were 80 because that's how many I want), but when I talk to it, it just faces me without saying anything and then turns away. So, I'm wondering, what did I do wrong? I've been watching scripting tutorials but I don't really know what I'm doing haha...

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