• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Dreamer Challenge Pillows!

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,492
Solutions
27
Reaction score
858
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
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)
image.png


Hope someone can help me finishing this quest,
Thanks in advance!
 
Are you sure you have the top left position correct?

It would be the corner of 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

    addEvent(function()
        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!

Changes made:
  • 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.
 
Back
Top