thanks to Doridion's excellent clickable doors modification ( viewtopic.php?f=22&t=8227 ) I was able to create the well known door, that is half open and can be pried open once on a random click number and with the notification.
This is based on his modification and I recommend you read the above thread first.
The reason why I created a new one is that I don't like searching for such additions in the depths of other threads, I think it can be found easier this way. ;-)
This goes to the objects.lua, use you preferred door as baseObject.
Code: Select all
defineObject{
name = "pry_door",
baseObject = "dungeon_door_wooden",
components = {
{
class = "Door",
sparse = true,
killPillars = true,
},
{
class = "Clickable",
maxDistance = 1,
-- offset vector is the point where begin the clickable box
offset = vec(0,1.3,0),
-- size is the size of our clickable box
size = vec(2.5,2.5,0.3),
onClick = function(self)
if math.random(1, 6) == 1 then
self.go.door:open()
end
end
},
{
class = "Controller",
onOpen = function(self, name)
--self.go.door:open()
end,
onClose = function(self)
-- self.go.door:close()
end,
onToggle = function(self)
-- self.go.door:toggle()
end,
},
},
placement = "wall",
editorIcon = 124,
}
if math.random(1, 6) == 1 then
defines a random number so that you don't know how often you have to click until the door is pried open.
There still need to be several objects.
Here is an example set up dungeon:
https://das-kartell.org/files/pry_door_open.zip
The following script is used in the test dungeon. It is tried and the door saves its state also after reloading.
Code: Select all
function doortestinitializedoor()
local door_start_position = my_clickable_door_1:getWorldPosition()
local door_x = door_start_position[1]
local door_y = door_start_position[2]+0.5
local door_f = door_start_position[3]
my_clickable_door_1:setWorldPosition(door_x, door_y, door_f, 0)
my_clickable_door_1.door:addConnector("onOpen", "script_entity_1", "doortestdisable")
end
doortestinitializedoor()
function doortestdisable()
my_clickable_door_1.clickable:disable()
hudPrint("You pry the door open.")
end
Kind regards,
Joerg