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

-okay I'll move it here-

I tested these windows and there are results:

-I tried making a 10000x10000 window -

It took ~3 seconds to open the menu and does not lower performance - it works fine, UNLESS when window is updating - I've put a refresh every second and it was lagging (for ~0.05 second) each second.

-I tried making a 20000x20000 window - it crashes upon entering menu - not crash, due to script etc. - it throws "Stopped Responding" Error.

Oh and changing opacity didn't changed anything. I completely didn't noticed any difference.

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

Okay, I'll try some things. =P
With this code :

Spoiler
class Scene_Test < Scene_Base  def start    super    @window = Window_Test.new  endendclass Window_Test < Window_Base  def initialize    super(0, 0, Graphics.width, Graphics.height)  endend
FPS didn't drop below 55
I really hope you guys did not test this with an i7 CPU uncapped or something similar... It's obvious that you won't notice much difference with a very good CPU.


But 55 FPS is already a lowered one and you did not do anything in it yet. Optimized scenes run on 60 FPS all the time even on older PCs (by optimized, I mean no bad update methods).


Also Graphics.width and height takes the game's resolution. Which resolution did you test it? 544x416 is not really a big window. The FPS drop will raise on higher resolutions much more.


Testing it on absurd numbers is really pointless. I mean, when will you ever use a 10000x10000 window? Keep it real and mind the older PCs, not just your super PC. 😀


A 1024x768 window will get around 30 FPS top on an i3 CPU (1,9 GHz). On my old laptop, it gets only around 10-12 FPS (single core, 1 GHz). These tests are on an opaque window.


If I make the window transparent, the FPS will raise to ~55 on the i3 CPU, and to ~24 on the crappy laptop.


Only the game is running and the browser in the background (as far as user programs go), nothing else. This is tested on Win 7 and Win XP. No idea how the other systems will do.
Haha, but that was fun checking how engine reacts to huge bricks. xD

So... I got a problem with that updating. =P

Let's assume I have something like this:

Spoiler
class Window_CelestiaExtraWindow < Window_Base def initialize(x, y) super(x, y, EXTRA_WINDOW_WIDTH, EXTRA_WINDOW_HEIGHT) @playtime = 0 refresh end def refresh self.contents.clear #-< ҉ >---< Draw Content >---------------------------------------------------- self.contents.draw_text(100, 200, 200, 24, "TEXT", 0) #one playtime, that updates. self.contents.draw_text(150, 300, 200, 24, "PTy:" + " #{$game_system.playtime_s}", 0) #second playtime, that's not updated. (for testing purposes) self.contents.draw_text(150, 324, 200, 24, "PTn:" + " #{$game_system.playtime_s}", 0) #-< ҉ >---< Refresh PlayTime >---------------------------------------------- @playtime = $game_system.playtime end # Refresh #-< ҉ >---< Update PlayTime >----------------------------------------------- def update super refresh if $game_system.playtime - @playtime >= 1 end # update end # class
How should I implement that properly?
@playtime should start like '$game_system.playtime_s' initially, since that will be drawn upon initializing anyway, I assume.

You don't have to refresh the whole window if you only want to redraw the playtime.

def update_playtime(force=false) if @playtime != $game_system.playtime_s || force @playtime = $game_system.playtime_s rect = Rect.new(x,y,width,height) # The rect reserved for the playtime drawing. contents.clear_rect(rect) # This will clear the previous playtime. draw_text(rect,$game_system.playtime_s) # This draws the updated playtime. end endCall this method in the 'update' method in your window without any arguments.I always add one argument for automatic refresh methods in case I need to trigger it manually (like upon initialization, which you should do right now, so I kept it like that). In your window's initialization method, call it with one argument set as 'true', so it will draw the correct playtime immediately upon opening the window.

Replace the x, y, width and height with your own values and you are good to go.

Ohh, and take out any other drawings regarding the playtime from the static refresh method.
Um... it may seem stupid, but actually I can't manage it to work... (⇀‸↼‶)

I still don't understand how exactly that works... =P

Maybe I'll just make multiple windows for that...

Sorry for being so noobish here. (;一_一)
def update_playtime(force=false)  if @playtime != $game_system.playtime_s || force    @playtime = $game_system.playtime_s    rect = Rect.new(x,y,width,height) # The rect reserved for the playtime drawing.    contents.clear_rect(rect) # This will clear the previous playtime.    draw_text(rect,$game_system.playtime_s) # This draws the updated playtime.  endendVery good code, indeed. I never considered doing something like this.

So, if you want an explaination, here it is.

When you have a Window, you need to draw stuff in it.

When you draw stuff in a Window, that stuff stays in a window.

But, if your playtime is updating, the previous stuff (previous playtime) will stay drawn.

That is the main reason why to make a method to update playtime.

So, if you have a window with a map name, current playtime and some static text (like "Hello"), the bad method is to update all of them, like

def update super contents.clear  draw_text_ex(0, 0, "Hello")  draw_text_ex(0, 24, $game_map.name)  draw_text_ex(0, 48, $game_system.playtime_s)endFirst, do you see contents.clear?

That clears the whole bitmap, that means all stuff disappears from the Window.

And after that , the text is drawn again.

Well, this is bad, because it is updating on every 60th part of a second (and that is fast)

That's why Sixth's method is better.

For example, after initializing the Window, you can call a method called refresh, with the following code :

def refresh  draw_text_ex(0, 0, "Hello")  draw_text_ex(0, 24, $game_map.name)endThe refresh method will execute every time Window is initialized (usually that means once, when you enter the Scene)

But, in the update method add :

def update  super  update_playtimeendThat method will update the playtime every 60th of a second, and that's better than updating all three texts.

It can be optimized even more, but it's a bit stupid to optimize it more, when the increase will be max. 1 FPS

@Sixth, you are right, I tested it on 2.4 GHz Intel Pentium 2020M (laptop), with 544x416 window.

But I said it is minimum of 55, and I saw it only once.

I'll try the test on a higher resolution, and edit this post after I do so.

Correct me if I'm wrong.
I think this question doesn't deserve it's own thread, so...

I tried modern algebra's picture fix and Seer UK's fixed picture to make pictures appear on a map like parallax mapping.

But pictures are never tinted by the Day/Night system I'm using, or any tint at all. Is there any way to set pictures to be tinted automatically like everything else?

I'm doing this because I want to make houses of a realistic size and I don't want to have 40 tilesets, one for each house. Also I can't make castles and towers, mountains, etc.
I think this question doesn't deserve it's own thread, so...

I tried modern algebra's picture fix and Seer UK's fixed picture to make pictures appear on a map like parallax mapping.

But pictures are never tinted by the Day/Night system I'm using, or any tint at all. Is there any way to set pictures to be tinted automatically like everything else?

I'm doing this because I want to make houses of a realistic size and I don't want to have 40 tilesets, one for each house. Also I can't make castles and towers, mountains, etc.
Did you already try to use Tint Pictures?
Did you already try to use Tint Pictures?
That isn't an option for me, I'm using Vlue Advanced Game Time and Khas Lights. The picture of the house will be changing every 30 or 60 seconds, and lights near the picture should tint it too. I need to set pictures to be placed in the same layer everything else is (tilesets, players, events) and not above all that.

EDIT: I can change the Z value of Khas lights to something like 500 and pictures will be tinted, but message boxes, huds, choices, everything will be tinted too. I'll see if I can do something there.

EDIT2: I had to set Khas Lights' Z value to 80 or something around that.
That isn't an option for me, I'm using Vlue Advanced Game Time and Khas Lights. The picture of the house will be changing every 30 or 60 seconds, and lights near the picture should tint it too. I need to set pictures to be placed in the same layer everything else is (tilesets, players, events) and not above all that.
I see, you should change the picture viewport into @viewport1 rather than @viewport2 in Spriteset_Map, but then it will affect all pictures.

You could try to use my parallax script for that http://pastebin.com/raw.php?i=bwX6QEmb
Hi everyone! I've just decided to learn scripting with RPGMXP and things aren't going well right from the beginning... I'm trying to do the classic Hello World script, just creating a window and printing some text on it using this code:

class My_Window < Window_Base def initialize super(70, 100, 400, 20) refresh end def refresh self.contents.clear self.contents.draw_text(120, 0, 100, 100, "Hello World!", 1) endendI'm calling it from an event with @window=My_Window.new, but I always receive a NoMethodError error in line 7 "undefined method 'clear' for nil:NilClass. I've checked it again and again, but I can't find where the error is... (I'm sure it is going to be one of those silly "you are missing a , here" errors)

Thanks for your help!
Thank you for explaining that like for a baby, that's the language I understand here I guess. xD What I'm trying to say, that I'm still learning and I'm confusing some things and explaining them like this helps a lot, now I understand (more or less) how it's supposed to work.

So.. finally I managed it to work, but there is one small problem - when opening a window, the playtime appears when the window is fully shown... It kinda look like - the menu appears, after ~ 0.2sec the playtime is shown, did I do something wrong? I did this:

Spoiler
#-< ҉ >---< Initialize >---------------------------------------------------- class Window_CelestiaExtraWindow < Window_Base def initialize(x, y) super(x, y, EXTRA_WINDOW_WIDTH, EXTRA_WINDOW_HEIGHT)#~ @playtime = 0 # is that needed? refresh end #-< ҉ >---< Draw Content >---------------------------------------------------- def refresh self.contents.draw_text(100, 200, 200, 24, "SOME TEXT", 0) draw_icon(5, 200, 50) # some icon draw_image(300, 400, "Graphics/Some Folder/Some Picture.png") end # Refresh #-< ҉ >---< Draw and Refresh PlayTime >--------------------------------------- def update_playtime(force=false) if @playtime != $game_system.playtime_s || force @playtime = $game_system.playtime_s rect = Rect.new(200,200,200,24) # The rect reserved for the playtime drawing. contents.clear_rect(rect) # This will clear the previous playtime. draw_text(rect,$game_system.playtime_s) # This draws the updated playtime. end end #-< ҉ >---< Update PlayTime >----------------------------------------------- def update super update_playtime end end # class
And really thank you for your time. =)

*also I noticed, that my question actually kinda deserved for its own thread, damn my simple-to-complex questions* =P
Pictures are show in a higher viewport than the map, and are not affected by the screen tint. To have them affected by the screen tint, you would either need to place pictures in the same viewport, or change the tint to apply to a higher viewport.


Re large vs small window ... the default Status window takes up most of the window size. If you are showing a single large window and not multiple small windows along with it it would obviously not be as great a processor hit as a large window WITH multiple small windows. Why you'd want 5000x5000 I don't really grasp though.
@Rikifive

Try to add update_playtime at the beginning of the refresh method.
kdZE0KB.png


Re large vs small window ... the default Status window takes up most of the window size. If you are showing a single large window and not multiple small windows along with it it would obviously not be as great a processor hit as a large window WITH multiple small windows. Why you'd want 5000x5000 I don't really grasp though.
Because I want to hide stuff from player, so he can't see it. ( ͡° ͜ʖ ͡°)

In all seriousness, that was just for testing purposes, I wanted to check how engine reacts to huge windows, why would I need that huge window? xD

To be clear with everybody:

I'm working on Menu scene and I'm planning to make something like this. (don't mind the mess it's just a quick sketch)

Spoiler
Ngofn1x.png
The yellow ones are already done - they're kinda the default ones.

And here is the question:

It is better to have separate windows for various things? (marked in red) - simpler refreshing methods etc. for each window

Or to make one bigger window and put all stuff in here? (marked in green) - easier drawing of things; more complex refreshing methods.

Is there any difference between one bigger window and multiple smaller ones?

@Rikifive

Try to add update_playtime at the beginning of the refresh method.
Thank you it did the thing. =)

So... the @playtime in initialize method is no longer needed; rest is fine and will be not considered as bad scripting? xD =3

And... What about making another updating thing?

I want to add 'updating' actor positions when changing formation.

add something like this?

Spoiler
def update_newthing some stuff inside similar to the update_playtime method (...) < refresh when formation changed rect = Rect.new(200,200,200,200) # for example the size of picture in bottom right corner -- whatever contents.clear_rect(rect) # This will clear the previous actor positions. -- whatever case actor.id when 1 draw_imag... #Oh it'll be hard there, because I'd have to make multiple update rect's for each postion... I'll draw a new window for this...enddef update # what to do here? super update_playtime update_newthingend
So don't mind the whole idea, just how to make another updating thing in that window?
If you mind the performance, why don't you consider something like this :

Spoiler
Images dead, sorry 🙁
That's a menu that is on-map, that means, it has no Scene for it.

Maybe you want to consider making something simple like this, and not too complicated and flashy like the idea.

And I think you have already made a HUD script that shows whatever you want on the map, so it would still show things in that window.

You can also make a few new windows for the Menu, but I prefer not spamming the screen very much.

And you can also set the opacity of the Menu window to 0.

I'm just giving examples

(By the way, this on the picture is an already existing script)

Yep, most scripters make separate windows for each thing they try to achieve.

I actually don't see the point of making more complicated refresh methods, when you can have less complicated, and the same design.

Maybe the performance is the problem, but I don't think someone with 2.4 GHz will notice only the drop below 40 FPS in the Menu Scene (unless he is using a Mouse script, and with Mouse scripts it is pretty noticable, since the cursor will move slower, and with the default cursor it is not very noticable)

And, yes, the structure of the method is pretty much the same as update_playtime @Sixth provided.
I still prefer having just simple menu, because I'm making a local-coop game and it's easier if the menu just shows up when one of the players will decide to bring that up.

Anyway, I'm also planning to make fancy HUD on map on the corners for both players.

Also all of my windows are fully transparent, I just need to place text and things here and there.

So besides the playtime, the rest of stuff is kinda fixed. I'll make another window to draw active members, because this script will be huge.

So... now I have information shown in one window, so it's always an achievement - 1 window less. < Thank you all for this.

So.. another question appears, (I could do that by myself, but it wouldn't be that efficient I think):

How to refresh a window, when formation is changed?

For example, I'll replace 4th actor with 2nd > whole window refreshes. How to do that? And that will be all for now. =3
The Menu above is also called with the X button.

I was too lazy to show more screenshots, but the actor select window is also transparent, and this scene leaves place for lots of HUDs and everything.

For example, if you make some HUDs for Scene_Map, and you enter the Menu, those windows won't refresh (you can change that) but will still be shown.

You can try to make some Menu that is shown on the map, and also called on X button.

(And actually, those two icons are an on-map Menu that is called with the Mouse, because I tried to use both. Standard is a bit better)

And for the refreshes...

I do not experiment with performance, but I think refreshing the whole window won't affect it too much, since it is not constant update.

Usually, the window is refreshed when it is initialized.

If the window is not refreshed when initialized, nothing will be shown in the window.

So, if you want to refresh it again, just call the refresh method again.

If you REALLY want some performance, clear the rectangles where changed actors are drawn (like @Sixth did), and redraw them again.
No, no - let's forget about performance here - it'll not affect FPS, because it'll be refreshed only if used.

Basically I simply want to refresh the whole window, but the question is - how to make it refresh when changing formation - let's go to my previous script:

Spoiler
class Window_ACTORSHUEHUE < Window_Base def initialize(x, y) super(x, y, w, h) refresh end #-< ҉ >---< Draw Members >---------------------------------------------------- def refresh self.contents.clear member1 = current 1st party member # also how to check who is in the first position? #party.members.id or something like this? draw_image(200, 200, "Graphics/actorshuehue/actor_" + member1.to_s) #draw #first active party member on the front member2 = current 2st party member draw_image(220, 220, "Graphics/actorshuehue/actor_" + member2.to_s) #draw #second active party member near the first member etc. (...) end # Refresh #-< ҉ >---< Update Members >----------------------------------------------- def update super refresh if party.members.changed.position #<< translate that to Ruby and I'll be happy! =3 end # updateend # class
So basically, how to check when members are changed to refresh the whole window once upon changing? =3

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