RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[SOLVED] need a little help with a bug in a script

0 Members and 2 Guests are viewing this topic.

***
Rep:
Level 81
Monster Hunter
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 for:
Code: [Select]
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   
« Last Edit: July 22, 2010, 11:30:38 PM by Mitsarugi »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
It's probably because you are transferring to a map for which you do not specify a switch.

***
Rep:
Level 81
Monster Hunter
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?

***
Rep:
Level 82
aka DigiDeity
I can offer you another vversion of this script:
Code: [Select]
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┤


***
Rep:
Level 81
Monster Hunter
I can offer you another vversion of this script:
Code: [Select]
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
Code: [Select]
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
« Last Edit: July 22, 2010, 01:16:32 AM by Mitsarugi »