




This can be done with an object that has the Sarcophagus as a model component and a door component that moves an invisible model (up and downSlicyr wrote:Would be cool to have something like a sarcophagus that acts like a secret door, but instead of going up or down, it moves back one square. openingDirection doesn't seem to accept anything other than "up" and "down". Anyone know how to accomplish this?
Code: Select all
defineObject{
name = "urban_town_door_wooden",
components = {
{
-- This is the model of the door that has the animation
class = "Model",
model = "mod_assets/ext/sx_urban_town/models/sx_house01_door.fbx",
},
{
-- This is the invisible model that acts as a blocker/unblocker depending on the door state
-- that model has one node that's called "gate"
class = "Model",
name = "door_logic",
model = "mod_assets/ext/sx_urban_town/models/sx_blocker.fbx", -- sx_blocker.fbx is a door model that is invisible
},
{
-- Here I define the 2 animations that I created, one that swings the door open, and another that closes it
class = "Animation",
currentLevelOnly = true,
animations = {
opendoor = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_open.fbx",
closedoor = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_close.fbx",
},
-- I also create animation events so that I can disable and enable both the controller
-- and the clickable component the reason for this is that I don't want the player to
-- be able to change the state during an animation event.
-- so if you click the door is starts to open, and will not be clickable again until the open animation has finished.
onAnimationEvent = function(self, event)
if event == "dooropening" then
self.go.clickable:disable()
self.go.controller:disable()
--print("opening")
elseif event == "doorclosing" then
self.go.clickable:disable()
self.go.controller:disable()
--print("closing")
elseif event == "doorisclosed" then
self.go.clickable:enable()
self.go.controller:enable()
--print("isclosed")
elseif event == "doorisopen" then
self.go.clickable:enable()
self.go.controller:enable()
--print("isopen")
end
end
},
{
-- this is the door class itself, I have created sounds that are silent so the "fake" door
-- will not play the default stone sliding sound when opening and closing
class = "Door",
sparse = false,
killPillars = false,
openVelocity = 10, -- change this to match the length of the animation, so the player can not pass if the door is not fully open
closeVelocity = 0,
closeAcceleration = -10, -- I just slam the door shut right away
openSound = "sx_silent",
closeSound = "sx_silent",
lockSound = "sx_silent"
},
{
-- this allows the player to click on the door to trigger the opening of it
class = "Clickable",
maxDistance = 0,
-- offset vector is the point where the clickable box begins
offset = vec(0,1.3,0),
-- size is the size of our clickable box
size = vec(2.0,2.0,0.3),
--debugDraw = true,
onClick = function(self)
if self.go.door:isClosed() then
self.go.controller:open()
else
self.go.controller:close()
end
end
},
{
-- if its possible to place objects on the floor around the door so they will go into
-- the model you need ItemConstrainBoxes to prevent item placement in those areas.
class = "ItemConstrainBox",
name = "cbox1",
size = vec(0.8, 3, 0.7),
offset = vec(-1.3, 1.5, 0),
--debugDraw = true,
},
{
class = "ItemConstrainBox",
name = "cbox2",
size = vec(0.8, 3, 0.7),
offset = vec(1.3, 1.5, 0),
--debugDraw = true,
},
{
class = "Controller",
onOpen = function(self)
self.go.door:open() -- this opens the invisible door, so the player can pass.
playSound("sx_door") --The sound to play when the door opens
self.go.animation:play("opendoor") -- here I play the animation of the visual door, swining it open
end,
onClose = function(self)
self.go.door:close() -- here we close the invisible door so the player can't pass
playSound("sx_door") --The sound to play when the door closes
self.go.animation:play("closedoor") -- here I play the animation of the visual door, swining it close
end,
onToggle = function(self)
if self.go.door:isClosed() then
self.go.controller:open()
else
self.go.controller:close()
end
end,
},
},
placement = "wall",
editorIcon = 16,
automapIcon = 84,
tags = { "sx_doors" },
}
defineAnimationEvent{
-- here we create an event called dooropening that starts on frame 1 of the opening animation
animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_open.fbx",
event = "dooropening",
frame = 1,
}
defineAnimationEvent{
-- here on frame 44 the door has come to a stop, creating the event doorisopen
animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_open.fbx",
event = "doorisopen",
frame = 44,
}
defineAnimationEvent{
-- here we create an event on frame 1 thats called doorclosing
animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_close.fbx",
event = "doorclosing",
frame = 1,
}
defineAnimationEvent{
-- and event when the door has come to a stop closed
animation = "mod_assets/ext/sx_urban_town/animations/sx_urban_door_close.fbx",
event = "doorisclosed",
frame = 44,
}
i.e. like a Master Quest or "The Mountain"? I'm pretty sure that won't be an issue.AndakRainor wrote:Is it allowed to base a mod on Isle of Nex ?