• 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!

Lights turns on automatic at X-time!

Wartio

Any game ideas?
Joined
Apr 2, 2010
Messages
457
Reaction score
29
Location
Sweden
I got a script from this thread:
http://otland.net/threads/light-up-the-streets-at-night.197060/

But the lights does not turn on ingame for some reason ;/

Can someone script this and make it so the All lights with id 1479 around the whole map

Code:
local t = {
{x = 1826, y = 1565, z = 7, stackpos = 2}, -- Street Lights on the Map
{x = 1837, y = 1569, z = 7, stackpos = 2},
{x = 1820, y = 1551, z = 7, stackpos = 2},
{x = 1874, y = 1591, z = 7, stackpos = 2},
{x = 1864, y = 1598, z = 7, stackpos = 2},
{x = 1851, y = 1603, z = 7, stackpos = 2},
{x = 1845, y = 1597, z = 7, stackpos = 2},
{x = 1852, y = 1592, z = 7, stackpos = 2},
{x = 1841, y = 1588, z = 7, stackpos = 2},
{x = 1810, y = 1592, z = 7, stackpos = 2},
{x = 1827, y = 1575, z = 7, stackpos = 2},
{x = 1860, y = 1574, z = 7, stackpos = 2},
{x = 1856, y = 1565, z = 7, stackpos = 2},
{x = 1842, y = 1571, z = 6, stackpos = 2},
{x = 1815, y = 1566, z = 7, stackpos = 2},
{x = 1808, y = 1546, z = 7, stackpos = 2},
{x = 1811, y = 1602, z = 7, stackpos = 2},
{x = 1808, y = 1620, z = 7, stackpos = 2},
{x = 1791, y = 1593, z = 7, stackpos = 2} -- No Comma Needed on the Last Light
}

local ret = "The city's streets are lit up. Have a safe evening."
function onTime()
for i = 1, #t do
local light = getTileItemById(t, 1479).uid
if(light > 0) then
doTransformItem(light, 1480)
ret = "The city's streets are lit up. Have a safe evening."
end
end

addEvent(broadcastMessage, 150, ret, MESSAGE_STATUS_DEFAULT)
return true
end
 
It will hang the server possibly crash it if you did that, especially if it is written dynamically.
Your talking at least the minimum of 3 for loops, scanning x,y,z of the width x height for 16 levels of depth
 
@artofwork
is it possible to make it work atleast? to turn on the lights ?
See how some servers freeze when they clean the map, now imagine the same concept except instead of just deleting tiles your transforming tiles from 1 id to another and who knows what is on that tile, i think its more trouble than its worth, but if you had specific coordinates then its not a big deal.
 
Yea, its only those positions i have written in the script, its about 18 lights i think.. But i cant get them working, i dont know why..
I only get broadcast "The city's streets are lit up. Have a safe evening"

But the lights dont turn on (i have all lights id 1479, it suppose to change to 1480) automatic from script, but i dont know why it does not do that.. i dont have any errors either.

@artofwork
 
This is just off the top of my head, just an example
Code:
local width = 1000
local height = 1000
local lightFrom = 1479
local lightTo = 1480

function onTime()
    for z = 0, 16 do -- layers of the map
        for y = 0, height do -- height of the map
            for x = 0, width do -- width of the map
                local light = getTileItemById({x, y, z}, lightFrom).uid
                if(light > 0) then
                    doTransformItem(light, lightTo)
                end
            end
        end
    end
end

What does width and height stand for?
 
@artofwork

Could you make the lights on these positions only turn on?

Code:
{x = 1826, y = 1565, z = 7, stackpos = 2},
{x = 1837, y = 1569, z = 7, stackpos = 2},
{x = 1820, y = 1551, z = 7, stackpos = 2},
{x = 1874, y = 1591, z = 7, stackpos = 2},
{x = 1864, y = 1598, z = 7, stackpos = 2},
{x = 1851, y = 1603, z = 7, stackpos = 2},
{x = 1845, y = 1597, z = 7, stackpos = 2},
{x = 1852, y = 1592, z = 7, stackpos = 2},
{x = 1841, y = 1588, z = 7, stackpos = 2},
{x = 1810, y = 1592, z = 7, stackpos = 2},
{x = 1827, y = 1575, z = 7, stackpos = 2},
{x = 1860, y = 1574, z = 7, stackpos = 2},
{x = 1856, y = 1565, z = 7, stackpos = 2},
{x = 1842, y = 1571, z = 6, stackpos = 2},
{x = 1815, y = 1566, z = 7, stackpos = 2},
{x = 1808, y = 1546, z = 7, stackpos = 2},
{x = 1811, y = 1602, z = 7, stackpos = 2},
{x = 1808, y = 1620, z = 7, stackpos = 2},
{x = 1791, y = 1593, z = 7, stackpos = 2}
 
I just did look up

Ok thanks, this is alright ?

Code:
local width = 1000
local height = {x = 1826, y = 1565, z = 7},
{x = 1837, y = 1569, z = 7},
{x = 1820, y = 1551, z = 7},
{x = 1874, y = 1591, z = 7},
{x = 1864, y = 1598, z = 7},
{x = 1851, y = 1603, z = 7},
{x = 1845, y = 1597, z = 7},
{x = 1852, y = 1592, z = 7},
{x = 1841, y = 1588, z = 7},
{x = 1810, y = 1592, z = 7},
{x = 1827, y = 1575, z = 7},
{x = 1860, y = 1574, z = 7},
{x = 1856, y = 1565, z = 7},
{x = 1842, y = 1571, z = 6},
{x = 1815, y = 1566, z = 7},
{x = 1808, y = 1546, z = 7},
{x = 1811, y = 1602, z = 7},
{x = 1808, y = 1620, z = 7},
{x = 1791, y = 1593, z = 7}
local lightFrom = 1479
local lightTo = 1480

function onTime()
    for z = 0, 16 do -- layers of the map
        for y = 0, height do -- height of the map
            for x = 0, width do -- width of the map
                local light = getTileItemById({x, y, z}, lightFrom).uid
                if(light > 0) then
                    doTransformItem(light, lightTo)
                end
            end
        end
    end
end
 
This on the other hand is if you want to try and search the whole map, but I don't even know if it will work, all i did write out the theory
Thats what you do when you write code, you write out how you think it should work, doesn't always work tho until you try it out.. soo try it out lol
Code:
local width = 1000
local height = 1000
local lightFrom = 1479
local lightTo = 1480

function onTime()
    for z = 0, 16 do -- layers of the map
        for y = 0, height do -- height of the map or y coordinate
            for x = 0, width do -- width of the map or x coordinate
                local light = getTileItemById({x, y, z}, lightFrom).uid
                if(light > 0) then
                    doTransformItem(light, lightTo)
                end
            end
        end
    end
    return true
end

I already tried that script too, but gives me massive laggs and then at the end it says "Could not execute event "nightlights" and nothing happens ingame

EDIT: Im using TFS 0.4 Rev 3884.
 

Similar threads

Back
Top