Page 1 of 1

Recreate level 4 puzzle problems

Posted: Fri Oct 19, 2012 9:59 pm
by neonille
I want to "recreate" the puzzle on level 4, where you have to put a specific scroll in a specific alcove.
I also want these scrolls to be found on an alcove or altar.

So..

1. The script from the website only makes it work for any scroll or any dagger as long as it is in the same "item group". I want it to only work with a very specific item (in this case a specific scroll)
Im guessing it will have something to do with the items id?

Code: Select all

function itemPuzzle()
   -- iterate through all contained items on alcove, checking for a matching name
   for i in itemPuzzleAlcove:containedItems() do
      if i.name == "scroll" then
         playSound("level_up")
         break
      end
   end
end
What should i add/change in the code to make this work?

2. I want these scrolls not to just lay around on the ground, these scrolls are gonna be put in an alcove or on an altar. But how do i give an item an uniqe id that i created via script?

Code: Select all

local message = spawn("scroll")
message:setScrollText("This is an important\nmessage!")

scrollAlcove:addItem(message)
What should i change/add here to make the item have a specific id?

Re: Recreate level 4 puzzle problems

Posted: Fri Oct 19, 2012 10:34 pm
by Komag
I haven't actually tried this, but maybe it will work - spawn the scroll fully, with x, y, facing, and id:

Code: Select all

local message = spawn("scroll", 1, 13, 15, 2, "goodScroll1")
message:setScrollText("This is an important\nmessage!")
scrollAlcove:addItem(message)
for the alcove check, us i.id instead of i.name, then you can be specific:

Code: Select all

if i.id == "goodScroll1" then

Re: Recreate level 4 puzzle problems

Posted: Fri Oct 19, 2012 11:02 pm
by neonille
Komag wrote:I haven't actually tried this, but maybe it will work - spawn the scroll fully, with x, y, facing, and id:

Code: Select all

local message = spawn("scroll", 1, 13, 15, 2, "goodScroll1")
message:setScrollText("This is an important\nmessage!")
scrollAlcove:addItem(message)
for the alcove check, us i.id instead of i.name, then you can be specific:

Code: Select all

if i.id == "goodScroll1" then
Dosen“t work, says that the entity already exist

Re: Recreate level 4 puzzle problems

Posted: Fri Oct 19, 2012 11:42 pm
by Komag
does it say that right when you start the play?

try this:

Code: Select all

scrollAlcove:addItem(spawn("scroll", 1, 13, 15, 2, "goodScroll1"):setScrollText("This is an important\nmessage!"))
that probably won't work though either

You have two other options: just spawn them on the ground (like they did on the original level 4), or you can define four new objects that clone a scroll which would allow you to go back to using i.name

Re: Recreate level 4 puzzle problems

Posted: Sat Oct 20, 2012 12:33 am
by Edsploration
Here's another solution, tested and it works for me:

Code: Select all

dungeon_alcove_1:addItem(spawn("scroll"))
local temp = dungeon_alcove_1:containedItems()
scrollReference = temp() -- gets 1st item in alcove, use a for loop + if check if multiple items are involved

-- scrollReference can now be called from anywhere in the same script entity
scrollReference:setScrollText("Scrolls are so much fancier than notes!")

Re: Recreate level 4 puzzle problems

Posted: Sat Oct 20, 2012 12:52 am
by Decayer

Code: Select all

my_alcove:addItem(spawn("scroll_fireburst", nil, nil, nil, nil, "my_id"))
seems to work nicely.

Re: Recreate level 4 puzzle problems

Posted: Sat Oct 20, 2012 1:30 pm
by Komag
nice to see some new solutions to this!