1 - Clickable door
I give you the definition trick
For original LoG2 models doors :
Code: Select all
defineObject{
name = "my_clickable_door",
baseObject = "[color=#40FFBF][name of the door you want to use][/color]",
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)
self.go.door:toggle()
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,
}
Code: Select all
defineObject{
name = "my_clickable_door",
components = {
{
class = "Model",
model = "mod_assets/models/env/my_door_model.fbx",
},
{
class = "Model",
name = "frame",
model = "mod_assets/models/env/my_frame_model.fbx",
},
{
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)
self.go.door:toggle()
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,
}
2 - Unlocking clickable door without lock item or attached script
Code: Select all
defineObject{
name = "my_clickable_door",
baseObject = "[color=#40FFBF][name of the door you want to use][/color]",
components = {
{
class = "Door",
sparse = true,
killPillars = true,
},
{
class = "Clickable",
maxDistance = 1,
offset = vec(0,1.3,0),
size = vec(2.5,2.5,0.3),
onClick = function(self)
local used_item = getMouseItem()
if self.go.lock:getOpenedBy() == ("" or nil) then
self.go.door:toggle()
else
if used_item == nil then
hudPrint("Door is locked ")
elseif used_item.go.item:hasTrait("key") then
if self.go.lock:getOpenedBy() == used_item.go.name then
self.go.door:open()
self.go.lock:setOpenedBy("")
setMouseItem(nil)
hudPrint("Door is unlocked")
else
hudPrint("Not the right key")
end
else
hudPrint("You must open the door with a key")
end
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,
},
{
class = "Lock",
},
},
placement = "wall",
editorIcon = 128,
}
1 - In the editor, just put the door on your map, locking her directly in the door's components like the lock items, place the key somewhere in your map.
2 - Test your party, go taking the key, go in front off the locked door, click on the key, click on the door and ... it's open
And that's it ! Go modding pretty doors now