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

Hmm...I see how it works.

But actually I think when's will be better, because I used that in this:

@menu_bg_image3=Plane.new case $game_variables[1] when 0..7 @menu_bg_image3.bitmap=Cache.picture("Command Backs_7") # Command Backs when 8 @menu_bg_image3.bitmap=Cache.picture("Command Backs_8") # Command Backs when 9 @menu_bg_image3.bitmap=Cache.picture("Command Backs_9") # Command Backs (...) else @menu_bg_image3.bitmap=Cache.picture("Command Backs_13") # Command Backs end # case @menu_bg_image3.opacity=255 Unless it'd be better here too.

Anyway, thanks for clarifying that, I'll note that down.

WtvmtpT.png


I see, I see - I know it can be shrunken. I'll fix that.

Fixed.
a = $game_variables[x]@menu_bg_image3=Plane.new@menu_bg_image3.bitmap = Cache.picture("Command Backs_" + (a <= 7 ? 7 : a == 8 ? 8 : a == 9 ? 9 : 13).to_s)@menu_bg_image3.opacity=255I think this will also work 🙂

EDIT : Did not see the (...) part.

Code:
a = $game_variables[x]@menu_bg_image3=Plane.new@menu_bg_image3.bitmap = Cache.picture("Command Backs_" + (a <= 7 ? 7 : a > 7 && a < 13 ? a : 13).to_s)@menu_bg_image3.opacity=255
Oh, I see what you did there!

I didn't think about that!

Now I understand how it works, It'll be useful, thanks!

Hmm... another question - how does .to_s exactly work? It turns output to string ~ puts that in ""?
Well...

The part in the brackets calculates the number.

But, because I used "Command Backs_" + that number, that would throw an error because you can't add Integer to a String.

So I used .to_s to turn the integer to a string.

That means

1.to_s # => "1"12313.to_s # => "12313""A".to_s # => "A" (does nothing)
There are also other .to_ methods

Code:
1.to_sym # => :1"123".to_i # => 123:a.to_s # => "a"
So yeah, as I thought, thanks for clarifying!

Speaking of .to_ methods

I *hopefully xD * know that:

13.463.to_i # => 13 right?but how to make an integer to fraction (? IDK how is this in English =P)

for example

14.747.to_f(2) # => 14.75 or something like this? xDI'm asking, because it'll be useful in future, thank you for your time.
It is FLOAT, not FRACTION ( and I don't know why I wrote these with BIG letters, but, whatever)

I don't know why the number with the decimal point is called float (programmers have weird names for things, like float and string)

No, to_ methods don't have arguments

If you want to round 14.13213135452353 to 2 numbers do

14.13213135452353.round(2) # => 14.13You can look in the help file for the class Numeric 
Oh right, it was float, I forgot.

Hmm.. okay, now everything is clear, thank you.
I don't know why the number with the decimal point is called float
Because float is short for floating point number (in case of RGSS and also usually, it's binary and not decimal). Who doesn't like abbreviations? We're not writing RPG Maker VX Ace all the time either, do we?
I think this will solve it :

class << DataManager  alias :some_random_alias_init  :init  def self.init    some_random_alias_init    $game_variables[1] = 0  endendOr change 1 to any other iD you want

Place this below Materials
Thanks a lot, it works, the variables are set when the game starts ... but I discovered another problem

I'm not sure if this counts as a question about scripting, but the reason I need those variables set when the game starts is because I'm using them for my portrets(they represent the drawing positions for the show_picture command). With this script the variables are changed(I press F9 and I can see they are changed) but the pictures are not drawn on the right positions.

I really don't know what to do about this ...
So, you are drawing portraits at specified positions with the Show Picture?

Can you show us your Show Picture command?

And, yeah, you might want to change that 0 in the code provided to something you want
Please start a new thread for this question.
Please start a new thread for this question.
Ok. Here it is http://forums.rpgmakerweb.com/index.php?/topic/43839-setting-a-variable-when-the-game-starts/

It's ok if I link the thread on here, right? Please tell me it is
OK, I have a stupid question - just curious ~

Question: How stupid it would be to create a window with size of the whole screen and then draw text and stuff wherever I want using X/Y etc.? Would that decrease performance? Would that be 'bad scripting'? Is there any difference ~ should I organize windows?

Example: Well, I was thinking about making a giant window in Menu Scene, where I'd put stuff manually - something like this:

self.contents.font.color = Color.new(255,0,0) # Red text? I can't believe this!self.contents.draw_text(100, 200, 200, 24, "HOLY BALLS!", 0) # one texty-textdraw_icon(5, 200, 50) # some random icon self.contents.font.color = Color.new(0,255,0) # so colorful ... =Oself.contents.draw_text(150, 300, 200, 24, "WHY DO U NEED TO MAKE THAT WINDOW SO GIGANTIC?!", 0) # another text? WOAH! draw_image(300, 400, "Graphics/Menu_UI/Status_Minimized_Twilight_Sparkle.png") # A totally misplaced image? Awesome!What I'm trying to achieve:  Just instead of creating multiple windows and setting their position/size etc. just create one transparent window and manually put stuff in.

WtvmtpT.png


Or what is better?

> Creating multiple windows for some stuff there and there

> Making one fullscreen window and put stuff in here

And I assume I should make different windows for 'refreshed' content like "PlayTime" and the rest 'fixed' stuff, right?

Thank you in advance.
Generally, the bigger the window, the bigger the performance cost.


You can set your windows' opacity to 0 to save a huge amount of FPS, and use a simple sprite for the background if needed.


But don't make million windows for a scene, because after around 10 windows (shown or not), the performance will drop, at least on older PCs (I tested this on my old laptop, newer ones might not have any problems, no idea).


You don't have to use a separate window for drawing playtime and stuffs like that. You simply make a separate refresh method for it, and clear only the rect reserved for the playtime display instead of the whole window (using the 'clear_rect' method).
Well, nothing will change the performance, unless you change something big in the update method.

The thing is, you would need to remake Window_Selectable and then apply it to Menu Scene, so you could make the Menu selectable.

If you are going that extreme, you could try to make an image of a menu, and change the selectable part and then draw all that in one window.
Let's leave the selectables, I have everything prepared - I just want to add 'playtime', 'gold', 'location' and 'picture with active members'.

So... for playtime I'd need to refresh every second; for picture refresh when party formation changes (?) and the rest is fixed stuff.

And I'm wondering here if I should create separate windows for:

1st window [playtime]

2nd [location, gold, drawn picture of current location]

3rd [active members on that picture]

~or

create just one window and put all stuff in here.

And... if I'd put that in one window - how to refresh 'one line' to not refreshing the whole window along playtime? ~ how to use 'clear_rect' properly? I'm still confusing the refreshes and stuff.
It WILL change performance. Bigger windows will drop the FPS more than smaller ones, it has been tested countless times. It is especially true on higher resolutions (a 800x600 window will drop performance drastically, even if nothing is happening in it, aka an empty window). But setting their opacity to 0 (making them transparent) helps a LOT.

I don't think he wants to make the window a selectable one, just a simple window with custom info shown in it.

The 'clear_rect' method takes a rect and clears only that part of the window.

Example:

contents.clear_rect(x,y,width,height)*or*contents.clear_rect(rect)Just set the correct rect and that part of the window will be cleared. It's like a targeted 'contents.clear' call.In your refresh method, first use the 'clear_rect' call, and draw the playtime after that.

In your update method, call the refresh method when the seconds change, and you are done.
Hmm... I'll try making 5000x5000 window and see what happens.

@Sixth is right - that's what I want to do - that'd be fun making all the selectables and stuff in one window - I'd die there. =P
Well, it CAN change the performance if stuff is constantly being drawn.

The thing with the picture menu would look like this :

Spoiler
Image dead, sorry 🙁

This screenshot is from some older game, also made in RM, and I am sure somebody will realize what game it is.
The faces are selectable, on the left, when you select one of them, then the items, equipment and spell icons are enabled (the one in the middle)

And also ? and Quit buttons are selectable.

You may consider making something like this, but less complicated. (not the same as this, because it would require major scripting skills)
Well, it CAN change the performance if stuff is constantly being drawn.
Nope, that's my point. Even an empty window without any drawing (literally without anything happening in it) will drop the performance if the window is big and not transparent.

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