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

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
I thought it wouldn't hurt. I mean, one is "I'm having trouble with this script and have no idea why it doesn't work, would someone give me a bit of help?", while the other is "I'm having truble with this small bit of the script but know what doesn't work, but not how to fix it"...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
And it's okay that you thought that. But we're telling you that it needs its own thread (or to go in the same one you've already started). I don't really want to use mod text.
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
The dreaded blue text of death...
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Yeah, yeah, already posted this question on my original thread, thankfully it already had passed 72 hours.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
How does custom formula work and how do they get evaluated?
 

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
They are evaluated using "Krenel.eval" as ruby code, in the context of the calling instance of RPG::UsableItem::Damage. The user, target, and $game_variables array are passed as local variables a, b, and v, respectively. The evaluate is wrapped in a rescue so if it fails due to a StandardError, the result will be returned as 0, otherwise, the result will be the calculation of the formula provided. Look at RPG::UsableItem::Damage in the help file. See also: http://ruby-doc.org/core-1.9.3/Kernel.html#method-i-eval
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
I am sure I seen a 'better' eval method for the battler eval. I cant remember what exactly made it 'better' but apparently it was :/
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Ok, I think this is a small one:

how do I make a variable (just true/false) that can be checked/changed by other classes/modules without making them inherited?
everytime I try it gives me an error of "undefined method"

[EDIT] Nevermind, used a global variable for that
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
attr_accessor :variable_name def initialize_class  @variable_name = falseend
I dont understand why any other class would need to inherit that other than the one you use it in and maybe its children...
 

SoulPour777

Crownless King
Veteran
Joined
Aug 15, 2012
Messages
1,093
Reaction score
104
First Language
English
Primarily Uses
N/A
Does anyone know why level stays undefined on this code?

class Game_Party alias :soulpour_average_actor_level_add_actor :add_actor #-------------------------------------------------------------------------- # * Add an Actor #-------------------------------------------------------------------------- def add_actor(actor_id, average = false) if average actor = $game_actors[actor_id] @level = 0 for i in 0..$game_party.members.size @level += $game_actors[$game_party.members.id.level] end @level = @level / $game_party.members.size actor.level = @level end soulpour_average_actor_level_add_actor end endclass Game_Actor attr_accessor :level alias ga :initialize def initialize(actor_id) ga(actor_id) @level = 0 end endclass Game_Interpreter def add_init_actor(id) $game_party.add_actor(id, true) endend 

AFAIK, I correctly added the level and a new argument called average = false for the script to recognize my new function. The purpose I was trying to recreate is that shouldn't the level be not initialized when added? For example, Eric and Ernest is Level 10. I added Natalie using my script call, instead of Natalie being Level 1 naturally, anyone in the scope of the script call, should be automatically Level 10.
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
dunno, maybe something in the orig add_actor method is overwriting it?

anyway, you can use other means to get the average level...

class Game_Party def member_level_avg members.compact.inject(1) { |r, i| r += i.level } / members.size endendMaybe it would be best to just add the actor and then level them up without showing the level up info... ?
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
attr_accessor :variable_name def initialize_class  @variable_name = falseendI dont understand why any other class would need to inherit that other than the one you use it in and maybe its children...
it was a variable of a battle script I made that needed to check the variable in both the Scene_Battle class and BattleManager module (and change it's value in Scene_Battle).

I made it into a global variable and it started working, but if you have another idea, the better.

And yes, already tried that you wrote...
 

SoulPour777

Crownless King
Veteran
Joined
Aug 15, 2012
Messages
1,093
Reaction score
104
First Language
English
Primarily Uses
N/A
dunno, maybe something in the orig add_actor method is overwriting it?

anyway, you can use other means to get the average level...

class Game_Party def member_level_avg members.compact.inject(1) { |r, i| r += i.level } / members.size endendMaybe it would be best to just add the actor and then level them up without showing the level up info... ?
thanks for the average level snippet. The only problem now is that I am torn between add_actor function and the level_up function. So basically, if I use the add_actor, my problem is to check the level, since whenever I do actor_id.level = $game_party.member_level_avg it just returns me an error, so i have to redefine level on Game_Party, while on level_up, the thing I need to determine would be getting the id of the actor that would level up (which is basically the actor I add).
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
...I made it into a global variable and it started working, but if you have another idea, the better....
Global variables can usually be avoided. Unless you really really need one, you shouldnt use one.

@SoulPour -

Why not just make a new method for adding actors... something like...

Code:
def add_soul_actor(actor_id,level=members_level_avg)  add_actor(actor_id)  level.times {  members.last.level_up }end
 

SoulPour777

Crownless King
Veteran
Joined
Aug 15, 2012
Messages
1,093
Reaction score
104
First Language
English
Primarily Uses
N/A
lol of course, that would have been much easier, as well as I can tinker around it for more. Thanks for the help.
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
it may be a bit stupid of my part, but I think the batle infobox goes too fast.
how do I make it wait longer?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
SoulPour:

Code:
$game_actors[$game_party.members[i].id.level]
Code:
$game_actors[$game_party.members[i].id].level
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
lol seems so obvious now...

Good find ^_^
 

SoulPour777

Crownless King
Veteran
Joined
Aug 15, 2012
Messages
1,093
Reaction score
104
First Language
English
Primarily Uses
N/A
lol why didn't I saw that. Thanks Shaz, that works easier.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
In fact, why don't you just use

$game_party.members.levelsince these lines will both give you exactly the same object:

$game_party.members$game_actors[$game_party.members.id]$game_party.members is an array of actors$game_actors is an array of actors

The second line is just saying "get the id of this actor object, then get the corresponding actor object (which you've already got) from the actor array, and then get the id (which you just started with) from that actor object"
 

Users Who Are Viewing This Thread (Users: 0, Guests: 3)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top