The Netherlands
Seen 8 Hours Ago
Posted June 11th, 2020
6 posts
344 Days
Hello! I am quite new to making fan games, however I have some experience coding. Therefore I thought I would make an item as practice.
The item in question warps the player to a pre-determined location (for instance, back home or to a secret base kind of thing) and when used again it warps the player back to the location it was originally used. (Think something along the lines of the Explorer Kit from DPP).
It is not fleshed out much, no fancy animations or anything but it works well. For this item to function, 3 variables and 1 switch are used, of which the IDs can be edited to serve your need. The code can be found below and needs to be inserted into the PItem_ItemEffects script section.
Any suggestions or improvements to the code are welcome!

Spoiler:
ItemHandlers::UseInField.add(:WARPER,proc{|item|
# Names of variables used to store mapID and x,y pos before transport
   mapvar=29
   xvar=30
   yvar=31
# Switch number whether on destination or overworld
   onOff=60
# mapID and x,y pos of transport destination
   pocketmapID=33
   pocketmapX=10
   pocketmapY=10
   if pbBikeCheck 
     if $game_switches[onOff]==true
       $game_temp.player_new_map_id = $game_variables[mapvar]
       $game_temp.player_new_x      = $game_variables[xvar]
       $game_temp.player_new_y      = $game_variables[yvar]
       Kernel.pbCancelVehicles
       $scene.transfer_player
       $game_map.autoplay
       $game_map.refresh
       $game_switches[onOff]=false
     else
       $game_variables[mapvar]=$game_map.map_id
       $game_variables[xvar]=$game_player.x
       $game_variables[yvar]=$game_player.y
       $game_temp.player_new_map_id = pocketmapID
       $game_temp.player_new_x      = pocketmapX
       $game_temp.player_new_y      = pocketmapY
       Kernel.pbCancelVehicles
       $scene.transfer_player
       $game_map.autoplay
       $game_map.refresh
       $game_switches[onOff]=true
     end 
     next 1
   end
   next 0
})
Slowly gaining experience with Essentials
Scripting, eventing, mapping mostly
Seen 1 Day Ago
Posted 2 Days Ago
392 posts
4.1 Years
Very interesting!
I did a script similiar for the same item infact.

ItemHandlers::UseFromBag.add(:EXPLORERGEAR,proc{|item|
   if $game_switches[438]==true
     next 2
     pbUndergroundExit
     $game_switches[438]=false
     next 2
   elsif $game_switches[438]==false
     next 2
     pbUndergroundEnter
     Kernel.pbTransferUnderground(235,8,8)
     $game_switches[438]=true
   end
})
the transferUnderground bit does all the bits you have in your script there just seperately.
the enter and exit are just used to like the escape rope to decide where to go and no need to record it for variables.

really like the script though, works functionally the same and way more plug-and-play than my one