I'll try that, thanks 🙂
Ruby/RGSSx questions that don't deserve their own thread
RGSSx Script SupportI've a question and am just curious, if there is a way for what I am looking for...
so, for a couple of sentences I wrote a vocab module where I write down all the things people say in my game, so I can edit/fix them in one place only!
now, some people should talk just random blabla, so it were nice if they have a pool of some sentences.
I tried to define in my vocab something like this: RANDOM_1 = "blabla", RANDOM_2 = "other bla", RANDOM_3 = "more bla" ...
and then if I want to talk to a stranger, the event first set a variable to a random number between 1 & 3 and then I make a string text with "RANDOM_" + variable.to_s
but unfortunately the message box just prints RANDOM_1 or RANDOM_2 ... is there a way to achieve this when I have a string variable to get the vocab text? or do I have to make switch cases just like everyone else?
so, for a couple of sentences I wrote a vocab module where I write down all the things people say in my game, so I can edit/fix them in one place only!
now, some people should talk just random blabla, so it were nice if they have a pool of some sentences.
I tried to define in my vocab something like this: RANDOM_1 = "blabla", RANDOM_2 = "other bla", RANDOM_3 = "more bla" ...
and then if I want to talk to a stranger, the event first set a variable to a random number between 1 & 3 and then I make a string text with "RANDOM_" + variable.to_s
but unfortunately the message box just prints RANDOM_1 or RANDOM_2 ... is there a way to achieve this when I have a string variable to get the vocab text? or do I have to make switch cases just like everyone else?
Supposing you have 5 party members and went into battle, how would I know in battle who are those members that isn't included in the battle (the 5th actor). I would like to do something about that actor. I just want to know how to check and keep track of those party members that are currently not participating in battle.
@Milena
$game_party.members will return all party members.
$game_party.battle_members will return only the ones participating in battle.
@Venka
Since I always work on a very old laptop, I can say for sure that it will make a difference if you add some update method without a condition. On better PCs, there might be no difference, but on older ones, it might just kill the FPS from 30 to 10-15.
And really, there is no reason to not add a condition. It is 1 or 2 more lines, and saves your game's FPS, so conditions should be used all the times in update methods, in my opinion.
@FeaR616
I don't know how you have setup your module, but I would do it like this:
So you can call that method where you want, pass a valid key to it from the Texts setup, and the returned text will be a random one from the specified Texts setup. After this, you can use the randomized text for whatever you want.
I think you can use that method above like this:
Make that new method in Game_Interpreter.
In the event commands, add a script call which looks like this:
$game_variables[id] = randomtextmethod(key)This will store a random text in the selected variable.After this, make a show message command with this:
\V[id]And this should display the random text from the module.I did not test this yet thought.
$game_party.members will return all party members.
$game_party.battle_members will return only the ones participating in battle.
@Venka
Since I always work on a very old laptop, I can say for sure that it will make a difference if you add some update method without a condition. On better PCs, there might be no difference, but on older ones, it might just kill the FPS from 30 to 10-15.
And really, there is no reason to not add a condition. It is 1 or 2 more lines, and saves your game's FPS, so conditions should be used all the times in update methods, in my opinion.
@FeaR616
I don't know how you have setup your module, but I would do it like this:
module CustomVocab Texts = { :key1 => ["text1","text2","text3"], :key2 => ["text4"], :key3 => ["text5","text6"], :key4 => ["text7","text8","text9","text10"], # and so on... } end def randomtextmethod(key) # <--\ # the key argument is a valid key from the Texts setup in the CustomVocab # getting the max value for the selected text array. size = Texts[key].size # <--/ # randomizing the result with a simple rand call. result = rand(size) # <--/ # returning the random text from the text array. return Texts[key][result] # <--/ end
I think you can use that method above like this:
Make that new method in Game_Interpreter.
In the event commands, add a script call which looks like this:
$game_variables[id] = randomtextmethod(key)This will store a random text in the selected variable.After this, make a show message command with this:
\V[id]And this should display the random text from the module.I did not test this yet thought.
@Venka:
I can't tell for sure, but I didn't experience a great difference between setting the y-coordinate of a sprite each frame and setting another random variable. I suppose sprites are redrawn every frame regardless of if their position has changed anyway (but again, that's a guess).
@Milena:
If I remember correctly, you can use an event to assign the actor ID of a certain party member to a variable.
Instead of $game_party.members you should probably use $game_party.all_members , since members are equivalent to battle_members while in battle.
I can't tell for sure, but I didn't experience a great difference between setting the y-coordinate of a sprite each frame and setting another random variable. I suppose sprites are redrawn every frame regardless of if their position has changed anyway (but again, that's a guess).
@Milena:
If I remember correctly, you can use an event to assign the actor ID of a certain party member to a variable.
Instead of $game_party.members you should probably use $game_party.all_members , since members are equivalent to battle_members while in battle.
Hmm that could work, but specifically, how can I tell who those not participating people are? Say in battle, I have Eric, Natalie, Terence and Ernest...I have Ryoma on the side, since the maximum actors I can have in battle is 4. How would I know specifically that Ryoma is there as a reserve? That is because I want to give him a state while he is a reserve.
@Milena: since you can check who is in battle with $game_party.members or $game_party.battle_members and you can check all party members with $game_party.all_members ...
I would suggest to compare the actor ID's of both and one should be left, this is the member which is not in battle... at least this is what I would try first. I am sure, there is a better way. ^^"
@sixth: well, nice! thank you. the thing with the keys is still a bit new to me, so I don't think of them often, but for this case they are just perfect!!
and yeah, I wrote some additional functions in game interpreter to achieve exactly that! ^^
this are methods where I can put text as parameter or text and file name and alignment flag to show message boxes without or with busts on left or right side, very simple, but efficient while working on game. =)
I would suggest to compare the actor ID's of both and one should be left, this is the member which is not in battle... at least this is what I would try first. I am sure, there is a better way. ^^"
@sixth: well, nice! thank you. the thing with the keys is still a bit new to me, so I don't think of them often, but for this case they are just perfect!!
and yeah, I wrote some additional functions in game interpreter to achieve exactly that! ^^
this are methods where I can put text as parameter or text and file name and alignment flag to show message boxes without or with busts on left or right side, very simple, but efficient while working on game. =)
Try it like this:
Code:
$game_party.all_members do |member| if !$game_party.battle_members.include?(member) # do the stuff here, like member.add_state(state_id) endend
So, I tried this to test...
class Scene_Battle < Scene_Base alias milena_update_reserve update #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update milena_update_reserve $game_party.all_members do |member| if !$game_party.battle_members.include?(member) puts member.id member.hp += 10 member.tp += 10 else puts member.id end end endendand somehow, Ryoma, who is #5 in my party isn't being healed....
class Scene_Battle < Scene_Base alias milena_update_reserve update #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update milena_update_reserve $game_party.all_members do |member| if !$game_party.battle_members.include?(member) puts member.id member.hp += 10 member.tp += 10 else puts member.id end end endendand somehow, Ryoma, who is #5 in my party isn't being healed....
Is the text on the console showing the correct IDs?
I am not sure how would your code work if the battler who you try to heal isn't even in your active party.
But, did you tried it with this method?
member.change_hp(value, enable_death)This is the default method used with event commands.Following through the method calls from that one, you will see that the member who's HP was changed will get refreshed after the change. So, the member need to be refreshed after any HP/MP/TP change.
Try it with the above method, that one will refresh the actor automatically.
What you did (if it works) will be executed every single frame in the battle. So that means 60x10 HP in every second, which is 600... Is that really what you want? 😀
You could add in a check for example:
if Graphics.framecount % 600 == 0 # do the above code hereendThis will make the HP/MP change after every 10 seconds only, and not constantly.Btw, how do you see your not active battlers in the battle anyway? o.o
I am not sure how would your code work if the battler who you try to heal isn't even in your active party.
But, did you tried it with this method?
member.change_hp(value, enable_death)This is the default method used with event commands.Following through the method calls from that one, you will see that the member who's HP was changed will get refreshed after the change. So, the member need to be refreshed after any HP/MP/TP change.
Try it with the above method, that one will refresh the actor automatically.
What you did (if it works) will be executed every single frame in the battle. So that means 60x10 HP in every second, which is 600... Is that really what you want? 😀
You could add in a check for example:
if Graphics.framecount % 600 == 0 # do the above code hereendThis will make the HP/MP change after every 10 seconds only, and not constantly.Btw, how do you see your not active battlers in the battle anyway? o.o
Somehow, the code you gave me is missing an each keyword. I was able to fix it and it works now, Sixth, thanks! Somehow I still don't understand how the frame count works, I'll add it in the place I want now. I placed it in the update just to see if it works or not 😀
I edited the script and made an alternative to make them healed.
I don't see my inactive battlers, I just want them there as a reserve and get healed when they're outside the battle.
I edited the script and made an alternative to make them healed.
I don't see my inactive battlers, I just want them there as a reserve and get healed when they're outside the battle.
Ahh, yeah, it seems I forgot to add that 'each' at the end, lol. 😀
@Sixth: I tested it today, modified it only a bit (return no text and store nothing in variable, show message box directly with random text) and it works like a charm!
thank you so much!!
thank you so much!!
Milena, if you KNOW there are 5 party members (Control Variables to get party size, or just use $game_party.all_members.size), you can do $game_party.all_members[4] (remembering the first will be at index 0) to give you the 5th actor. That will be the actor object, not just the id. So you could do this in a script call:
Code:
if $game_party.all_members.size > 4 reserve = $game_party.all_members[4] reserve.add_state(id)end
I have a problem drawing the names of the battle members correctly on a window. I do it this way:
$game_party.battle_members.each do |mem| draw_text_ex(x, 10, mem.name)endbut they become cluttered. I want them to be displayed in 1 column like this:
Eric
Natalie
Terence
Ernest
But somehow I am missing something big here. Care to explain what could be wrong?
$game_party.battle_members.each do |mem| draw_text_ex(x, 10, mem.name)endbut they become cluttered. I want them to be displayed in 1 column like this:
Eric
Natalie
Terence
Ernest
But somehow I am missing something big here. Care to explain what could be wrong?
Your current method draws them on the same place... You need to adjust the y, something like
Code:
$game_party.battle_members.each do |mem| draw_text_ex(x, 10*$game_party.battle_members.index(mem), mem.name)end
It works fine, but it repeats it over and over. I only have Eric and Natalie, but it shows me:
Eric,
Natalie,
Eric
Natalie
Eric,
Natalie,
Eric
Natalie
You could try:
Code:
$game_party.battle_members.each do |mem| next if mem.nil? draw_text_ex(x, 10*$game_party.battle_members.index(mem), mem.name)end
Show us what you're wrapping that command in. Sounds like you have a loop of some sort. It shouldn't repeat them with just that bit of code.
I am wrapping the command in the refresh method of my new window, actually.
This is how I make it as a representation:
This is how I make it as a representation:
Code:
class Window_Actors < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, window_width, fitting_height(1)) refresh end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh contents.clear $game_party.battle_members.each do |mem| draw_text_ex(x, 10*$game_party.battle_members.index(mem), mem.name) end endend
Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/