Page 1 of 1
specific food on alter triggers two doors, help?
Posted: Fri Feb 01, 2013 9:19 pm
by wolfee
I want to have an alter accept a specific kind of food, (snail_slice for this example) and trigger two doors to open. I've been looking at a few example functions but no luck so far. This is what I have so far:
The door ID's are "feedmeDoor_1" and "feedmeDoor_2".
The alter ID is "altar_accept_flesh".
The script_entity is this:
Code: Select all
function feedme()
-- iterate through all contained items on alcove, checking for a matching name
for i in alter_accept_flesh:containedItems() do
if i.name == "snail_slice" then
feedmeDoor_1:open
else
feedmeDoor_1:close
end
end
end
Right now I'm just trying to get one door to work but I tried using "and feedmeDoor_2:open" with no luck either.
Any help appreciated. Almost done with the dungeon!
Re: specific food on alter triggers two doors, help?
Posted: Fri Feb 01, 2013 10:01 pm
by Komag
That looks fine to me. You probably just need to make sure your altar is set correctly. You want to add a connection to the altar, "any", "yourScript", "feedme". Be sure your altar is set to "activate always" in this case
Re: specific food on alter triggers two doors, help?
Posted: Fri Feb 01, 2013 10:35 pm
by wolfee
I keep getting "function arguement expected near 'else'". If I get rid if the 'else', it moves down to the "end" and gives an error for that. I set up a connector to my script_entity_5 which has the function "feedme" and I set the event to "any" and the altar to "always activate". The function itself is wrong somehow.
Re: specific food on alter triggers two doors, help?
Posted: Fri Feb 01, 2013 10:40 pm
by Komag
Oh yeah, I sometimes forget those myself! You need () after open and close:
open()
close()
Re: specific food on alter triggers two doors, help?
Posted: Fri Feb 01, 2013 10:50 pm
by wolfee
Ok awesome, that worked ... but now I get "attempt to index global 'altar_accept_flesh' (a nil value)" as soon as I put a piece of snail_slice on the altar.
Disclaimer: I'm a DBA that really likes dungeon crawler games. Sorry if I don't know squat about scripting but the idea of making my own dungeon was too much to pass up

Re: specific food on alter triggers two doors, help?
Posted: Fri Feb 01, 2013 11:06 pm
by wolfee
Just for kicks I made the altar an alcove and it is working. Not sure why, but that's ok. Now I just need to get it to open two doors at the same time.
Re: specific food on alter triggers two doors, help?
Posted: Sat Feb 02, 2013 12:05 am
by Komag
I missed it before - you had the spelling different, "altar" and "alter" (keep them both "altar")
to open two doors just add another line
door1:open()
door2:open()
Re: specific food on alter triggers two doors, help?
Posted: Sat Feb 02, 2013 12:07 am
by Ixnatifual
You probably want to make the loop end if you find the food piece so another item in the alcove doesn't cause the door to shut if there's multiple items.
Re: specific food on alter triggers two doors, help?
Posted: Sat Feb 02, 2013 12:13 am
by Komag
Code: Select all
function feedme()
-- iterate through all contained items on alcove, checking for a matching name
for i in altar_accept_flesh:containedItems() do
if i.name == "snail_slice" then
feedmeDoor_1:open()
feedmeDoor_2:open()
return
else
feedmeDoor_1:close()
feedmeDoor_2:close()
end
end
end