Main Menu
  • Welcome to The RPG Maker Resource Kit.

[SOLVED] need a little help with a bug in a script

Started by Mitsarugi, July 13, 2010, 10:04:57 PM

0 Members and 1 Guest are viewing this topic.

Mitsarugi

i asked a friend on a french site to make this for me it's a script that auto-activates a switch on a certain map and
auto-deactivates it leaving the map
now the bug i have is when leaving the map i'm on it says there's an error in Game_Switches
this lign: if switch_id <= 5000

the error is '<='

script:
[spoiler]class Scene_Map < Scene_Base
   
    alias new_update update
    alias new_update_transfer_player update_transfer_player
   
LISTE_MAP = {
1 => 65,
2 => 24,
3 => 64,
4 => 62
}
  def update
    new_update
    $game_switches[LISTE_MAP[$game_map.map_id]] = true
  end

  def update_transfer_player
    $game_switches[LISTE_MAP[$game_map.map_id]] = false
    new_update_transfer_player
  end
   
end   
[/spoiler]

modern algebra

It's probably because you are transferring to a map for which you do not specify a switch.

Mitsarugi

Quote from: modern algebra on July 13, 2010, 10:08:19 PM
It's probably because you are transferring to a map for which you do not specify a switch.
but what if i don't want a switch for that map?

Deity

I can offer you another vversion of this script:
MAP_LIST = {
#Mapid => Switchid
1 => 2,
2 => 3,
3 => 4,
}
class Scene_Map
  alias update_auto_Switches_at_maps update_transfer_player unless $@
  def update_transfer_player
    for i in MAP_LIST.keys
      if i == $game_map.map_id
        $game_switches[MAP_LIST[i]] = true
      else
        $game_switches[MAP_LIST[i]] = false
      end
    end
    update_auto_Switches_at_maps
  end
end


Deity
Greetings
DigiDeity


├Work┤
├Contact┤


Mitsarugi

#4
Quote from: Deity on July 20, 2010, 06:47:15 PM
I can offer you another vversion of this script:
MAP_LIST = {
#Mapid => Switchid
1 => 2,
2 => 3,
3 => 4,
}
class Scene_Map
  alias update_auto_Switches_at_maps update_transfer_player unless $@
  def update_transfer_player
    for i in MAP_LIST.keys
      if i == $game_map.map_id
        $game_switches[MAP_LIST[i]] = true
      else
        $game_switches[MAP_LIST[i]] = false
      end
    end
    update_auto_Switches_at_maps
  end
end


Deity


really nice of you Deity , thanks a lot ^^
could i request a script if i ask you?


EDIT: this is what Mithran made
class Game_Map
  SWITCH_BINDINGS = {
  # map_id => switch_id
  48 => 100
#~   2 => 24,
#~   3 => 64,
#~   4 => 62
  }

  alias setup_orig_bind_switch_to_map setup
  def setup(map_id)
    $game_switches[SWITCH_BINDINGS[@map_id]] = false if SWITCH_BINDINGS.include?(@map_id)
    $game_switches[SWITCH_BINDINGS[map_id]] = true if SWITCH_BINDINGS.include?(map_id)
    setup_orig_bind_switch_to_map(map_id)
  end
end