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

Try this:

Spoiler
def draw_actor_simple_status(actor, dx, dy) dy -= line_height / 2 draw_actor_name(actor, dx, dy) draw_actor_level(actor, dx, dy + line_height * 1) draw_actor_icons(actor, dx, dy + line_height * 2) dw = contents.width - dx - 124 draw_actor_class(actor, dx + 120, dy, dw) # This is the actor's MHP width part. #------------------------------------ gw = actor.mhp/10 draw_actor_hp(actor, dx, dy, gw) #------------------------------------ #draw_actor_hp(actor, dx + 120, dy + line_height * 1, dw) draw_actor_jp(actor, dx, dy + line_height * 2) if YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp? draw_actor_tp(actor, dx + 120, dy + line_height * 2, dw) elsif YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp? if $imported["YEA-BattleEngine"] draw_actor_tp(actor, dx + 120, dy + line_height * 2, dw/2 + 1) draw_actor_mp(actor, dx + 120 + dw/2, dy + line_height * 2, dw/2) else draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw/2 + 1) draw_actor_tp(actor, dx + 120 + dw/2, dy + line_height * 2, dw/2) end else draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw) end end
So, you got the correct actor already in that method, that's why I asked you where do you want to make that happen.

The above code will change the HP gauge to your MHP based gauges. I marked what I added. Note that I removed the default HP gauge drawing too, since I guess you won't need that.

Remove the 'def draw_gauge' methods you added, that can not be done that way. You can't define a new method inside of another method.
lol... guys, I have another problem oO

I make this

def method array.size.times do |i| text = array.some_text while !text.empty? temptext = text.slice!(x..y) do something with temptext and repeat end endendnow I had to realize, that the text in my array is empty too, like in the text variable I stored it in. so this must mean it is no new string, it is a reference and whatever happened to my text variable happens to my array.some_text too!

how can I prevend that?? this is not what I wanted to achieve. XD

 

 

/E:

oh my god, the solution is so simple if you know it! >_>

so, for everyone who have the same troubles one day...

 

if you copy the text of a string to another variable like this 

text = "hello"text2 = textthen text2 is the same object, both variables share the same object_id. this means if you make something like text2.gsub or text2.slice! it affects text as well.

if you change the text in text2 like this 

text2 = "world"the variable got a new object_id.

 

well... to prevent that the other variable have the same ID but the same text, just use

text2 = text.cloneand the object_id is different.

 

 

and learned something again today.... 
Try this:

Spoiler
def draw_actor_simple_status(actor, dx, dy) dy -= line_height / 2 draw_actor_name(actor, dx, dy) draw_actor_level(actor, dx, dy + line_height * 1) draw_actor_icons(actor, dx, dy + line_height * 2) dw = contents.width - dx - 124 draw_actor_class(actor, dx + 120, dy, dw) # This is the actor's MHP width part. #------------------------------------ gw = actor.mhp/10 draw_actor_hp(actor, dx, dy, gw) #------------------------------------ #draw_actor_hp(actor, dx + 120, dy + line_height * 1, dw) draw_actor_jp(actor, dx, dy + line_height * 2) if YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && !actor.draw_mp? draw_actor_tp(actor, dx + 120, dy + line_height * 2, dw) elsif YEA::MENU:😀RAW_TP_GAUGE && actor.draw_tp? && actor.draw_mp? if $imported["YEA-BattleEngine"] draw_actor_tp(actor, dx + 120, dy + line_height * 2, dw/2 + 1) draw_actor_mp(actor, dx + 120 + dw/2, dy + line_height * 2, dw/2) else draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw/2 + 1) draw_actor_tp(actor, dx + 120 + dw/2, dy + line_height * 2, dw/2) end else draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw) end end
So, you got the correct actor already in that method, that's why I asked you where do you want to make that happen.

The above code will change the HP gauge to your MHP based gauges. I marked what I added. Note that I removed the default HP gauge drawing too, since I guess you won't need that.

Remove the 'def draw_gauge' methods you added, that can not be done that way. You can't define a new method inside of another method.

That worked! Thank you!

So... I really messed up everything... =P

I have one another question:

The main purpose I added 'def draw_gauge' methods was the ability to change the HEIGHT of each gauge, because YANFLY_Ace Core Engine does have GAUGE_HEIGHT = 10 option and I couldn't change the height of the gauges. For example I would like to have exp and tp gauge more 'flat', so my *idiotic* instincts told me to steal that method from core to that script and paste that before drawing each gauge.

Is there any possibility to do that? To change the height of each gauge?

I'm not even sure if I will use different heights, I need to plan my design of that first, so if its a long/complicated process then let's forget about that.

I discovered how to do that. My *idiotic* instincts were not that stupid actually, I just messed up something.

Anyway, thank you for help! =)

And one another: If the gauge is short, it only draws current HP. It starts to draw current and maximum hp when it's pretty long ~ can it be fixed/changed? Is this possible to remove the HP vocab and leave only gauge and numbers?

Managed to do that by myself.

WtvmtpT.png


I managed to remove vocab by leaving blank HP (short) in terms tab in database. =P

I removed that in better way, using script.

WtvmtpT.png


Or remove the numbers and everything and just leave the gauge, and draw the rest of stuff manually. (I know how to draw these stuff manually)

That was easier than I thought.

WtvmtpT.png


OK I managed to do everything I asked before. Problem SOLVED.

Now I have full control of actor status.

Thanks for helping with sizes of gauges! =)
ah god dammit!! need some help again... 

if someone creates a new method in GameInterpreter in his/her script, do I have access to that methods in my scripts only in GameInterpreter or everywhere?

and when everywhere... can I use methods that are written like this?

Code:
  [:method_name_a, :method_name_b].each { |method|    define_method(method) do |var1, *obj|      quest(var1).send(method, *obj)    end  }
Game_Interpreter is for script calls made from events directly. So, no, you won't have access to those methods in another class.


If you want to make methods which can be accessed from everywhere, I suggest you make them within a module. That way you can call them from any class you want.


As for the second question, I have no idea. I tend to stay away from doing stuffs like those. I like to define my methods on the normal way, and if I want to operate dynamic values, I simply use arguments for my methods. Much cleaner that way. But that is just my personal preference.
yeah, I like the cleaner way too. 

this definitions are from another script... hm... they are not within a module, so I have to find another way to use some of the methods, thanks for your answer! =)
If they are not within a class at all, they can be used in every class/module, I think.


I just like to put my own methods into my own module to avoid method name clashing and to keep it more organized.
yep, organized and commented!! two very important things in my opinion! ^^

and nope, his/her methods are within classes.

but I found another way, luckily the important parts of it are stored in $game_party, so I gain access with this. =)

another small question, I feel a bit stupid because I can't find it: windows play SE's if you press a button right? 

but for my window I want some other SE's be played. no panic, the SE's are playing which I wanted, my problem is, that the standard sounds are playing too and this is a bit stupid. 

so I thought I overwrite these things for this one window but I can't find the methods for this. oO
It depends what kind of SEs you want to get rid of.


To get a quick find on them, search for 'Sound.' in Window_Selectable. You will see all the sound effects scattered in different methods. What each method does will be obvious because they are named logically, so you will know when each SE is played.


If you still hear some default SEs, they are most probably in the scene itself, so search around there.
ugh, yeah... there they are! I knew I saw it before... as I said, I feel stupid. =_=

thanks again! found it - fixed it

now everything works fine! =)
How to check "Preserve TP" special flag in scripts to use that in conditions?

Something like:

If actor doesn't have "preserve tp" - tp bar is not displayed;

if actor has "preserve tp" - tp bar is displayed.

If that is important - I'm editing:

class Window_Base < Window

def draw_actor_simple_status(actor, dx, dy)
How to check "Preserve TP" special flag in scripts to use that in conditions?

Something like:

If actor doesn't have "preserve tp" - tp bar is not displayed;

if actor has "preserve tp" - tp bar is displayed.

If that is important - I'm editing:

class Window_Base < Window

def draw_actor_simple_status(actor, dx, dy)
Simply:

if someBattler.preserve_tp? #Do somethingendpreserve_tp? is a method built into the Game_BattlerBase Class.

If found this simply by doing Ctrl-shift-F and typing "Preserve" 😉

/Kai
Yeah I did the same and found that too, but I had problem with using that properly. =P
I tried putting lines with "unless preserve_tp?" as well as tried using that in "if" e.g. "if preserve_tp?", but it didn't work. =P
 
Now it works, I used:

if actor.preserve_tp?~ do stuffendLOL I knew that will be easy and I feel like an idiot now.
Thank you!
 
~ Solved
Sorry for double posting, but I don't want to make a thread especially for that ~ I know I'm asking and asking, sorry.

I'm using Max TP script and Max TP value may be different than 100, so I want to put that value into actor status menu, just like in other bars: something like 23/100.

I discovered how to draw MAX TP value (actor.max_tp) but it's displayed like this: 34/100.0

So... The question is quite overall: how to get rid of the numbers after dot and vice versa?

So far I know, that when I put "* 0.01 * 100", the integer number is displayed as fraction (like 53.2), but I don't know how to convert fraction to integer.

And I would be grateful if somebody could tell me how to draw that tp max value as integer.
actor.max_tp.to_iThe '.to_i' will make it an integer.
Ohh, and note that even current tp value can become a float number, so you need to put .to_i there as well.
actor.max_tp.to_iThe '.to_i' will make it an integer.Ohh, and note that even current tp value can become a float number, so you need to put .to_i there as well.
LOL thanks!

(I know many people laughs at me now)

Yeah, I noticed that and solved immediately. =P

Once more - thanks! =)
Using the draw_text method, is it possible to have mutliple text colors within the "text" argument? I found the change_color method, but I want to have multiple colors on one line of text while using a custom Window_Selectable class.
Or more simply, I have draw_text(x,y,width,height,text), can I stick some form of color change in the text variable or do I have to find another way?
Unless I am missing something big, there is no way to change colors mid draw_text command. 

I tend to achieve the result like this:

draw_text(0,0,100,line_height,"Attack:")cx = text_size("Attack:").widthcontents.font.color = Color.new(255,0,0) #Reddraw_text(cx,0,100-cx,line_height,"100")The text_size(string).width gives you the width, in pixels, of some text using the current Font settings
Unless I am missing something big, there is no way to change colors mid draw_text command. 

I tend to achieve the result like this:

draw_text(0,0,100,line_height,"Attack:")cx = text_size("Attack:").widthcontents.font.color = Color.new(255,0,0) #Reddraw_text(cx,0,100-cx,line_height,"100")The text_size(string).width gives you the width, in pixels, of some text using the current Font settings
Thank you! I just got done making workaround scripts, now I can just pitch them and use this, so much simpler and easier 🙂
Hello everybody, I want to do something big, but I have a small question and it doesn't deserve it's own thread I think.

Is this possible to have multiple actor status sizes in one window? (the one with actors in menu)

I have something like this:

Spoiler
pG8YiEA.png
And my question: Is this even possible to make something like this in one window or I need to create a separate window for that?

Spoiler
4v3P6I6.png
There are only two active members in party and there will be kinda lots of them (+6) available, so I want to make it look better.

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