[Solved]Undefined method in a little ass script

Started by MetalZelda, August 24, 2014, 11:17:00 am

Previous topic - Next topic

MetalZelda

August 24, 2014, 11:17:00 am Last Edit: August 24, 2014, 04:22:11 pm by MetalZelda
HelHoy

So I was messing around to make a little script that can handle a sound effect and a character sprite looping in a certain case.

The sprite mechanism works well, but the sound effect is a mess to do, it always return an error (Undefined method '+' for Nil nilclass) and the error is pointing this certain code  (@waitcount_se += 1)

#===============================================================================
# ■ LOW_LIFE_ANIMATION
#===============================================================================
#If Link's HP is under 40 (1 heart), change his charset if he's not moving after 15 frames
module LOW_LIFE_ANIMATION
 #Suffix of the spriteset
 LOW_LIFE = "_LOWANI"
 #Wait count when he's standing still and seems hurt
 WCOUNT = 15
 #Here, add the sound when Link is suffering
 SE = RPG::AudioFile.new('Link_Huff1', 100)
 
#--------------------------------------------------------------------------
# ● Sound effect initialize - FAULTY
#--------------------------------------------------------------------------  
 alias lowlife_setup_init initialize unless $@
 def initialize
@waitcount_se = 0
lowlife_setup_init
 end
#--------------------------------------------------------------------------
# ● Character Name
#--------------------------------------------------------------------------                                  
 def character_name
   filename = super
for i in 0...$game_party.actors.size
   actor = $game_party.actors[i]
   if @breakacting and not $game_system.map_interpreter.running? & if actor.hp * 100 / actor.maxhp <= 40
      new_name = filename + LOW_LIFE
      filename = new_name if RPG_FileTest.character_exist?(new_name)
   end
end
end
   return filename
 end

#--------------------------------------------------------------------------
# ● Breakact
#--------------------------------------------------------------------------                                
def breakact=(b)
    @breakacting = b
    @step_anime  = b
end

#--------------------------------------------------------------------------
# ● Update  
#--------------------------------------------------------------------------
alias idontknow_update update unless $@
 def update
     super
     if controllable?
        if @breakact_count.to_i > 0
           @breakact_count -= 1
        else
           self.breakact = true
        end

#################################" Faulty
@waitcount_se += 1
if @waitcount_se > WCOUNT
@waitcount_se = 0
end
 if @step_anime and @waitcount_se = 14
Audio.se_play("Audio/SE/" + LOW_LIFE_ANIMATION::SE, 100, 100) rescue nil
end
##################################"
     else
       @breakact_count = WCOUNT
       unless self.action != nil or $game_map.starting? or
              self.knockbacking?
              self.breakact = false
       end
     end
 idontknow_update
 end
end


#===============================================================================
# ■ Game_Player < Game_Character
#===============================================================================
class Game_Player < Game_Character
     include LOW_LIFE_ANIMATION
end

#===============================================================================
# ■ Game_Player
#===============================================================================
class Game_Player < Game_Character
 
#--------------------------------------------------------------------------
# ● Controllable?  
#--------------------------------------------------------------------------                          
 def controllable?  
     return false if @actor == nil
     return false if moving?
     return false if @move_route_forcing or $game_temp.message_window_showing
     return false if $game_system.map_interpreter.running?
     return false if self.action != nil
     return false if self.battler.stop
     return false if @character_name != @actor.character_name
     return false if terrain_tag == XAS::FALL_TERRAIN
 return false if terrain_tag == XAS::SWIMMING_TERRAIN
 for i in 0...$game_party.actors.size
 actor = $game_party.actors[i]
 return false if actor.hp * 100 / actor.maxhp > 40
 end
     return true
 end
end

$LOW_LIFE_ANIMATION = true


I don't know what I fucked up here ...

KK20

I'd suggest reading over your script again. You have a lot of syntax mistakes such as using one & when you should be using && or 'and'. You also have too many 'end's for def character_name.

Also, is the alias for initialize even necessary?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

MetalZelda

Quote from: KK20 on August 24, 2014, 04:04:04 pm
I'd suggest reading over your script again. You have a lot of syntax mistakes such as using one & when you should be using && or 'and'. You also have too many 'end's for def character_name.

Also, is the alias for initialize even necessary?


Hmmm, yes, there was it and den ...

THANKS <3

The alias, meh, I was following some RGSS tutorial claiming that it's a plus to put them ... So I did it ...

Solved :)