Rest and Rewards

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Rest and Rewards

Post by crisman »

I've tested the code and doesn't work to me neither. :shock:
Apparently, the strings

Code: Select all

local d = findEntity("restDoor"..restCount)
if d then d:close() end
are the responsible. So I've changed them with

Code: Select all

 findEntity("restDoor"..restCount):close()
And works really good!
In this way, thought you have to add an if statement on the top of the script to prevent the code looking for a non-existent entity (with a crash as a result), such as

Code: Select all

 if restCount >= 6 then
	return true
end
If you have 6 doors.
Let us know! :)

EDIT: forgot an equal ;)
EDIT2: I don't know what I did the first time, but now Komag's code working right for me (and I hoped, because I could't see any flaws, I was a bit confused when it didn't work)
So try with the print ;)
User avatar
Ulwaen
Posts: 44
Joined: Thu Feb 07, 2013 4:12 pm

Re: Rest and Rewards

Post by Ulwaen »

Nop! no result nothing...the door stay opened!
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Rest and Rewards

Post by crisman »

Can't even read any prints?
If so there should be something wrong with your cloned party.
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Rest and Rewards

Post by Komag »

I second that advice, add print messages at each step to get a better idea what part isn't working
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 »

I dont understand what you mean about " cloned party"? What is this, an entity in the editor?
Actually there is only the script "restScript" as entity in the editor, which is linked to nothing!
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Rest and Rewards

Post by Komag »

It's something you need to make and put in your objects.lua file in your documents/Almost Human/dungeons/yourdungeon/mod_assets/scripts folder. Here is an example:
viewtopic.php?p=53320#p53320
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 »

I'm lost...:/
In the lua entity, "restScript", there is now :

restCount = 0

function doRest()
if restCount >= 6 then
return true
end
restCount = restCount + 1
local d = findEntity("restDoor"..restCount):close()
if d then d:close() end
end

............................................................................
And in the object.lua there is now :

cloneObject{
name = "party",
baseObject = "party",
onAttack = function (self, weapon)
return damage.whatWeapon(self, weapon)
end
}
onRest = function(party)
restScript.doRest()
end

...........................................................................

But of course, I dont understand what I made so it's not working... I'm ready for the sepuku ^^,
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Rest and Rewards

Post by crisman »

the { parenthesis in the cloneObject must go after the last row of code (with a comma right after the "end" of the onAttack hook), so it will be:

Code: Select all

cloneObject{
name = "party",
baseObject = "party",
onAttack = function (self, weapon)
return damage.whatWeapon(self, weapon)
end,
onRest = function(party)
restScript.doRest()
end
}
That should do the trick! ;)
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Rest and Rewards

Post by Komag »

Yeah but don't leave that onAttack hook in there unless you're going to use it and have a damage script with a whatWeapon function!
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 »

The game crashed and I get this :
Image

Here are my script >>
object.lua :

cloneObject{
name = "party",
baseObject = "party",
onAttack = function (self, weapon)
return damage.whatWeapon(self, weapon)
end,
onRest = function(party)
restScript.doRest()
end
}

.....................................................................
"restScript" entity :

restCount = 0

function doRest()
if restCount >= 6 then
return true
end
restCount = restCount + 1
local d = findEntity("restDoor"..restCount):close()
if d then d:close() end
end

.....................................................................
Post Reply