Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Strange behavior RGSS
#1
Today this strange thing happened to me.
I was testing the 2.12 version of my BS, where I had just added a few features, and I discovered that the interpreter that runs common events called by executed skills was running an instruction two times, the second one causing an error btw.
Other instructions were executed once, I tried putting something before and something after that instruction.
It was a script call to $scene.switch which is a method I defined. It is there since version... I don't know, but it's not new and it was not changed recently.
Guess what? The problem was solved by putting a return instruction at the end of that method...

I'm confused...
Reply }
#2
What is the line before that return command? (Or line before that if it's an 'end')
Reply }
#3
Well, here's the whole method
Code:
def switch()
    # Remove the sprite
    party_position=$game_party.remove_switched_actor(@active_battler.id)
    @spriteset.remove_sprite_in_pos(party_position)
    # Add the actor
    $game_party.add_switched(@switch_id, party_position)
    sprite=@spriteset.add_sprite_in_pos(party_position)
    sprite.animation($data_animations[SWITCHED_ACTOR_ANIMATION_ID],true) unless SWITCHED_ACTOR_ANIMATION_ID==nil
    @status_window.refresh
    return
  end

Thanks for your interest in this strange case. :)
Reply }
#4
Sounds like @status_window.refresh returned something odd
Try putting p @status_window.refresh ^^
Reply }
#5
def switch() <-- why the ( and ) ?
Reply }
#6
Zeriab Wrote: Sounds like @status_window.refresh returned something odd
Try putting p @status_window.refresh ^^
It returns false.
p @status_window.refresh works (without the return) as the return value becomes that one of p, I guess.

It's switch() because I like consistency and switch seems odd to me... personal taste of someone who usually programs in C/C++.
Reply }
#7
There's your reason.
Returning false has a special meaning in call scripts.
Reply }
#8
Code:
# If return value is false when trying to execute event command
      if execute_command == false
        return
      end
      # Advance index
      @index += 1

This is at the end of a loop in the Interpreter::Update method... I guess that's what you're talking about.
Ok, it remains to figure out what I changed to make this happen only now...

Anyway, a return does not cost that much... :D
Reply }
#9
You added a return statement which returns nil rather than false.
Reply }
#10
Yes, now I know.
I meant, what did I do before when the problem started to happen?
I must have changed something in that refresh method that I don't remember and that caused it to return false, and then caused switch itself to return false to the interpreter.
But I'm too busy with other things to investigate.

I appreciate your help Zeriab, thanks.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   RGSS scripting dissections and explinations Siletrea 97 87,760 03-18-2019, 06:46 AM
Last Post: Siletrea
   Help iwth script (RGSS Player crash) Whisper 3 6,383 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,280 11-03-2015, 06:16 AM
Last Post: kyonides
Question  RGSS stoped to work Chaos17 5 6,758 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   Ruby, RGSS & General Code Discussion Kain Nobel 6 9,704 12-22-2012, 05:11 AM
Last Post: MechanicalPen
   [Request] Tut. for RGSS Eldur 9 10,345 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   Strange Game_Enemy#actions iteration bug Kain Nobel 4 6,261 06-15-2011, 07:21 PM
Last Post: Charlie Fleed
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 3,795 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Quick RGSS question - switches Ravenith 2 5,039 08-23-2009, 11:23 AM
Last Post: Ravenith
   How can i activate switches with rgss computerwizoo7 2 6,815 07-04-2009, 03:01 AM
Last Post: computerwizoo7



Users browsing this thread: