Page 2 of 3

Re: Rest and Rewards

Posted: Sun Feb 10, 2013 9:33 pm
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 ;)

Re: Rest and Rewards

Posted: Sun Feb 10, 2013 11:04 pm
by Ulwaen
Nop! no result nothing...the door stay opened!

Re: Rest and Rewards

Posted: Sun Feb 10, 2013 11:49 pm
by crisman
Can't even read any prints?
If so there should be something wrong with your cloned party.

Re: Rest and Rewards

Posted: Mon Feb 11, 2013 12:09 am
by Komag
I second that advice, add print messages at each step to get a better idea what part isn't working

Re: Rest and Rewards

Posted: Mon Feb 11, 2013 4:10 pm
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!

Re: Rest and Rewards

Posted: Mon Feb 11, 2013 4:21 pm
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

Re: Rest and Rewards

Posted: Mon Feb 11, 2013 6:56 pm
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 ^^,

Re: Rest and Rewards

Posted: Mon Feb 11, 2013 10:17 pm
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! ;)

Re: Rest and Rewards

Posted: Mon Feb 11, 2013 11:33 pm
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!

Re: Rest and Rewards

Posted: Mon Feb 11, 2013 11:54 pm
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

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