script which prevents sleeping

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

script which prevents sleeping

Post 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 ? :)
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: script which prevents sleeping

Post 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 :)
Finished Dungeons - complete mods to play
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: script which prevents sleeping

Post 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 :D 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)
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: script which prevents sleeping

Post 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!
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: script which prevents sleeping

Post 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.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: script which prevents sleeping

Post by Komag »

if you're not going to put anything in onWakeUp you don't need that part in there
Finished Dungeons - complete mods to play
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: script which prevents sleeping

Post 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!
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: script which prevents sleeping

Post 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)
Finished Dungeons - complete mods to play
User avatar
aaneton
Posts: 189
Joined: Fri Sep 21, 2012 1:53 pm

Re: script which prevents sleeping

Post 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 ;)
My Grimrock mod (LoG1): The Onkalo Project
My Android (and windows desktop) game: Balloon Gentleman
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: script which prevents sleeping

Post 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.
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
Post Reply