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

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
678
First Language
Polish
Primarily Uses
Other
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.



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

Fixed.
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
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
 
Last edited by a moderator:

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
678
First Language
Polish
Primarily Uses
Other
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 ""?
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
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"
 
Last edited by a moderator:

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
678
First Language
Polish
Primarily Uses
Other
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.
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
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 
 
Last edited by a moderator:

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
678
First Language
Polish
Primarily Uses
Other
Oh right, it was float, I forgot.

Hmm.. okay, now everything is clear, thank you.
 

Cristiander

Veteran
Veteran
Joined
Aug 13, 2015
Messages
41
Reaction score
1
First Language
Romanian
Primarily Uses
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 ...
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
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
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,310
Reaction score
11,910
First Language
English
Primarily Uses
RMMV
Please start a new thread for this question.
 

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
678
First Language
Polish
Primarily Uses
Other
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.



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.
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,136
Reaction score
805
First Language
Hungarian
Primarily Uses
RMVXA
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).
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
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.
 

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
678
First Language
Polish
Primarily Uses
Other
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.
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,136
Reaction score
805
First Language
Hungarian
Primarily Uses
RMVXA
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.
 
Last edited by a moderator:

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,442
Reaction score
678
First Language
Polish
Primarily Uses
Other
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
 
Last edited by a moderator:

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
570
Reaction score
156
First Language
Serbian
Primarily Uses
N/A
Well, it CAN change the performance if stuff is constantly being drawn.

The thing with the picture menu would look like this :

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)
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,136
Reaction score
805
First Language
Hungarian
Primarily Uses
RMVXA
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.
 

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

Latest Threads

Latest Profile Posts

Quon is watching you
Quon blessed your good efforts
I have tried, several times to understand how Markiplier is popular. You can't deny his popularity. I can only get through a few minutes of his vids, though. He's cringier than ANY cringe comp I've ever watched. When I was a kid, if you acted like that, 0 friends and 100% no dates for you. Times have changed XD
Sometimes you may feel helpless and defeated. But everyone loses from time to time. It's okay to be tired. Take a breather. Have a good cry if you need to. You gotta take breaks from your workout, or you'll collapse before you can get stronger.
So, my roommates wrote a news article in English, translated it into Bengali with google translate and now I'm helping them fix the monstrosity which was the result. Making English the medium of education is fine... but not to an extent that we forget how to write properly in our own language :")
Stream will be live shortly with some more Minecraft spriting! Feel free to drop by~

Forum statistics

Threads
93,544
Messages
913,351
Members
123,073
Latest member
stunner345
Top