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

already using mithrans text cache script, but because its alot of text being drew on some pages, i was trying to cut down on the amount of FPS drop when changing pages (it drops down to 56FPS for a second then back up)
4 fps drop from 60 to 56 is not the same as 4 fps drop from 30 to 26, to my advice to you is that you should not be worry about that. But if you want, I guess you could cache the page as a bitmap once it is already written and then just use blt with the page bitmap.
thanks,

i already managed to reduce it down to 60->59/58 fps, which is a reasonable drop i think, turns out it was drawing all the rect,s and filling them that was causing my lag as opposed to the text (which i had originally thought) and its just getting faster and faster the more im working on it, so i think when its properly done i should have almost no drop at all 🙂
You also should not trust the FPS display as a means of actual benchmarking as it is not 100% accurate. An FPS drop can also be caused by a number of different things not directly in your control (eg., garbage collection). If you are noticing some actual visual stutter, then it might be worth it to benchmark and find your bottleneck.


Drawing text is indeed slow. My script alleviates some of this by adding the cache, but you may have noticed adds a tremendous amount of overhead to each draw_text command (while actually accessing the underlying method less), as well as individually having to calculate where to draw each letter. Net result, the longer the string being drawn, the less of an improvement you will see due to this calculation (the actual draw is much faster since its just a simple blt instead of accessing the font and asking it it to build a letter, but the letter iteration and calculating of the position is much slower). On the flipside, the normal overhead the draw_text method has to go through just to access the font is also slow, so you will see a tremendous improvement on smaller strings.


That was a bit of a tangent but the point I am getting at is if you want to see improvement, you need to identify your bottleneck and either solve it by replacing it completely with a more efficient method, write around it in such a way that you have to access it less (as above), or find a better time or times to access the method (eg., my Window Selectable MAX VX script (http://pastebin.com/xHptRXKs) where I only drew the visible areas of any scrolling Window_Selectable window and drew a limited number of items per frame). For example, if you have indeed determined drawing rects is too slow for you, you could either write a completely new method to draw rects, try using a different operation like blt so you only have to draw them once (if the pages are static, you could also consider saving the entire bitmap instead of redrawing it as lemony suggested), or draw them when it wont be a drag on your framerate.
hmmm, you plan on making that script for VX Ace ? seems very usefull 😛

( i thought it was a vx ace script and got an error at line 69 for an initialized constant WLH )

i do have a window that draws about 200 items (usually) so im working on reducing the micro-lag caused by that, i do have a slight visual delay ( of about half a second ) which isnt really that bad, but not ideal imo

also, the page layout is static but the information shown is variable ( items only show the stats they have and the unique stats given to them )

edit: i think il just study that script you linked and see if i can do something similar. ( no draw item off-screen )

see all my equipment is individualized, so through the course of an average game players could build up quite the collection of equipment, especially if they are trying for a particular bonus stat ( randomized bonus stats ) like Atk Per turn +1 x3 or something ;p
Yeah, no plans for an ACE version from me because the script itself was a bugfix for the specific issue in VX (where the max creatable blank bitmap size was smaller than a full database full of items drawn in Window_Item, VX ACE's upper limit is much more reasonable). I added the staggered offscreen drawing to combat the obvious issue that arose when you had to draw potentially hundreds or thousands of items during a scene switch - you'd get upwards of a ten second freeze. This was not acceptable, so I had it only draw what was visible and delegated the rest to be drawn at x per frame (or force drawn as the window was scrolled). For ACE the bitmap size was large enough to accommodate an entire database full of items and the loading time seemed within reason.


Keep in mind that ACE has faster text drawing (much faster if you are using my text cache) as well as faster everything else due to using a more current ruby version. You need to do at least a few calculations to determine what should be drawn and when, so that is overhead which is actually slowing you down before you reach a certain number of skipped drawn items (likely a very low amount, but I haven't benched in in ACE). You likely won't notice this overhead at all, and it should considerably speed up the initial loading of the screen given 200+ draws. Ideally, you want to plan for what would be a normal load but have it be able to scale to the maximum amount possible.
 ive been trying to figure that one out for a while so i could create a little music production / mixing mini game type thing.

so i would also like to know the answer to this, and i would like to add a little to the question also, 

Does anyone know how to access the midi audio synthesizer within vx ace ? 

i figure if playing a midi it must pass through some kind of vst instrument ( probably a very weak one ) but cannot find any reference to this whatsoever in the F1 help pages.
How does MogHunter use the music in his Melodia Minigame. It is like guitar hero button style (http://www.atelier-rgss.com/RGSS/System/ACE_SYS16.html)



Would that help at all?
Mog just randomly generates a key to press. The graphics are impressive but in terms of customization you have a lot of control over the look and feel but have very little control over the notes themselves.


SO it looks more like a reflex game since you have like a second to figure out which key popped up and to hit it.
@ Mithran, last night i checked how many items i could get in my selection window before a ridiculous lag was achieved, over 1050 items only caused a drop from 60-44FPS for a second, but the main lag appears when the selection window is first drawn, i think il just try and do something similar to your script and store the items and then only display the items within the selected range.

or put a limit on how many equip items can be held at any one time, 100 seems reasonable enough, lol. dunno yet, i think storing them would probably be the best route 🙂
why do people put (*args, &block) at the end of methods that do not usually have any args ?

ie.

def some_method(*args, &block)  # << some codeend
i understand that the args is basically telling it to keep all the current arguments that have been passed, but what the hell is &block for ?

edit : sorry for the double post. I didnt realise i was the last person to post. 
some_method { p "something" }You can retrieve whatever I wrote between those curly braces in `block`.

Better answers:

url=http://stackoverflow.com/questions/8829478/understanding-ruby-blocks]http://stackoverflow.com/questions/8829478/understanding-ruby-blocks

http://stackoverflow.com/questions/814739/whats-this-block-in-ruby-and-how-does-it-get-passes-in-a-method-here
@dekita


Yeah, my script also does a staggered draw ahead of what is displayed so that you'll never have more load than the initial displayed area being drawn. To your other question and to add to Tsukihime,


Using the & symbol in front of a variable at the end of your argument list binds it to a variable that you can then pass around as a proc. If you use the & when passing this back as an argument into a method, it is read as a block. You can mix and match these behaviors, much in the same way you can use the splat (*) to collect arguments into an array or expand them into an argument list. If you don't explicitly bind it into a variable, the block at the end of an argument list is still implicitly passed and can be accessed using yield.


Ruby will pass a given block automatically if it is tacked onto the end of a method, however, this does not happen when a method has been aliased and at some point has the aliased method called within it - if a block was given there, it would need to be explicitly passed, so they then bind it to the variable and pass it transparently, as with the argument list. I suspect may scripters do this because with the way Rpg Maker scripts are and with the possibility of having so many different chefs in the kitchen, so to speak, it is impossible to know what a method will actually do. This encompasses nearly every usage I have seen for the practice of binding a block in RPG maker scripts. However, I find this thinking to be slightly flawed as if the method was changed so drastically as to require a block to function when it did not before, simply transparently passing the block in whatever code you are adding on is probably not going to have the desired result. Its not really making any notable impact either way in this situation, so use your own discretion.
Just wondering, I'm getting this error

unexpected tIDENTIFIER, expecting ')'

((10 x (1 + rand(1.125))) - b.mdf)...

Whenever I use a skill with this damage formula.

((10 x (1 + rand(1.125))) - b.mdf) x (2 + a.mat x (a.xstat.intelligence + a.mat)) / 256

There doesn't seem to be an open bracket or anything, which I assume the error is telling me.

(oh and the xstat refers to a script, it works in other formulae fine)
Is your formula exactly as you've typed it?  If so, x does not mean multiply.  * does.  I'm assuming it's reading ((10 then reading x and thinking they don't belong together.

This should be a bit more successful:

((10 * (1 + rand(1.125))) - b.mdf) * (2 + a.mat * (a.xstat.intelligence + a.mat)) / 256
...I am a fool.
lol - I was almost afraid to post that, as I thought surely you know it, and would be insulted by me asking if that was the problem 😀
I have no idea why I wrote 'x' instead! Thanks for the help! 😛
@ Tsukihime

Quick one line explained alot surprisingly 😛 thanks 🙂

@ Mithran

few paragraphs, explained even more (after i re-read it for the 5th time to be sure 😛 )

i think i may be best to just use 

def method(*args)# << crapendand forget about the block unless i know that a block will most probably be passed, as well as what the block will be doing..

considering the methods im putting it on dont normally have any args at all, this seems the best route (at least for now) imo.

thanks. (once again 😛 ).

edit:

then again, it may be safer to assume that a block will be passed for some methods i guess...
Is there a script call for showing a Balloon Icon above a player/event head? I'd like to call one through a Set Move Route command.

Thanks in advance!
Code:
@balloon_id = 2
in script in move route
Thanks Galv. I can't seem to get it to work. I'm assuming the syntax is as follows:


Exclamation on event 002:


@balloon_001 = 002
or
@balloon_1 = 002

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