Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Map generator
--[[ -Map generator Scripted by: DmilkaSTD- ]] --[[Sky]] local sky = "." --[[Materials]] local materials = { ["Grass"] = "#", ["Water"] = "~", ["Rock"] = "*" } --[[Pixels]] local screen = { -- 5 layer ["5,1"] = sky, ["5,2"] = sky, ["5,3"] = sky, ["5,4"] = sky, ["5,5"] = sky, ["5,6"] = sky, ["5,7"] = sky, ["5,8"] = sky, ["5,9"] = sky, ["5,10"] = sky, --4 layer ["4,1"] = sky, ["4,2"] = sky, ["4,3"] = sky, ["4,4"] = sky, ["4,5"] = sky, ["4,6"] = sky, ["4,7"] = sky, ["4,8"] = sky, ["4,9"] = sky, ["4,10"] = sky, -- 3 layer ["3,1"] = sky, ["3,2"] = sky, ["3,3"] = sky, ["3,4"] = sky, ["3,5"] = sky, ["3,6"] = sky, ["3,7"] = sky, ["3,8"] = sky, ["3,9"] = sky, ["3,10"] = sky, -- 2 layer ["2,1"] = sky, ["2,2"] = sky, ["2,3"] = sky, ["2,4"] = sky, ["2,5"] = sky, ["2,6"] = sky, ["2,7"] = sky, ["2,8"] = sky, ["2,9"] = sky, ["2,10"] = sky, -- 1 layer ["1,1"] = sky, ["1,2"] = sky, ["1,3"] = sky, ["1,4"] = sky, ["1,5"] = sky, ["1,6"] = sky, ["1,7"] = sky, ["1,8"] = sky, ["1,9"] = sky, ["1,10"] = sky, } --[[Max vertical size for grass generation]] local grassVerticalGeneration = 3 local yearTwoDigit = tonumber(os.date("%y")) local dayInMonth = tonumber(os.date("%d")) local dayInWeek = tonumber(os.date("%w")) local hour = tonumber(os.date("%H")) local second = tonumber(os.date("%S")) local minute = tonumber(os.date("%M")) local seed = 5 function mod(n, m) x = n while x > m do x = x / 10 end return x end -- GRASS GENERATION -- for y = 1, grassVerticalGeneration do for x = 1, 10 do if mod(math.floor(minute / second * hour + yearTwoDigit - dayInWeek + dayInMonth + seed), 50) < 15 + yearTwoDigit / second + dayInWeek then screen[tostring(y) .. "," .. tostring(x)] = materials["Grass"] if y~=1 then if screen[tostring(y - 1) .. "," .. tostring(x)] ~= materials["Grass"] then screen[tostring(y) .. "," .. tostring(x)] = materials["Rock"] end end else -- WATER GENERATION -- screen[tostring(y) .. "," .. tostring(x)] = materials["Water"] end seed = minute / second * hour + seed end seed = 0 end -- RENDER -- print("If the map doesnt change, try waiting some time.") for y = 1, 5 do local output = "" for x = 1, 10 do output = output .. screen[tostring(math.abs((y - 1) - 5)) .. "," .. tostring(x)] end print(output) end print("\nStats {\n sky = " .. sky .. "\n grass = " .. materials["Grass"] .. "\n water = " .. materials["Water"] .. "\n rock = " .. materials["Rock"] .. "}")
run
|
edit
|
history
|
help
0
Lua recursion with function
Basic class example
Creating habits v3, Lua
Basic Lehmer RNG implementation using closures
MXR
Truly random numbers with ranges (Lua)
xml panel repeater
multiline string
Dirty Bag 'o Tokens Maker
anti.lua