-- player_gate_path - Logic to path to and travel through a gate -- (component of worldgate) -- Template attachment: player -- Created by: Patrick Ferland -- Created on: 08/06/2008 -- Revision History -- 08/06/2008 P.Ferland - New script -- Constants WEB_SERVER_BASE = 'http://alpha.metaplace.com/' GATE_RANGE = 3.0 -- Script Properties Define Properties() world_gate_target_id = 0 end -- Commands -- no commands -- Triggers Trigger world_gate_goto(gate) self.world_gate_target_id = gate.id self.speed = self.walk_speed PathToLocation(self, gate.x, gate.y) end Trigger path_end(x, y) if (self.world_gate_target_id == 0) then -- If we have no target gate, then these aren't the droids you're looking for. Move along. return end local world_gate = GetObjectById(self.world_gate_target_id) if (world_gate == nil) then -- If the target gate no longer exists, then clear it and quit self.world_gate_target_id = 0 return end local dx = x - world_gate.x local dy = y - world_gate.y if ( (dx * dx + dy * dy) <= (GATE_RANGE * GATE_RANGE) ) then -- If we pathed within the gate's use range, use it use_gate(self, world_gate) else -- If we did not path to the gate, then clear our current target gate self.world_gate_target_id = 0 end end -- Local functions function use_gate(self, gate) local url = WEB_SERVER_BASE .. gate.worldgate_target .. '/play' UserGotoUrl(self, url) end