• 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 Ebb and Flow

nanduzenho

Member
Joined
Mar 21, 2021
Messages
191
Solutions
1
Reaction score
16
GitHub
nanduzenho
Could anyone help me with how to make the soulwar inundate script? I have no idea how to start. I use TFS 1.5
 
To achieve this you should create two maps - one flooded and one dry, and then use Game.loadMap()

It would be just the beginning, as you should get the players from map and teleport them in certain places and perhaps some more features, but here's the base with map change event only, you can build further on that.

Well, for now it changes the map randomly, can happen that it will load same map few times, but you should change it from one state to other in order to copy real mechanics.

Lua:
local maps = {
    [1] = {
        mapName = 'flooded',
    },
    [2] = {
        mapName = 'drained',
    }
}

local config = {
    fromPosition = Position(2682, 1750, 6),
    toPosition = Position(2717, 1787, 7),
    chance = 100
}

local ebbandflow = GlobalEvent("Ebb and Flow")

function ebbandflow.onThink(interval)
    iterateArea(function(position)
        local tile = Tile(position)
        if not tile then
            return
        end
        local items = tile:getItems()

        if items then
            for i = 1, #items do
            local checkitem = items[i]
                    local item = items[i]
                    item:remove()
            end
        end
    end, Position(config.fromPosition.x, config.fromPosition.y, config.fromPosition. z), Position(config.toPosition.x, config.toPosition.y, config.toPosition.z))
 
        if math.random(100) <= config.chance then
            local randMap = maps[math.random(#maps)]
            Game.loadMap('data/world/worldchange/' .. randMap.mapName .. '.otbm')
        end
        return true
end

ebbandflow:interval(60000*2)
ebbandflow:register()
 
Last edited:
Back
Top