Page 1 of 2
script which prevents sleeping
Posted: Tue Jan 01, 2013 11:01 pm
by Drakkan
Help pls. Subject is quite clear - I need to disable sleeping possibility in particular level of the dungeon. As I do not think that it is possible to completely disable Zzz option, just to make that hp/energy will be not replenished up during sleep is fine
Any ideas somebody ?

Re: script which prevents sleeping
Posted: Tue Jan 01, 2013 11:03 pm
by Komag
simply break onRest hook for the party, or set up a temporary condition which causes it to return false for a while so that it will work again later

Re: script which prevents sleeping
Posted: Wed Jan 02, 2013 2:38 am
by Drakkan
Komag wrote:simply break onRest hook for the party, or set up a temporary condition which causes it to return false for a while so that it will work again later

aah. hooks. not there yet

script plssss ?
Also I am wondering some script which disable mappin on automap ? I need some area of the level have no possibility to be automaped (could be bordered by hidden pressure plates)
Re: script which prevents sleeping
Posted: Wed Jan 02, 2013 11:50 am
by JohnWordsworth
Editing party hooks is as easy as using a clone of the party object and over-riding the provided onX hook functions. In order to prevent sleeping, you just need to do the following.
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onRest = function(party)
return false;
end,
onWakeUp = function(party)
end,
}
I've got this weird hunch that if you have onRest / onWakeUp then you have to have the other (this is certainly true if you want to override onWakeUp, if you don't override onRest then it causes a crash I think - or at least it used too).
If you want to make it conditional (only when the party is on level 3 of your dungeon say), do something like...
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onRest = function(party)
if ( party.level == 3 ) then
return false;
end
end,
onWakeUp = function(party)
end,
}
Enjoy!
Re: script which prevents sleeping
Posted: Wed Jan 02, 2013 12:59 pm
by Drakkan
JohnWordsworth wrote:Editing party hooks is as easy as using a clone of the party object and over-riding the provided onX hook functions. In order to prevent sleeping, you just need to do the following.
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onRest = function(party)
return false;
end,
onWakeUp = function(party)
end,
}
I've got this weird hunch that if you have onRest / onWakeUp then you have to have the other (this is certainly true if you want to override onWakeUp, if you don't override onRest then it causes a crash I think - or at least it used too).
If you want to make it conditional (only when the party is on level 3 of your dungeon say), do something like...
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onRest = function(party)
if ( party.level == 3 ) then
return false;
end
end,
onWakeUp = function(party)
end,
}
Enjoy!
wow I am quite suprised of capacatibility of this editor... really awesome, thanks a lot, working fine as I intended.
Re: script which prevents sleeping
Posted: Thu Jan 03, 2013 12:07 am
by Komag
if you're not going to put anything in onWakeUp you don't need that part in there
Re: script which prevents sleeping
Posted: Thu Jan 03, 2013 12:10 am
by JohnWordsworth
@Komag: Are you certain of that (I should test it really). There was a crashing bug before XMas where if you defined onWakeUp but not onRest the the game would crash when you woke up! I know this is the opposite, and might also be fixed now, but I just wanted to highlight it incase!
Re: script which prevents sleeping
Posted: Thu Jan 03, 2013 1:57 am
by Komag
I suppose I'm not certain, maybe something has changed in new version, worth testing to be sure (it doesn't make sense to me that the crash you rescind happens, sounds like a bug)
Re: script which prevents sleeping
Posted: Thu Jan 03, 2013 7:37 pm
by aaneton
I'm using this no rest code in Onkalo project and have gotten no complaint about it:
Code: Select all
function restcheck()
if party:isResting() == true then
party:wakeUp(true)
hudPrint("You feel at unease resting here.")
end
end
This function is attached to a timer called no_rest_timer with 0 time and timer is started at start of game and running constantly. Yup I'm a lazy coder doing all the shortcuts

Re: script which prevents sleeping
Posted: Fri Jan 04, 2013 8:56 am
by mahric
Komag wrote:I suppose I'm not certain, maybe something has changed in new version, worth testing to be sure (it doesn't make sense to me that the crash you rescind happens, sounds like a bug)
According to the releasenotes this has been fixed in version 1.3.6:
bug fix: crash when party stops resting and there is a onRest hook but no onWakeUp hook
Didn't test it though.