Ask a simple question, get a simple answer
-
- Posts: 275
- Joined: Sat Jun 16, 2012 5:32 am
Re: Ask a simple question, get a simple answer
I"m nto sure of LoG2 has it like Log 1, other floors goes way slower in 1. so also the timer.
If log 2 has it as well, I guess you can put a timer some where emty on the map far deep somewhere. So the timer runs the same all over. ( you just have to calculate the difference then with it being slower then real time)
If log 2 has it as well, I guess you can put a timer some where emty on the map far deep somewhere. So the timer runs the same all over. ( you just have to calculate the difference then with it being slower then real time)
Re: Ask a simple question, get a simple answer
well, I need the timer and it's triggering just in one level. My qustion is, if it's absolutely neccessary to stop it, when the party leaves this level or is it enough to set it on "current level only"... ??
Re: Ask a simple question, get a simple answer


________________________________________________________________________
You don't have to use a timer for this.
You could use the game's internal play_time statistic to track time.
Code: Select all
--object.lua
defineObject{
name = "party",
class = "Party",
editorIcon = 32,
onDrawGui = function(self)
if lightSwitch.needed then
lightSwitch:check()
end
end,
}
Code: Select all
--script name: lightSwitch
time_delay = 4 --
needed = true
lights_on = true
last_time = getStatistic("play_time")
function floorPlate(caller)
if needed then
needed = false
else
needed = true
end
print("Checking time: ",needed) --=----------[debug comment]-
end
function check()
if getStatistic("play_time") >= last_time + time_delay then
last_time = getStatistic("play_time")
if lights_on then
lights_on = false
else
lights_on = true
end
lights(lights_on)
end
end
function setTimeDelay(num)
if type(num) == "number" then
time_delay = num
end
end
function setNeeded(bool)
if type(bool) == "boolean" then
needed = bool
end
end
function setLightsOn(bool)
if type(bool) == "boolean" then
lights_on = bool
lights(bool)
end
end
function lights(bool) -- add your own custom light controller here.
-- this one is just for the example map.
if lamp_1 then
lamp_1:destroy()
end
if bool then
spawn("temple_ceiling_lamp", self.level, self.x, self.y, self.facing,"lamp_1")
end
--
end
Last edited by Isaac on Sun Jul 05, 2015 10:41 pm, edited 3 times in total.
Re: Ask a simple question, get a simple answer
If you want the time of day you should use GameMode.getTimeOfDay(). Time of day in Grimrock does not actually correspond to time, it changes when the party moves and turns, and while they're resting.
Also consider using Time.currentTime() instead of the play_time statistic, depending on your needs.
Also consider using Time.currentTime() instead of the play_time statistic, depending on your needs.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Ask a simple question, get a simple answer
I recall using that for the town clock bell in one mod, but it was a nightmare to check accurately.minmay wrote:If you want the time of day you should use GameMode.getTimeOfDay(). Time of day in Grimrock does not actually correspond to time, it changes when the party moves and turns, and while they're resting.
Also consider using Time.currentTime() instead of the play_time statistic, depending on your needs.
Re: Ask a simple question, get a simple answer
What do you mean? Getting the hour from the scale is very easy:
Code: Select all
local hour = (GameMode.getTimeOfDay()*12+9)%24
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Ask a simple question, get a simple answer
The problem I had was under/ or overshooting the hour when checking the time, and the bell was off. (IIRC, the problem came of not wanting a constant high-speed test going on all the time during the game. This was compounded by variant time speed during rest ~which still rang on the hour, and no time speed, when the party was stationary.)minmay wrote:What do you mean? Getting the hour from the scale is very easy:Code: Select all
local hour = (GameMode.getTimeOfDay()*12+9)%24
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
Is there any way to make a champion use a UsableItem in a script (automatically, without the player right clicking on it) ?
Re: Ask a simple question, get a simple answer
How exactly do you mean then? (Please invent a gameplay example.)AndakRainor wrote:Is there any way to make a champion use a UsableItem in a script (automatically, without the player right clicking on it) ?
Re: Ask a simple question, get a simple answer
Using the item like when the player right-clicks on it or drops it on a champion's portrait, but without actually requiring the player to right-click on it or drop it on a champion's portrait.Isaac wrote:How exactly do you mean then? (Please invent a gameplay example.)AndakRainor wrote:Is there any way to make a champion use a UsableItem in a script (automatically, without the player right clicking on it) ?
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.