You could of course place a button on a wall, then select that prop in the editor and move it (ASWD, for those who don't know) to an empty space, and it would look like a wall with a button, but it could be walked through, which is not what we want.
I've found a way how to simulate a button ON a secret door with a minimal graphical glitching.
Place a lua script object into your map and copy the following function(s) as needed into it. Explanation below the script:
Code: Select all
function buttonIntoDoorDungeon(self)
local levl,x,y,f
x = self.x
y = self.y
levl = self.level
f = self.facing
-- we use dragon statue(s) to block passage through the otherwise passable "button wall"
for iterX = x-1,x+1 do
for iterY = y-1,y+1 do
for ent in entitiesAt(levl,iterX,iterY) do
if ent.name == "dragon_statue" then
ent:destroy()
end
end
end
end
self:destroy()
local new_id = spawn("dungeon_secret_door",levl,x,y,f)
new_id:open()
end
function buttonIntoDoorTemple(self)
local levl,x,y,f
x = self.x
y = self.y
levl = self.level
f = self.facing
-- we use dragon statue(s) to block passage through the otherwise passable "button wall"
for iterX = x-1,x+1 do
for iterY = y-1,y+1 do
for ent in entitiesAt(levl,iterX,iterY) do
if ent.name == "dragon_statue" then
ent:destroy()
end
end
end
end
self:destroy()
local new_id = spawn("temple_secret_door",levl,x,y,f)
new_id:open()
end
How to use this?
1. Place a secret button (any type) on any wall (otherwise the editor won't let you place it). Or, spawn the button via script wherever you want.
2. Select it in the editor and move it [WASD keys, plus E/Q for rotation] into a "corridor" so that it blocks it like a secret door would. If you test your map now, you will see the button, but can walk through it.
3. Place a dragon_statue just behind the wall -- this will prevent walking through the button.
4. Add connector to the button that leads to the "buttonIntoDoorXXXXXX(self)" function -- select the one function that corresponds to the level's tileset (Dungeon or Temple).
That's it! As soon as the button is clicked, it disappears and is immediately replaced with a secret door that starts opening. The dragon_statue also disappears (before the opening), so you can suddenly move through.
Of course, the button can have multiple connectors, so you can also connect it to a secondary secret_door from the other side, which will make sure no-one sees ugly glitches or the statue.
Picture of a typical map layout (from my Rite of Passage dungeon)
