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

awesome, just what I needed. thanks Shaz~
I created an instance variable in Game_BattlerBase and initialized in the initialize method but when i try to use it from Game_Battler it says it's not a part of the class
 

Code:
class Game_BattleBase  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_reader   :cd                           # CoolDown  attr_accessor   :lskills                      # Skills learnable    #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    @hp = @mp = @tp = 0    @cd = @lskills = []    p self.learnings    self.learnings.each_with_index do |learning, id|      @lskills += [$data_skills[learning.skill_id]]      @cd += [0]    end    @hidden = false    clear_param_plus    clear_states    clear_buffs    super  end...

Code:
  ...  #--------------------------------------------------------------------------  # * Initialize CD  #--------------------------------------------------------------------------  def init_cd    self.lskills.each do |skill|      self.cd = 0,skill    end  end...
Put a super in the initialize method.

Edit: I mean in Game_Battler by the way, not Game_BattlerBase.
I re-wrote it and added this (to Game_BattlerBase) but it says undefined method lskills

Code:
...  #--------------------------------------------------------------------------  # * Change CoolDown  #--------------------------------------------------------------------------  def cd=(cd, skill)    if @lskills.include?(skill)      @cd[@lskills.index(skill)] = [[cd, max_cd(skill)].min, 0].max    end  end...
Make sure you aren't calling your init_cd method before @lskills is initialized.
that is what i'm seeing as the problem but then how do i get it to initialize Game_BattlerBase before the start of battle?

EDIT

I just ran it on a clean file and it initializes a Game_BattlerBase when you click new game and two more when you get into a fight with two enemies and then initializes three instances of Game_Battler but when i run my own code i never creates instances of Game_Battler any ideas why?
If your code is exactly as you have posted here, you have not added it to Game_BattlerBase. You have added it to Game_BattleBase.


Look closely - check your spelling.
Wow... thanks xD
Another question, I remember the system in Breath of Fire 4 wherein there is a Group Inventory. When the game shifts from the perspective of Fou-Lu to Ryu, both of them has their own individual inventory. It means that if Fou-Lu is the current character, he has his own items you gain and carry, if its Ryu and his friends, then you have items for them.

Is there a way to do this as well?
Did you search the scripts to see if something like this already exists? I'd be surprised if it doesn't.
Is there a script call for the "Jump to Label" function? I'd like to be able to jump to labels based on the contents of a variable. Thanks for your great help on this forum, oh awesome-r and smarter-er than me people.

EDIT: Well I found this in Game_Interpreter, but I'm not sure how to use it. (Ignorance, at least in this case, is not always bliss)

def command_119

    label_name = @params[0]

    @list.size.times do |i|

      if @list.code == 118 && @list.parameters[0] == label_name

        @index = i

        return

      end

    end

  end

 

Am I close?
Unfortunately, just using the code as presented in the interpreter doesn't work. I tried this a while ago and had to resort to something a bit uglier.

This did the trick for me, but someone else might be able to make a nicer one:

Code:
  #--------------------------------------------------------------------------  # * Jump to Label  #--------------------------------------------------------------------------  def command_119    # Shaz - @temp_label is used for a dynamic label    label_name = @temp_label.nil? ? @params[0] : @temp_label    @temp_label = nil    @list.size.times do |i|      if @list[i].code == 118 && @list[i].parameters[0] == label_name        @index = i        return      end    end  end
Then in your event code:
Code:
Script: @temp_label = "label" + $game_variables[1].to_sJump to Label: xxxLabel: label1...Label: label2...Label: label3
The Jump to Label: xxx can be anything - if @temp_label has been populated, whatever you put in here will be ignored and whatever you set in the script call will be the label used. Make sure, if the Script call goes over 2 lines, that the break is in the correct place (after the + is a good spot).
Here's my solution for label jumping. Rather than messing around with the built-in command I just introduce a new one as a script call

http://forums.rpgmakerweb.com/index.php?/topic/11655-jump-to-label
Dear Godly Blue-Squirrel-with-Acorn:

 

Thank you for your help with this. Blushing aside, I'm not exactly sure what to do with your script snippets. Should I be overwriting the bit in Game_Interpreter with your first bit? And then naming my labels label1, label2 . . . labeln? And then use your second bit in a script call, adjusting what again? I'm not sure if I get your meaning.

 

Let's say I've got the following labels: "label1" "label2" and "label3". Let's say the dynamic variable is $game_variables[5].

What would the script call look like? What would I do?

 

Thatnks for being patient with a dude still new, but actively learning to understand Ruby. I tried to test it a couple of ways before pestering you; I got an syntax error in Game_Interpreter line 1413: unexpected ':', expecting $end Label: label1.

 

Tsukihime: That's a good workaround in the future for when I've gotta use script calls for jumping to a specific label. Thanks for the help. I think I'm looking more to something that'll help me avoid recopying and editing (and most likely re-changing) gads of jumpto's and other bits.

 

It's really nice of y'all to help me to pare down my eventing like this!

 

This'll teach me to ask a question with little hope of understanding the answer.
You don't need to change existing labels. The built-in label jumping command still works as usual.

Unless you mean you already have a bunch of label jump commands with variable designation set up.
Thanks for the help, everyone. I'm in a good place with this now.

I'm thinking I understand, Tsukihime--I sent you a pm, just to try to clarify things. Shaz, I'm gonna keep working on it--I'll be in touch.
Tsukihime's solution is a more elegant one than mine. I suggest you use his little script (which is an addition, not a replacement). It's also easier to do the actual call than the method I use.
I am using Vlue's basic day/night clock script, and I can't seem to figure out how to make the starting time of the game morning its always

midnight which is bothersome.
Dunno if this is what you're looking for, but you can change the game time by calling the script $game_time. So, for example, to set the clock to 6:00 AM you could use the event script call: $game_time = 360. Will that do you?
No but I figured it out anyway from that.

Line 89: $game_time = 0

Just changed the 0 to 360 and the game starts off at 6. My mistake was that I set it to 6 thinking it was the quick thing like when scripting in conditional branches.

Not the number of frames, but still your post gave me the idea so thank you.

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