specific food on alter triggers two doors, help?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
wolfee
Posts: 12
Joined: Thu Jan 24, 2013 1:20 pm

specific food on alter triggers two doors, help?

Post 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!
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: specific food on alter triggers two doors, help?

Post 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
Finished Dungeons - complete mods to play
wolfee
Posts: 12
Joined: Thu Jan 24, 2013 1:20 pm

Re: specific food on alter triggers two doors, help?

Post 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.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: specific food on alter triggers two doors, help?

Post by Komag »

Oh yeah, I sometimes forget those myself! You need () after open and close:
open()

close()
Finished Dungeons - complete mods to play
wolfee
Posts: 12
Joined: Thu Jan 24, 2013 1:20 pm

Re: specific food on alter triggers two doors, help?

Post 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 :D
wolfee
Posts: 12
Joined: Thu Jan 24, 2013 1:20 pm

Re: specific food on alter triggers two doors, help?

Post 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.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: specific food on alter triggers two doors, help?

Post 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()
Finished Dungeons - complete mods to play
Ixnatifual

Re: specific food on alter triggers two doors, help?

Post 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.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: specific food on alter triggers two doors, help?

Post 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
Finished Dungeons - complete mods to play
Post Reply