Re: Ask a simple question, get a simple answer
Posted: Mon Mar 26, 2018 12:07 am
Many thanks! This is exactly what I need!
Official Legend of Grimrock Forums
http://grimrock.net/forum/
Code: Select all
defineObject{
name = "sx_swingdoor_clickable",
components = {
{
class = "Model",
model = "mod_assets/models/doors/swingdoor.fbx",
offset = vec(0,1.375,0),
},
{
class = "Model",
name = "door_logic",
model = "assets/models/env/dungeon_secret_door.fbx",
enabled = false
},
{
class = "Animation",
animations = {
activate = "mod_assets/animations/swingdoor_open.fbx",
deactivate = "mod_assets/animations/swingdoor_close.fbx",
},
},
{
class = "Door",
sparse = true,
killPillars = false,
openVelocity = 10,
closeVelocity = 0,
closeAcceleration = -10,
openSound = "silent",
closeSound = "silent",
lockSound = "silent"
},
{
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 self.go.door:isClosed() then
self.go.controller:open()
else
self.go.controller:close()
end
end
},
{
class = "Controller",
onOpen = function(self)
self.go.door:open()
playSound("lever") --Change to what you want
self.go.animation:play("activate")
end,
onClose = function(self)
self.go.door:close()
playSound("lever") --Change to what you want
self.go.animation:play("deactivate")
end,
onToggle = function(self)
if self.go.door:isClosed() then
self.go.controller:open()
else
self.go.controller:close()
end
end,
},
},
placement = "wall",
editorIcon = 124,
tags = { "doors" },
}
Code: Select all
function nightdoors2()
if GameMode.getTimeOfDay() > 1.04 and GameMode.getTimeOfDay() < 1.97 then
sx_swingdoor_clickable_3.clickable:disable()
sx_swingdoor_clickable_3.controller:disable()
else
sx_swingdoor_clickable_3.clickable:enable()
sx_swingdoor_clickable_3.controller:activate()
end
end
ReplaceMysterious wrote:Night and Day Code (in editor):What happens is the door is unuseable at night but when the day cycle come back I cannot open the door. I have set a timer on to check 0.1 seconds. I don't know what I have done wrong here?Code: Select all
function nightdoors2() if GameMode.getTimeOfDay() > 1.04 and GameMode.getTimeOfDay() < 1.97 then sx_swingdoor_clickable_3.clickable:disable() sx_swingdoor_clickable_3.controller:disable() else sx_swingdoor_clickable_3.clickable:enable() sx_swingdoor_clickable_3.controller:activate() end end
The performance impact of this is utterly irrelevant.Isaac wrote:I think that rather than have it set to 0.1, that you could probably just as well set your timer to 180, or 360.
It could save an awful lot of —guaranteed failure— time checks.
Except time of day doesn't work that way. It increments when the party moves or turns, not with real-time.Isaac wrote:Or you could perhaps check or set the time when the game loads, and set the timer to the exact delay that you need.
Is it? I will take your word for it; it still seems a waste to make that check ten times a second for half of the day.minmay wrote:The performance impact of this is utterly irrelevant.Isaac wrote:I think that rather than have it set to 0.1, that you could probably just as well set your timer to 180, or 360.
It could save an awful lot of —guaranteed failure— time checks.
I never liked that part about it. It seems to me that the time should pass even when squandered by loitering. I suppose it is to obfuscate the —much faster than realistic— passage of time during the game.Except time of day doesn't work that way. It increments when the party moves or turns, not with real-time.Isaac wrote:Or you could perhaps check or set the time when the game loads, and set the timer to the exact delay that you need.
ok, understood!minmay wrote:The game only has one reflection buffer. The only things you accomplish by having multiple WaterSurfaceComponents on the same level are:bongobeat wrote:Well I didn't know that you can have (and should) only one. But what is the matter when using 5 water_surface_component on the same map? Except for the issue of reflection.
1. You make it difficult to know which WaterSurfaceComponent will be used to calculate the reflection buffer. This is bad.
2. You make performance slightly worse. This is also bad.
Note that WaterSurfaceComponent isn't really affected by disabling it. You should remove the components entirely, not just disable them.