Page 78 of 400
Re: Ask a simple question, get a simple answer
Posted: Sun Jul 05, 2015 4:24 pm
by trancelistic
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)
Re: Ask a simple question, get a simple answer
Posted: Sun Jul 05, 2015 4:55 pm
by THOM
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
Posted: Sun Jul 05, 2015 9:52 pm
by Isaac

This is scripted for LoG1... (my mistake; I will convert it when I get a chance sometime later on tonight, or tomorrow

.)
________________________________________________________________________
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
https://www.dropbox.com/s/79m9n0rmxgvr1 ... k.zip?dl=0
Re: Ask a simple question, get a simple answer
Posted: Sun Jul 05, 2015 10:24 pm
by minmay
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
Posted: Sun Jul 05, 2015 10:31 pm
by Isaac
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.
I recall using that for the town clock bell in one mod, but it was a nightmare to check accurately.
Re: Ask a simple question, get a simple answer
Posted: Sun Jul 05, 2015 10:36 pm
by minmay
What do you mean? Getting the hour from the scale is very easy:
Code: Select all
local hour = (GameMode.getTimeOfDay()*12+9)%24
Re: Ask a simple question, get a simple answer
Posted: Sun Jul 05, 2015 10:44 pm
by Isaac
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
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.)
Re: Ask a simple question, get a simple answer
Posted: Mon Jul 06, 2015 11:51 pm
by AndakRainor
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
Posted: Tue Jul 07, 2015 5:06 am
by Isaac
AndakRainor wrote:Is there any way to make a champion use a UsableItem in a script (automatically, without the player right clicking on it) ?
How exactly do you mean then? (Please invent a gameplay example.)
Re: Ask a simple question, get a simple answer
Posted: Tue Jul 07, 2015 6:33 am
by minmay
Isaac wrote:AndakRainor wrote:Is there any way to make a champion use a UsableItem in a script (automatically, without the player right clicking on it) ?
How exactly do you mean then? (Please invent a gameplay example.)
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.