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

Chucksaints

Veteran
Veteran
Joined
Dec 8, 2016
Messages
34
Reaction score
1
First Language
Portuguese
Primarily Uses
RMVXA
You have two options. Use either of
.contents_opacity = 128
OR
.contents.font.color.alpha = 128


Complicated. First, you have to erase the arrow from the windowskin image asset, then add your own sprite to the window.
As for the first one, is done, Thank you ^^

For the sprite, how can I check if there is scrollable content up/down & hide sprite if it hasn't?
 

Ebanyle

açspasl~d~dfflass
Veteran
Joined
Sep 2, 2016
Messages
338
Reaction score
200
First Language
Portuguese
Primarily Uses
RMVXA
How do I check values that can all fit into a condition?
For example, I'm trying to make X action in an event if the player is facing down or right direction.
Instead of checking it like this:

Code:
if $game_player.direction == 2
   do X thing
end
if $game_player.direction == 6
   do X thing
end
Is there a way I can check for both in the same condition? Like this:
Code:
if $game_player.direction == 2 [or] 6
   do X thing
else
   do Y thing
end
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
287
Reaction score
70
First Language
English
Primarily Uses
RMXP
That should make it possible for you to check if the direction will ever trigger it.
 

D.L. Yomegami

Sanely Insane
Veteran
Joined
Jan 22, 2017
Messages
182
Reaction score
234
First Language
English
Primarily Uses
RMMZ
Does Ruby have an equivalent to the JS clamp function?

That is, can I write something like value.clamp(min, max) to ensure the value stays between the minimum number and the maximum number, or do I have to use something like ((value, 10).max, 9999).min?
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
250
Reaction score
91
First Language
English
Primarily Uses
RMXP
Quick google check says not until Ruby version 2.4.0

What you alternatively put is equivalent. Make the clamp method yourself if you want.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,497
First Language
Indonesian
Primarily Uses
RMVXA
Untested, but something like this might work.
Ruby:
class Numeric
  def clamp(min, max)
    return [[self,min].max,max].min
  end
end
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
287
Reaction score
70
First Language
English
Primarily Uses
RMXP
You seem to ignore that an Array's min and max methods let you include more than just two values for Arrays have no specific size limit. (OK, Ruby arrays aren't as huge as C's or C++'s vectors...)
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
250
Reaction score
91
First Language
English
Primarily Uses
RMXP
You seem to ignore that an Array's min and max methods let you include more than just two values for Arrays have no specific size limit. (OK, Ruby arrays aren't as huge as C's or C++'s vectors...)
Why would you need to use more than two values for a min or max? This comment contributed nothing of value to the question at hand.

Alternatively
Ruby:
class Numeric
  def clamp(min, max)
    [min, self, max].sort[1]
  end
end
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
287
Reaction score
70
First Language
English
Primarily Uses
RMXP
You want a quick solution? Here's one!

Code:
class Numeric
  def clamp(mn, mx)
    return mn if self < mn
    return mx if self > mx
    self
  end
end
This one avoids making a value search by index that's unnecessary.
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
Anyway to use line breaks with bitmap.draw_text commands?
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
Window_ChoiceList - For animation purposes, how would I be able to dispose of the choice window while not having to rely on close commands?

Code:
  def call_ok_handler
    $game_message.choice_proc.call(index)
    close #to remove?
  end

  def call_cancel_handler
    $game_message.choice_proc.call($game_message.choice_cancel_type - 1)
    close #to remove?
  end
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,497
First Language
Indonesian
Primarily Uses
RMVXA
how would I be able to dispose of the choice window while not having to rely on close commands?
You don't technically dispose the window, but you can have a similar effect if you don't want to use close command. Just use
Code:
self.openness = 0
 

RaluShow

tsukuru_caynu
Member
Joined
May 20, 2017
Messages
18
Reaction score
0
First Language
English
Primarily Uses
RMVXA
How does one set up a way to allow RGSS3 to read from a .txt file and set a variable from what the text file says?


Just numbers will work perfect.

Edit: I am aware of the External Text script. But is there a simple script call I can use to do a task like I am doing?
 
Last edited:

BCj

Veteran
Veteran
Joined
Jun 19, 2014
Messages
1,731
Reaction score
928
First Language
Dutch
Primarily Uses
N/A


How would I go about drawing a parameter bar here, for the status menu?
e.g.


 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,497
First Language
Indonesian
Primarily Uses
RMVXA
Generally, you just need to call draw_gauge, however, that does depends on the rate.
What does the stat rate depend on? If HP, it makes sense since the max gauge is when the current hp is equal to max hp, but stats?
 

CaRa_CrAzY

Undefined Custom Title
Veteran
Joined
Jan 19, 2019
Messages
63
Reaction score
27
First Language
Portuguese
Primarily Uses
Other
How does one set up a way to allow RGSS3 to read from a .txt file and set a variable from what the text file says?


Just numbers will work perfect.

Edit: I am aware of the External Text script. But is there a simple script call I can use to do a task like I am doing?
I am not sure if this will work with RGSS3, but in pure ruby this will do the trick:
Ruby:
File.readlines(file_path)
Just iterate over it using each, map or similar method.
 

BCj

Veteran
Veteran
Joined
Jun 19, 2014
Messages
1,731
Reaction score
928
First Language
Dutch
Primarily Uses
N/A
Generally, you just need to call draw_gauge, however, that does depends on the rate.
What does the stat rate depend on? If HP, it makes sense since the max gauge is when the current hp is equal to max hp, but stats?
would max stats if lvl 99 count as rate?

say stat attack at level 10 = 10, and at lvl 99 = 100

then at lvl 10 the bar should be at 10% of the 100%
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,497
First Language
Indonesian
Primarily Uses
RMVXA
would max stats if lvl 99 count as rate?

say stat attack at level 10 = 10, and at lvl 99 = 100

then at lvl 10 the bar should be at 10% of the 100%
Honest opinion, drawing gauge bar in stat display does not convey anything. And by that logic it will really be a small fraction of the bar. And not to mention, if you use equip, it may exceed 100. And the bar will be maxed.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 3)

Latest Threads

Latest Profile Posts

Crazy idea: lawnmower/weed whackers as a weapon type.

Specifically the ones that are spinning axes on sticks.
The only part of the advent calendar that is missing is the content for christmas. And I am clueless af xD
Based on music resources around the internet, what is the musical theme or style that's hard to find? Is it sci-fi, slice of life, urban, platformer, or anything else? :D
Good morning. Please introduce caffeine in the proper slot. Not sufficient caffeine, add more. Add more. Continue until you hear a sound signal. Please continue. Insufficient caffeine. Increase the quantity of SRW music. Add caffeine.
I have to fix a little more.
Or maybe a lot. Yeah, I need to make the characters look a little bit more fit in some poses.

Forum statistics

Threads
103,396
Messages
999,030
Members
134,923
Latest member
yawarsiddiqui
Top