Rest and Rewards

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Ulwaen
Posts: 44
Joined: Thu Feb 07, 2013 4:12 pm

Rest and Rewards

Post by Ulwaen » Sat Feb 09, 2013 2:44 pm

Hello Folks!
I am wondering if there is a way to script in the editor to lock/unlock room in the dungeon, this if you decide to have some rest during the game.
This means the rewards the dungeon has to offer (which are in the targeted room) will depend of the time you will get some rest.

User avatar
Komag
Posts: 3637
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Rest and Rewards

Post by Komag » Sat Feb 09, 2013 2:50 pm

that sounds doable using onRest and onWakeUp hooks, perhaps with timers to measure, or a tick counter
Finished Dungeons - complete mods to play

User avatar
Ulwaen
Posts: 44
Joined: Thu Feb 07, 2013 4:12 pm

Re: Rest and Rewards

Post by Ulwaen » Sat Feb 09, 2013 4:11 pm

Ok but I have no idea of the writing script process ^^,
I'm a noob in scrip ;)
If somebody may show me what to write as function!

User avatar
Komag
Posts: 3637
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Rest and Rewards

Post by Komag » Sat Feb 09, 2013 5:38 pm

The code will depend heavily on exactly what you want and what approach you want to take. Try piecing together little tiny bits of progress, like study and see if you can get it set up to simply print a message with onRest. If that is elusive, first get a message to print when pushing a button! Everything is a step by step learning process that builds on itself.
Finished Dungeons - complete mods to play

User avatar
Ulwaen
Posts: 44
Joined: Thu Feb 07, 2013 4:12 pm

Re: Rest and Rewards

Post by Ulwaen » Sun Feb 10, 2013 2:04 am

Yeah thanks ^^

"noob" doesn't means totally stupid ;)
About the dungeons I'm working on, I used many script by searching on the forum and other, then I understood some stuff here and there.
It's because I didn't found any script with the logic I'm looking for, that I am asking for some advice. ^^

"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime"
I'm ready to learn ;) that why I'm here!

So in the dungeon there is 6 room having each one an alcove with a "reward" in it.
I would like to lock one room by a script, each time the player decide to rest, to give more challenge to the quest.
I understand the necessity of counters which will be decremented each time the party rest, so one counter for each room link to the same script :
room 01 > counter value 1 > 1 rest = locked
room 02 > counter value 2 > 2 rest = locked
room 03 > counter value 3 > 3 rest = locked
room 04 > counter value 4 > 4 rest = locked
room 05 > counter value 5 > 5 rest = locked
room 06 > counter value 6 > 6 rest = locked
But may you explain me how to write the function please :)

User avatar
Komag
Posts: 3637
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Rest and Rewards

Post by Komag » Sun Feb 10, 2013 3:21 am

You could have the onRest just increment a variable counter (not a counter object, or it could be if you want I guess)
add to your party clone object in your objects.lua file:

Code: Select all

  onRest = function(party)
	restScript.doRest()
  end,
have a script entity in the dungeon called restScript and have this code:

Code: Select all

restCount = 0

function doRest()
  restCount = restCount + 1
  local d = findEntity("restDoor"..restCount)
  if d then d:close() end
end
Have your six rooms each have a door named "restDoor1", "restDoor2", etc. Every time the player rests, the restCount variable will go up one, and, for example, when it gets to 4, "restDoor4" will close. So long as you don't make any way for the player to open the door, it will be "locked". Not to worry if restCount gets to 7 because the function first checks that the door exists, and if it doesn't, no harm is done, no crash or anything.
Finished Dungeons - complete mods to play

User avatar
Ulwaen
Posts: 44
Joined: Thu Feb 07, 2013 4:12 pm

Re: Rest and Rewards

Post by Ulwaen » Sun Feb 10, 2013 4:38 pm

Hi!
Sorry dude I'm made as you told me (and checked with a friend who know script too), but it's not working...

Marble Mouth
Posts: 52
Joined: Sun Feb 10, 2013 12:46 am
Location: Dorchester, MA, USA

Re: Rest and Rewards

Post by Marble Mouth » Sun Feb 10, 2013 5:31 pm

Hi Ulwaen. What happens when you try it? Does it crash? Does it continue to run, but the doors don't react to the party resting? Are you testing by resting right in front of the door(s) you want to close?

There's a lot of straightforward (but easy to overlook) issues that might be preventing it from working just right. For example, are your doors named exactly "restDoor1", "restDoor2", etc. as Komag suggested? If they're named anything else (e.g. "RestDoor1", "rest Door1", or "restdoor1") then Komag's code won't find them and close them. It's also necessary that the script is named exactly "restScript". I think if the door names are wrong, then it will run but nothing will happen, but if the script name is wrong it could crash. Also, after changing (and saving) your objects.lua file, don't forget to File>Reload Project. I hope some of this helps.

Edit: Have you thought about what would happen if the party rests inside of a reward room thereby locking it? Could they get stuck in there with no way to leave? Is that a possibility that you're ok with? If not, a simple button on the inside to open the door should work. In this scenario, the door would be open, so the party would be able to access this room for the rest of the game, no matter how many times they rested. If that's also a problem for you, we can discuss possible solutions for that, too.

User avatar
Ulwaen
Posts: 44
Joined: Thu Feb 07, 2013 4:12 pm

Re: Rest and Rewards

Post by Ulwaen » Sun Feb 10, 2013 8:56 pm

All what you're talking about was checked without success...But maybe I forget to something. To test I'm having some rest just in front of the door, but I don't think this may cause any issue.

User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Rest and Rewards

Post by crisman » Sun Feb 10, 2013 9:21 pm

Try adding some print("hello") here and there in the code, and see where the code does not work.

For example:

Code: Select all

  onRest = function(party)
print("bed time")
   restScript.doRest()
  end,
and

Code: Select all

restCount = 0

function doRest()
print("I'm sleeping")
  restCount = restCount + 1
  local d = findEntity("restDoor"..restCount)
print("let's find the door!")
  if d then d:close() end
end
Yeah, I know, my messages are stupid... :oops:

Post Reply