Okay I have to admit that this section of code appears to be well beyond me.
last_plate = {}
function setLastPlate(caller)
if party.x == caller.x and party.y == caller.y then --filters plates activated by monsters.
last_plate = {caller.x, caller.y, party.facing, caller.level}
print(unpack(last_plate)) --delete line when finished
end
end
I get what it's trying to do, but I'm failing at seeing how I can actually use it as I cannot seem to reference last_plate to the teleporter script at all.
Code: Select all
spawn("teleporter", party.level, party.x, party.y, 0, "teleport_destination"):setTeleportTarget(caller.x, caller.y, party.facing, caller.level)
returns a 'got nil' error on the setTeleportTarget and
Code: Select all
spawn("teleporter", party.level, party.x, party.y, 0, "teleport_destination"):setTeleportTarget(last_plate)
returns a 'number expected got table' error on setTeleportTarget as well. None of this is the most frustrating part though. If I make the coordinates static like this:
Code: Select all
spawn("teleporter", party.level, party.x, party.y, 0,"flytosafety1"):setTeleportTarget(12, 11, party.facing, 1)
I get a 'duplicated entity id' message which I can fix by removing the static name but prevents me from destroying the teleporters via a destroy script. To top it off it appears that the teleporter is also triggering on closed pit traps which it shouldn't because it's only supposed to be called after the isOpen:() comes back true; it's also preventing the damage from going through. So yea.... problems galore right now and simplifying the script down doesn't seem to be helping.
Code: Select all
function pittraps()
local deathpits = {"dungeonpit1",
"dungeonpit2",
"dungeonpit3",
"dungeonpit4",
"dungeonpit5",
"dungeonpit6",
"dungeonpit7",
"dungeonpit8",
"dungeonpit9",
"dungeonpit10",
"dungeonpit11",
"dungeonpit12",
"dungeonpit13",
"dungeonpit14",
"dungeonpit15"}
for i=1, #deathpits do
local deathpit = findEntity(deathpits[i])
if deathpit:isOpen() then
damageTile(deathpit.level, deathpit.x, deathpit.y, 0, 6, "poison", 10)
spawn("teleporter", party.level, party.x, party.y, 0,"flytosafety1"):setTeleportTarget(12, 11, party.facing, 1)
end
end
end
Also returned a "duplicated ID" message which is confusing as hell because there's no additional entities with that name in the dungeon. So my only thought is that the game is trying to spawn the teleporter at every single one of the listed pits and either ignoring the variables that tell it to spawn at the parties location; or is spawning them all at the players location. I'm still testing to see what's going on.
edit
A quick test has told me that indeed the teleporter is spawning regardless of the pits state and is spawning multiple teleporters at once with this script:
function pittraps()
local deathpits = {"dungeonpit1",
"dungeonpit2",
"dungeonpit3",
"dungeonpit4",
"dungeonpit5",
"dungeonpit6",
"dungeonpit7",
"dungeonpit8",
"dungeonpit9",
"dungeonpit10",
"dungeonpit11",
"dungeonpit12",
"dungeonpit13",
"dungeonpit14",
"dungeonpit15"}
for i=1, #deathpits do
local deathpit = findEntity(deathpits)
if deathpit:isOpen() then
damageTile(deathpit.level, deathpit.x, deathpit.y, 0, 6, "poison", 10)
spawn("teleporter", party.level, party.x, party.y, 0):setTeleportTarget(12, 11, party.facing, 1)
end
end
end
This is the simplest form of what I am wanting to do and I'm not entirely sure why it's doing what it is doing.