# LuaDreamer Challenge Pillows!

#### ralke

##### (҂ ͠❛ ෴ ͡❛)ᕤ
Hi again guys! Based on this revscript orts2/dreamer_challenge.lua at main · EPuncker/orts2 (https://github.com/EPuncker/orts2/blob/main/data/scripts/quests/dreamer_challenge.lua) I tried to merge Dreamer Challenge on my server. I'm on the pillows puzzle now, struggling with this part, and I have the following errors:

a) When I finish the puzzle no magic effect is sent (to confirm that I've finished)
b) The teleport for the next room isn't created after finishing the puzzle, destination should be 1271, 749, 14
b) The tile triggers (of the puzzle) still work when I finish the puzzle, i'm not sure, but they're supposed to be enabled again as soon you stepIn the teleport

Here's good evidence of how works, check 21:52 aproximatelly
Live! - DREAMER'S CHALLENGE QUEST - PASO A PASO (https://www.youtube.com/live/kjQlJhxzNl8?feature=share&t=1312)

Lua:
``````local riddleTeleport = MoveEvent()

local destination = Position(1271, 749, 14)
local topLeftPosition = Position(1322, 808, 9)
local pillowPositions = {
{itemid = 1686, center = topLeftPosition + Position(2, 2, 0)},
{itemid = 1687, center = topLeftPosition + Position(2, 5, 0)},
{itemid = 1688, center = topLeftPosition + Position(5, 2, 0)},
{itemid = 1689, center = topLeftPosition + Position(5, 5, 0)}
}

function riddleTeleport.onStepIn(creature, item, position, fromPosition)
if not player:getPlayer() then
return true
end

local pillows = {}
for i = 1, #pillowPositions do
local pillowPos = pillowPositions[i]
for x = -1, 1 do
for y = -1, 1 do
local item = Tile(pillowPos.center + Position(x, y, 0)):getThing(1)
if not item or item.itemid ~= pillowPos.itemid then
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end

pillows[#pillows + 1] = item
end
end
end

player:teleportTo(destination)
destination:sendMagicEffect(CONST_ME_TELEPORT)

for x = 1, 6 do
for y = 1, 6 do
local index = math.random(#pillows)
pillows[index]:moveTo(topLeftPosition + Position(x, y, 0))
table.remove(pillows, index)
end
end
return true
end

riddleTeleport:type("stepin")
riddleTeleport:uid(50147)
riddleTeleport:register()``````

A photo of finished puzzle (proof that tile triggers works)

Hope someone can help me finishing this quest,

Are you sure you have the top left position correct?

It would be the corner of the bone wall.

Are you sure you have the top left position correct?

It would be the corner of the bone wall.
Here goes! It is on the bone wall

Try this:
Lua:
``````local riddleTeleport = MoveEvent()

local destination = Position(1271, 749, 14)
local topLeftPosition = Position(1322, 808, 9)
local pillowPositions = {
{itemid = 1686, center = topLeftPosition + Position(2, 2, 0)},
{itemid = 1687, center = topLeftPosition + Position(2, 5, 0)},
{itemid = 1688, center = topLeftPosition + Position(5, 2, 0)},
{itemid = 1689, center = topLeftPosition + Position(5, 5, 0)}
}

function riddleTeleport.onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end

local pillows = {}
for i = 1, #pillowPositions do
local pillowPos = pillowPositions[i]
for x = -1, 1 do
for y = -1, 1 do
local item = Tile(pillowPos.center + Position(x, y, 0)):getTopVisibleThing()
if not item or item.itemid ~= pillowPos.itemid then
player:teleportTo(fromPosition)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end

pillows[#pillows + 1] = item
end
end
end

player:teleportTo(destination)
destination:sendMagicEffect(CONST_ME_TELEPORT)

for x = 1, 6 do
for y = 1, 6 do
local index = math.random(#pillows)
pillows[index]:moveTo(topLeftPosition + Position(x, y, 0))
table.remove(pillows, index)
end
end

for _, pillowPos in ipairs(pillowPositions) do
for x = -1, 1 do
for y = -1, 1 do
local pos = pillowPos.center + Position(x, y, 0)
local tile = Tile(pos)
if tile then
local item = tile:getTopVisibleThing()
if item and item.itemid == pillowPos.itemid then
tile:setTopVisibleThingActionId(50147)
else
tile:setTopVisibleThingActionId(0)
end
end
end
end
end
end, 2000)

return true
end

riddleTeleport:type("stepin")
riddleTeleport:uid(50147)
riddleTeleport:register()``````

Tested? -Nope!

• Added a local player variable to store the player object.
• Changed getThing(1) to getTopVisibleThing() to get the top visible item.
• Replaced true argument in teleportTo with the default false value.
• Added a delay of 2 seconds after finishing the puzzle to enable the tile triggers again.
• Changed onStepIn function to return true at the end.

Replies
3
Views
520
Replies
9
Views
472
Replies
4
Views
587
Replies
0
Views
161
Replies
8
Views
713
Replies
4
Views
290
Replies
1
Views
210
Replies
0
Views
186
RevScripts Teleport after kill
Replies
7
Views
658
Replies
0
Views
307