@CashmereCat: Pressing CTRL + A in the script editor will select the entirety of the selected script and then pressing CTRL + Q will comment out/uncomment the selected portions of the script.
Ruby/RGSSx questions that don't deserve their own thread
RGSSx Script Support@Alexander Amnell: Beautiful. Much thanks!
Hello all, First I'm very noob at scipting, to be honest I just learn it this morning.. Sorry if my question is a silly question..
The goal:
I try to make a window with size 400x400.
The window is done. now the problem is..
I want the window give an explanation of an actor description.
Let's say Eric description :
A veteran warrior who fought on many battlefields.
He becomes uncontrollable in battle when berserk.
That's a two line sentences by default in the database.. I mean if I put that description into the window of 400 x 400 that I made, it cannot fit in one line(I use draw_text method, and contents.width for width parameter, make the word cannot be readable). However I realize that draw_text_ex method can split the description sentence into two lines in the window. However..
because draw_text_ex doesn't have a width parameters which I like to use with contents.width method from Window_Base, the description sentence still
penetrating the right border of window make some of the words not visible.
Here's the parameters from both method, in case you forgot(I don't mean to offend anyone, just in case you forgot, sorry)
draw_text(x, y, width, height, str[,align]) this method has width parameter
draw_text_ex(x, y, text) this method doesn't have a width paramater
What I want is I can split the description sentence into two lines or probably three lines, it doesn't matter.. The most important is I don't want the sentence penetrating the window right border.(Somehow if I can use draw_text_ex and it has the width parameter like draw_text, that penetrating issue will gone, but this is
a dumb analysis from my dumb brain). This trial and error have driven me crazy!
I know maybe this is a simple problem but I believe this become more complex because my english very "great" you know what I mean..
Hopefully someone know what I mean.. Thanks
The goal:
I try to make a window with size 400x400.
The window is done. now the problem is..
I want the window give an explanation of an actor description.
Let's say Eric description :
A veteran warrior who fought on many battlefields.
He becomes uncontrollable in battle when berserk.
That's a two line sentences by default in the database.. I mean if I put that description into the window of 400 x 400 that I made, it cannot fit in one line(I use draw_text method, and contents.width for width parameter, make the word cannot be readable). However I realize that draw_text_ex method can split the description sentence into two lines in the window. However..
because draw_text_ex doesn't have a width parameters which I like to use with contents.width method from Window_Base, the description sentence still
penetrating the right border of window make some of the words not visible.
Here's the parameters from both method, in case you forgot(I don't mean to offend anyone, just in case you forgot, sorry)
draw_text(x, y, width, height, str[,align]) this method has width parameter
draw_text_ex(x, y, text) this method doesn't have a width paramater
What I want is I can split the description sentence into two lines or probably three lines, it doesn't matter.. The most important is I don't want the sentence penetrating the window right border.(Somehow if I can use draw_text_ex and it has the width parameter like draw_text, that penetrating issue will gone, but this is
a dumb analysis from my dumb brain). This trial and error have driven me crazy!
I know maybe this is a simple problem but I believe this become more complex because my english very "great" you know what I mean..
Hopefully someone know what I mean.. Thanks
Maybe your window just isn't big enough to fit all the text.
The Help window allows up to 2 lines for descriptions of items, weapons, armors, etc. Take a look and see what it uses.
The Help window allows up to 2 lines for descriptions of items, weapons, armors, etc. Take a look and see what it uses.
I haven't traced through all the text drawing code in a while (check the help docs, there may be something in there under "text"), but off the top of my head you've got two or three options:
1) Format the text yourself, sort of like what we have to do in the show text dialog boxes by default.
2) Rewrite the draw_text_ex method with a width paramater (give it a default value of 0 and check for that so you don't break any existing code).
3) Write a new draw_text_my_way method that uses the same splitting procedure draw_text_ex uses but has a variable width parameter.
3 is probably the best if you know all the places you'd be calling it from (ie: new windows you create). If you want it to work on all windows, including 'default' ones you plan on resizing, 2 may be the more direct approach. As always keep the original code up top so you can rollback at any time.
1) Format the text yourself, sort of like what we have to do in the show text dialog boxes by default.
2) Rewrite the draw_text_ex method with a width paramater (give it a default value of 0 and check for that so you don't break any existing code).
3) Write a new draw_text_my_way method that uses the same splitting procedure draw_text_ex uses but has a variable width parameter.
3 is probably the best if you know all the places you'd be calling it from (ie: new windows you create). If you want it to work on all windows, including 'default' ones you plan on resizing, 2 may be the more direct approach. As always keep the original code up top so you can rollback at any time.
Hi Mouser, I have a reason why not to do your option number 1, but because I'm not good at explaining my problem especially in english so I can't tell you precisely.
I want it like this, when the window open, then I input.trigger?🙂RIGHT) it will change all the data from character one into another(it's kind like choosing a character for your game). So I put an index variable and set it to 1, then if I press right the index will += 1, thus change all the data from actor one to another. Then I don't think if I'm format every actor description is a good idea, because I call the description data using $data_actors[index].description. Hopefully you know what I mean.
Then your second and third option probably is the best option for me, but because I'm a noob in both scripting and ruby, I still need to figure out how to rewrite this and that..(Actually I have tried to rewrite the draw_text_ex and have been messed up with the parameter width, but again it's a trial and error).
Okay, thanks Mouser, I appreciate your reply, however I still need some help here..
That's it, I'm aware that the window is indeed not big enough, but I'm just wondering if maybe there's a way to make that description sentence fit in my window, by spliting the lines into 3 line. But I think there's no way to do this right?(because draw_text_ex only split it into 2 lines and then it doesn't have width parameter like draw_text which is very convenient to automatically resize the size smaller up to 60%, If I;m not wrong) Forgive me, I know this is such a silly question..
But thanks for the reply Shaz, I will continue learning about scripting..
I have a general question regarding rgss and the eventing system.
When it comes to efficiency, how much more efficient is it to have a system built through rgss3 as opposed to eventing?
For example: You've got an event that's in parallel process calculating its distance between the player every few frames.
How much more efficient would the game be in going through the process if it was a script call instead of eventing?
How much more efficient would the game be if the process was done completely through a script, not touching the eventing system at all?
When it comes to efficiency, how much more efficient is it to have a system built through rgss3 as opposed to eventing?
For example: You've got an event that's in parallel process calculating its distance between the player every few frames.
How much more efficient would the game be in going through the process if it was a script call instead of eventing?
How much more efficient would the game be if the process was done completely through a script, not touching the eventing system at all?
Take a look at Game_Interpreter and see how it handles things.
It calls scripts directly, so the overhead you have with the Interpreter that you wouldn't (might not) have just using scripts would all be inside that class. You'd have the extra processing of looking at each line, calling the appropriate method for the command, maybe setting up some arguments to pass, and doing the call.
It calls scripts directly, so the overhead you have with the Interpreter that you wouldn't (might not) have just using scripts would all be inside that class. You'd have the extra processing of looking at each line, calling the appropriate method for the command, maybe setting up some arguments to pass, and doing the call.
I would try to set that up so that it checks the distance after every player move. There's no reason to keep checking every few frames, since the player isn't going anywhere. Where exactly in the scripting classes I'm not sure - whatever handles character movement could set a switch, use that to start a common event, have the event turn the switch off after calculating distance: lather, rinse, repeat.
Have another switch for "done" so the script stops setting the switch for the common event.
I was just wondering if anyone had ever encountered problems with cloning a bitmap via doing something like...
Cache.whatever("IMAGE",hue_value).clone
Anyone?
Cache.whatever("IMAGE",hue_value).clone
Anyone?
The interpreter calls themselves aren't that much overhead. The real difference usually comes from the fact that if you know exactly what you want to do, you can most likely write a script that does the logic much more efficiently than anything you could get from re-using the limited things events can do.
Like Mouser said, in your example the biggest difference would be that if you scripted it, you could just check the distance when the player moved, rather than checking it every frame. RGSS already even has an on_player_walk function you can extend. If both the event and the player are moving simultaneously, you might have to do more complex checks, but you'd still be able to write faster checks in ruby (see this thread for details).
Events are still fine if you use them mostly for the things they were intended to do, like showing messages or running move routes. You'll only see a significant difference in performance when you do something more complicated, like line-of-sight or distance checks.
Can't remember if I've ever attempted anything like this, but I certainly don't see any problem with the logic. What's happening when you try it?
@Shaz - Nothing unusual. Its creating the image fine.
My thinking is, if its cloning an image, it must be creating a normal one first - in order to clone it.
I cant really notice any performance loss due to it but I was wondering if its creating a bitmap somewhere thats not being disposed. I know theres a script to check for disposed bitmaps by Mithran (I have it somewhere) but I still dont know how you would find that image in order to dispose it - or even if there is one.
Maybe I am over-thinking this seemingly simple method...
My thinking is, if its cloning an image, it must be creating a normal one first - in order to clone it.
I cant really notice any performance loss due to it but I was wondering if its creating a bitmap somewhere thats not being disposed. I know theres a script to check for disposed bitmaps by Mithran (I have it somewhere) but I still dont know how you would find that image in order to dispose it - or even if there is one.
Maybe I am over-thinking this seemingly simple method...
@Dekita
The script you are thinking of checks for undisposed drawn screen objects (Sprites, Windows, Planes, Tilemaps), not Bitmaps. It is stickied at the top of the RGSS3 Completed Scripts page. Bitmaps are an entirely different animal in the way they use resources, and their respective limits.
The short answer (for the purposes of this thread) that there is a solid 10000 GDI object limit by default for any windows process, and RGSS Bitmap objects all fall within this limit. Up to the point just before you approach the limit, you shouldn't experience any performance issues just from having the Bitmap objects in memory, but you will take a performance hit if you create, clone, dispose, or orphan (via GC collecting them) a particularly large amount at a given time. Bitmaps tend to use a fair amount of RAM if you keep them around and have the limits described, but otherwise, usually fine. Screen objects on the other hand are the opposite - you will take a performance hit for having too many of them in memory, whether or not you are updating them or whether the screen can actually "see" them, and the metadata access and Graphics.update will be progressively slower for each one, however, these objects use hardly any memory at all. Keep Bitmaps around (within reason), dispose Sprites if you have a lot of them you aren't using (but try not to volume dispose these either, unless it is during a scene transition).
I've gone into more detail on this in other threads, including the aforementioned script thread.
And yes, cloning the bitmap in the way you specified has to create a new one in Cache if it is not already present, storing it in the cache, and then cloning that bitmap. If the Cached bitmap already exists, you are getting a clone of that one. So long as you disposed the cloned one when you don't need it anymore, you are fine, and you wont touch the cache. Even if you dispose something in the Cache, the module has logic to reload it the next time it is referenced from Cache (however, it is still a bad idea because other sprites could still be using the bitmap). You don't need to clone a bitmap from Cache unless you are drawing on it.
The script you are thinking of checks for undisposed drawn screen objects (Sprites, Windows, Planes, Tilemaps), not Bitmaps. It is stickied at the top of the RGSS3 Completed Scripts page. Bitmaps are an entirely different animal in the way they use resources, and their respective limits.
The short answer (for the purposes of this thread) that there is a solid 10000 GDI object limit by default for any windows process, and RGSS Bitmap objects all fall within this limit. Up to the point just before you approach the limit, you shouldn't experience any performance issues just from having the Bitmap objects in memory, but you will take a performance hit if you create, clone, dispose, or orphan (via GC collecting them) a particularly large amount at a given time. Bitmaps tend to use a fair amount of RAM if you keep them around and have the limits described, but otherwise, usually fine. Screen objects on the other hand are the opposite - you will take a performance hit for having too many of them in memory, whether or not you are updating them or whether the screen can actually "see" them, and the metadata access and Graphics.update will be progressively slower for each one, however, these objects use hardly any memory at all. Keep Bitmaps around (within reason), dispose Sprites if you have a lot of them you aren't using (but try not to volume dispose these either, unless it is during a scene transition).
I've gone into more detail on this in other threads, including the aforementioned script thread.
And yes, cloning the bitmap in the way you specified has to create a new one in Cache if it is not already present, storing it in the cache, and then cloning that bitmap. If the Cached bitmap already exists, you are getting a clone of that one. So long as you disposed the cloned one when you don't need it anymore, you are fine, and you wont touch the cache. Even if you dispose something in the Cache, the module has logic to reload it the next time it is referenced from Cache (however, it is still a bad idea because other sprites could still be using the bitmap). You don't need to clone a bitmap from Cache unless you are drawing on it.
I knew it!! ^_^
Perhaps I will rethink my approach then.. Just to be safe..
I mean, I am not drawing on the bitmaps, but because there was more than 1 of it on the screen at a time, when I disposed any one of them, they all got disposed - which is why I cloned the BM is the first place :/
I will have a good look through that thread and see if theres anything that can give me some thoughts on how best to proceed ^_^
Thanks for the reply.
Perhaps I will rethink my approach then.. Just to be safe..
I mean, I am not drawing on the bitmaps, but because there was more than 1 of it on the screen at a time, when I disposed any one of them, they all got disposed - which is why I cloned the BM is the first place :/
I will have a good look through that thread and see if theres anything that can give me some thoughts on how best to proceed ^_^
Thanks for the reply.
If they are Cached, you don't need to dispose them right away, or usually, at all. The base scripts occasionally dispose cached bitmaps with battlers (only to be disposed all at once, when the scene end, because hue shifted battlers are cached separately), backgrounds (which are screen-size, and all disposed at the same time when the scene ends), and animations (where a class variable is set up to check when an animation is no longer needed to unload it), most likely to keep the memory usage at a reasonable amount. You have a hard limit on the process of about ~1.8gb, which is enough to load a bitmap the max screen size 1000 times over and still have some to play with, but a reasonable sandbox to play in is < ~0.5gb. With proper usage it shouldn't be an issue, and no way you should be hitting the cap within a single scene. Just dispose the bitmaps in question when the scene ends if you are concerned about using too much memory.
Hey everyone, wanted to ask a question, but I don't think that it requires an entire thread. Isn't there a way to increase damage if an enemy is already weak to a certain element? For Example: let's say Giant Frog's weakness to ice is 120%, but it resists everything else. When the player uses a skill or inflicts a status Giant Frog's weakness to ice increases to 150%, but it still resists everything else. Is there a way to make this happen in eventing or would I have to use a script?
You should be able to set up a state that will change the weakness to ice from 120% to 150%. No scripting OR event commands needed at all.
If you can't figure it out, make a new post in VX Ace Support, as it's not a scripting issue.
If you can't figure it out, make a new post in VX Ace Support, as it's not a scripting issue.
Thank you, Sharm. I only asked here because I didn't want to see the blue text of shame.
I'm not Sharm 😉
Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/