Re: Spike trap script help
Posted: Thu Apr 23, 2015 6:54 pm
<3 I'm still trying to figure that part out. I also realized last night that I'm probably making the code harder on myself than it actually needs to be. I don't really need to be spawning a spawner that spawns another entity that then is used to check where to teleport too. All I need to do is either spawn a spawner and use that or spawn the entity itself and use that. Also as I'm having the spawner activated on the pressure plates which are themselves always safe to land on; I can just destroy any entities of the same name at those locations and spawn a new entity at the parties location to teleport too. The teleporting itself is a completely separate function inside the script and needs only run when the party falls into the pit and that calls the teleport timer which calls back to the cleanup script after a delay. (to ensure the party gets successfully teleported before the teleporter is destroyed.) Which leaves me with this so far:
What I'm working on right now is finding the proper syntax to get the X, Y coordinates for the entity named "probe" in the targetX and targetY statements.
Code: Select all
function trapexit()
local safespots = {"dungeon_pressure_plate_1",
"dm_pressure_plate_1",
"dm_pressure_plate_2",
"dm_pressure_plate_3",
"dm_pressure_plate_4",
"dm_pressure_plate_5",
"dm_pressure_plate_6",
"dm_pressure_plate_7",
"dm_pressure_plate_8"}
local targetX = findEntity("probe", probe.X)
local targetY = findEntity("probe", probe.Y)
local targetFacing = party.facing
local teleportSuccess = false
for i #safespots, do
if i.name == "probe" then
i:destroy
spawn("spawner", party.level, party.X, party.Y, 0, "probe"):setSpawnedEntity("blocker")
else
spawn("spawner", party.level, party.X, party.Y, 0, "probe"):setSpawnedEntity("blocker")
end
end
end
function trapteleporter(teleport)
spawn("teleporter", party.level, party.x, party.y, 0 "teleport_destination"):setTeleportTarget(targetX, targetY, targetFacing)
teleport_timer:activate()
break
end
function tpCleanup()
findEntity("teleport_destination"):destroy()
end