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

Well, will the formation window be used as a window for changing the formation?

If so, then the bigger problem will be how to change the formation, not how to refresh window after changing the formation.

Try copying the method how default RTP scripts did it, but if you fail, I think you should start a new topic for how to make a custom formation window.

And you can get the first member with $game_party.members[0] (or $game_party.leader, I think)

Or am I getting something wrong?
The formation will be simply changed via 'formation' command in the very standard party window. The picture here is non selectable, it only draws pictures based on party member's position.

It's just kinda like gold window - there is only information drawn, but here instead of text, I want to draw pictures - but how to force refresh in that window, when any of the members changes position? (using totally basic formation command and changing position in actor status window)

So, I want something like this:

Choose formation command > go to actor status window (totally standard, kinda) > replace members (the very basic function) > force refresh in another window (the one with the pictures).

That's all, I just need a condition, where it checks if any of the members changed position.

WtvmtpT.png


Also, I spent sooooo much time on customizing that scene, and I'm near the end. I'm not gonna do all of this from the beginning. xD
Then I think you should do something like :

Spoiler
class Scene_Menu < Scene_Base  alias :start :initialize  attr_accessor :your_first_member_window  def initialize    blahblahblah    @your_first_member_window = Window_YourFirstMember.new  endend
And then in the Window_ActorSelect in on_actor_ok try to add someting like

Code:
SceneManager.scene.your_first_member_window.refresh
I... kinda got confused... how that works? =P

I was thinking about something like this, though it may seem completely stupid:

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 = $game_party.members[0].name draw_image(200, 200, "Graphics/actorshuehue/actor_" + member1.to_s) #draw #first active party member on the front member2 = $game_party.members[1].name draw_image(220, 220, "Graphics/actorshuehue/actor_" + member2.to_s) #draw #second active party member near the first member etc. (...) @partymember1 = $game_party.members[0].id @partymember2 = $game_party.members[1].id @partymember3 = $game_party.members[2].id @partymember4 = $game_party.members[3].id @partymember5 = $game_party.members[4].id @partymember6 = $game_party.members[5].id end # Refresh #-< ҉ >---< Update Members >----------------------------------------------- def update super refresh if @partymember1 != $game_party.members[0].id refresh if @partymember2 != $game_party.members[1].id refresh if @partymember3 != $game_party.members[2].id refresh if @partymember4 != $game_party.members[3].id refresh if @partymember5 != $game_party.members[4].id refresh if @partymember6 != $game_party.members[5].id end # updateend # class
But I'm not sure if it will work... =P

Uh... and I thought it will be an easy thing to do...

WtvmtpT.png


LOL actually it works! I hope...

It refreshes the ... Wait I know how to check that...

WtvmtpT.png


Pff LOL it really works! xD

I didn't thought It actually is correct!

Okay, problem solved! (unless there is something not right =P)

WtvmtpT.png


Yes, there is something wrong (not wrong, but simply not needed) -  there's no need to put that stuff in initialize method. (it is removed now) =]

Now it's working perfectly!

Thank you for help! =]
Yep, that will work also.

But it's better for performance the way above.

And, you could optimize (not optimize, shorten) your code a bit, if you are sure you want to use that way :

Spoiler
class Window_ACTORSHUEHUE < Window_Base def refresh    (...)    @partymembers = [] # Initializes the party member array    6.times{|i|@partymembers << $game_party.members.id} # Adds the iD's of party members  end  def update    super    @partymembers.size.times{|i|refresh if @partymembers != $game_party.members.id} # Refreshes the window  endend # WARNING : This code is untested. 

But of course, if you don't understand the code above, keep it your way, as long as it works.

Great you solved it!
Of course I don't understand. xD

Also, now I need to make it draw/update members related to party size.

Initially I have 6 actors, so that's why there are 6 lines, but I need to make it change along with party size.

So I need to add 'case $game_party.size' and put "when's" before each line. So... as long as I know how my method works, it should be easy to do - I wouldn't have idea what to do with you code as I have no idea how it exactly works. =P

But thank you anyway for helping with so many things! =]
His method basically just loops the given number of times so that you can write your code in less lines...
His method basically just loops the given number of times so that you can write your code in less lines...
I know that, but I don't know how to interact with it. =P

For example, I have a conditionals:

Spoiler
def refresh self.contents.clear @partymember1 = $game_party.members[0].id if $game_party.members.size >= 1 # These are @partymember2 = $game_party.members[1].id if $game_party.members.size >= 2 # to prevent @partymember3 = $game_party.members[2].id if $game_party.members.size >= 3 # game from @partymember4 = $game_party.members[3].id if $game_party.members.size >= 4 # crashing @partymember5 = $game_party.members[4].id if $game_party.members.size >= 5 # when there's @partymember6 = $game_party.members[5].id if $game_party.members.size >= 6 # no enough @partymember7 = $game_party.members[6].id if $game_party.members.size >= 7 # members to @partymember8 = $game_party.members[7].id if $game_party.members.size >= 8 # take ID's (...) even more if needed end # Refresh #-< ҉ >---< Update Positions >----------------------------------------------- def update super refresh if @partymember1 != $game_party.members[0].id if $game_party.members.size >= 1 #Same refresh if @partymember2 != $game_party.members[1].id if $game_party.members.size >= 2 #here refresh if @partymember3 != $game_party.members[2].id if $game_party.members.size >= 3 #... refresh if @partymember4 != $game_party.members[3].id if $game_party.members.size >= 4 refresh if @partymember5 != $game_party.members[4].id if $game_party.members.size >= 5 refresh if @partymember6 != $game_party.members[5].id if $game_party.members.size >= 6 refresh if @partymember7 != $game_party.members[6].id if $game_party.members.size >= 7 refresh if @partymember8 != $game_party.members[7].id if $game_party.members.size >= 8 (...) end # update
And there I would have no idea how to implement that =P
Just replace the '6.times' in Admiralac's code with '$game_party.members.size.times'. That way it can't give you a NoMethod error, since it always takes the size of the party, not more, not less.

But I assume that the player needs to press a button or confirm on some party members before the party member formation changes, so why don't you add a single '@your_window.refresh' call in the method which actually triggers the formation change (the default method is called 'on_formation_ok', in case you use the default one)? That is the best option you have and you should do it like that.

Leave the update method to things which need constant updating (like the playtime, for example).

About that on-map menu thingy...

The map is the least optimized scene the engine has. Placing many new windows in it is generally a bad idea. Doing your whole menu on the map scene sounds a bit too much, especially if you do it because of some Map HUD elements only. You can always hide your HUD elements before the system takes the background screenshot, you can even get rid of that ugly and (very) time consuming blur effect if you want. Initialize a new map HUD in your main menu, add in the rest of your menu, and finally add in some new refresh methods for your "map HUD" if needed in the menu scene.

I did it like this to save every inch of FPS I could on the map scene. My game is using an ABS (with lotsa map HUD elements too), so it's mandatory for me to optimize the map scene as much as possible. 😛
Just replace the '6.times' in Admiralac's code with '$game_party.members.size.times'. That way it can't give you a NoMethod error, since it always takes the size of the party, not more, not less.
LOL that's right! =P

Just replace the '6.times' in Admiralac's code with '$game_party.members.size.times'. That way it can't give you a NoMethod error, since it always takes the size of the party, not more, not less.

But I assume that the player needs to press a button or confirm on some party members before the party member formation changes, so why don't you add a single '@your_window.refresh' call in the method which actually triggers the formation change (the default method is called 'on_formation_ok', in case you use the default one)? That is the best option you have and you should do it like that.

Leave the update method to things which need constant updating (like the playtime, for example).

kdZE0KB.png
Oh I see what you did there! I totally didn't thought about that! Yes, that's the simplest & best way.

So I wrote a small snippet that will do this:

class Scene_Menu < Scene_MenuBase def on_formation_ok if @status_window.pending_index >= 0 $game_party.swap_order(@status_window.index, @status_window.pending_index) @status_window.pending_index = -1 @status_window.redraw_item(@status_window.index) @celestiaactorswindow_window.refresh # Refresh Status Picture window else @status_window.pending_index = @status_window.index end @status_window.activate endendBy the way I want to ask: Is overwriting methods okay or I should simply edit the default one? I'm trying to avoid touching the default ones.
If you make your own scripts for your own personal use, it's okay to overwrite the default methods.

Just keep track of all of the methods you overwrote, in case you need to edit the same methods for something else.

And mind the placement of your overwrites on the script list. Generally, the safest method is to put all of your overwrites at the top, while the rest goes below them (the aliases and new methods).

And you are right. Do not edit the default methods directly. Well, you can, just make sure to add a very noticeable comment for every of your edits. That way, if you have some problems, you can search for those comments quickly and see if your edits are causing the problem or not.

I usually just write something like "- by Sixth" or "EDITED!!" (although the latter is not really unique 😛 ), and I only edit the defaults if it's just a one liner code modification. For bigger edits, always use overwrite (or alias if possible) in a new script slot.
But I assume that the player needs to press a button or confirm on some party members before the party member formation changes, so why don't you add a single '@your_window.refresh' call in the method which actually triggers the formation change (the default method is called 'on_formation_ok', in case you use the default one)? That is the best option you have and you should do it like that.

Leave the update method to things which need constant updating (like the playtime, for example).
That's what I said above.

I just didn't mention the on_something_ok method and those

I don't know why, I also use something like :

alias :kocka_random_alias_initialize_6V4n :initializeto make aliases unique.

Maybe that's not needed, but usually I use those.

And if you publishing the script, make sure you write which methods are aliased, and which are overwritten in a section usually called Compatibility, because if a script overwrites a method, all scripts that alias that method should be pasted BELOW it. But if two scripts are overwriting the same method, only one of them will work and that may cause bugs and crashes.

EDIT : But, if you want some more performance, you may want to, when your game is completed, remove all aliases and merge the methods if you know what I mean.

This way you would stop defining 1000 times the same class, aliasing same methods, adding same things...
Fun fact - I don't know how aliases work. (more or less I know, but not in details -- I mean how exactly it works - when to use etc.) --- It's the first time I'm seeing scripts (first saw / started using ~3 months ago)  so bear with me - I'm still a noob at this. =3

As for overwriting, actually I'm having all of this below any other scripts - my whole engine is on the bottom - to be sure it overwrites everything and puts my own stuff correctly.

And I don't need to keep track of edited methods - I have everything sorted - so it's not possible to edit the same method twice, unless it's done on purpose (such a draw_gauge [to make different sizes/colors and stuff for each gauge] etc.) =]

kdZE0KB.png


EDIT : But, if you want some more performance, you may want to, when your game is completed, remove all aliases and merge the methods if you know what I mean.

This way you would stop defining 1000 times the same class, aliasing same methods, adding same things...
Eventually, I'll comment things in base scripts and put some marks in it as Sixth suggested.

Thank you both for helping! =3
Well, alias is literally copying one method to other method, with another name.

Example is :

def a  p "A"endalias :b :aa # => "A"b # => "A"So, if you are aliasing a method, you copy the original contents, add your own content and overwrite the method with combination of those two.

If you are overwriting the method, any methods that were above in the same class with the same name will be overwritten, even if they were aliased methods.

That's why aliasing is better than overwriting (unless in the case you want to troll the fellow user).
And that is why overwrite should be above any aliases... There are cases that overwrite is needed, you can't do everything with alias, at least in the way RM was set up... One example is editing of make_damage_value, id you want to change how it's computed (especially if you want to remove some parts of it) you'll find it hard to use alias for that...

If you want to ad something, alias is good but if you need to remove something, alias is not what you need. It could be if the method is modular, but like in the case I cited, it ian't
Hmm... I see...

But I'm editing things, that I want to change completely - so I think overwriting will be better in this case. =P

Thanks for clarifying. =)
Take note though that if you have scripts that alias it, your overwrite should be above them
~ Or it will completely overwrite the aliased methods in scripts above and may cause crash and stuff?

I'm okay with that - I'm not using any menu scripts etc. so I'm editing that from let's say 'nothing' ~ and it's even better to overwrite things to make sure, there are no unwanted things from other scripts ~ but if there are important things, then I know that and I'm aware of this ~ so instead of overwriting ~ I'd simply edit that in the script, where it is aliased to avoid making multiple methods.
Yeah because overwrite will basically overwrite... If you're not using any script made by others you might be fine with just overwrites...

It probably wont crash, it will stop the other script from even running...

Example

class A alias watda wat def wat watda Your Stuff here endendclass A def wat Your stuff here endendThe second definition of method wat will overwrite any prior declarations of wat, which in turn means the alias before it will not run...Unless you're making a lot of changes to same methods, which would be easier to handle separately, thus a need for alias.

For us scripters, I think it's simply ingrained intp us to make even personal use scripts the same way we create our public scripts.

If ur gonna edit other peoples scripts, make sure you note the changes because you might forget that you edited it...
I'm editing everything all the time. xD

Don't worry, I'll be fine. =3

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