Guest User

Untitled

a guest
Aug 29th, 2012
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --flatland mod
  2. --by kddekadenz
  3.  
  4.  
  5. --VARIABLES
  6.  
  7. n_top = "default:dirt_with_grass"
  8. n_dn = "default:dirt"
  9. lvl = 2
  10.  
  11. xlimit = 1000
  12. ylimit = 1000
  13. zlimit = 100
  14.  
  15.  
  16. --CUSTOMIZING
  17.  
  18. --TODO: add possibility to change level ingame (previous tries made the game crash)
  19. --TODO: prevent game from crashing when typing false name
  20.  
  21. minetest.register_on_chat_message(function(name, message, playername, player)
  22.     local cmd = "/nt"
  23.     if message:sub(0, #cmd) == cmd then
  24.     nodet = string.match(message, cmd.." (.*)")
  25.     if nodet ~= nil then
  26.     n_top = nodet
  27.     minetest.chat_send_player(name, "Node at level setted to: " ..nodet)
  28.     return true
  29.     end
  30.     minetest.chat_send_player(name, 'usage: '..cmd..'node at level')
  31.     return true
  32.     end
  33. end)
  34.  
  35.  
  36. minetest.register_on_chat_message(function(name, message, playername, player)
  37.     local cmd = "/nd"
  38.     if message:sub(0, #cmd) == cmd then
  39.     noded = string.match(message, cmd.." (.*)")
  40.     if noded ~= nil then
  41.     n_dn = noded
  42.     minetest.chat_send_player(name, "Node below level setted to: " ..noded)
  43.     return true
  44.     end
  45.     minetest.chat_send_player(name, 'usage: '..cmd..'node below level')
  46.     return true
  47.     end
  48. end)
  49.  
  50.  
  51. minetest.register_on_chat_message(function(name, message, playername, player)
  52.     local cmd = "/water"
  53.     if message:sub(0, #cmd) == cmd then
  54.     n_top = "water_source"
  55.     n_dn = "water_source"
  56.     minetest.chat_send_player(name, "Enabled ocean mode")
  57.     return true
  58.     end
  59. end)
  60.  
  61.  
  62. minetest.register_on_chat_message(function(name, message, playername, player)
  63.     local cmd = "/cloud"
  64.     if message:sub(0, #cmd) == cmd then
  65.     n_top = "cloud"
  66.     n_dn = "air"
  67.     minetest.chat_send_player(name, "Enabled cloud mode")
  68.     return true
  69.     end
  70. end)
  71.  
  72. minetest.register_on_chat_message(function(name, message, playername, player)
  73.     local cmd = "/desert"
  74.     if message:sub(0, #cmd) == cmd then
  75.     n_top = "desert_sand"
  76.     n_dn = "desert_stone"
  77.     minetest.chat_send_player(name, "Enabled desert mode")
  78.     return true
  79.     end
  80. end)
  81.  
  82.  
  83. minetest.register_on_chat_message(function(name, message, playername, player)
  84.     local cmd = "/glass"
  85.     if message:sub(0, #cmd) == cmd then
  86.     n_top = "glass"
  87.     n_dn = "air"
  88.     minetest.chat_send_player(name, "Enabled glass mode")
  89.     return true
  90.     end
  91. end)
  92.  
  93. minetest.register_on_chat_message(function(name, message, playername, player)
  94.     local cmd = "/sand"
  95.     if message:sub(0, #cmd) == cmd then
  96.     n_top = "sand"
  97.     n_dn = "sand"
  98.     minetest.chat_send_player(name, "Enabled sand mode")
  99.     return true
  100.     end
  101. end)
  102.  
  103. minetest.register_on_chat_message(function(name, message, playername, player)
  104.     local cmd = "/grass"
  105.     if message:sub(0, #cmd) == cmd then
  106.     n_top = "dirt_with_grass"
  107.     n_dn = "dirt"
  108.     minetest.chat_send_player(name, "Enabled grass mode")
  109.     return true
  110.     end
  111. end)
  112.  
  113.  
  114.  
  115. --GENERATING
  116.  
  117. minetest.register_on_generated(function(minp, maxp)
  118.     if minetest.setting_getbool("flatland") then
  119.         for x = -xlimit, xlimit do
  120.             for z = -zlimit, zlimit do
  121.                 for ly = -ylimit, ylimit do
  122.                 local y = ylimit + -ylimit - ly
  123.                 local p = {x = x, y = y, z = z}
  124.                         if y == lvl then
  125.                         minetest.env:add_node(p, {name=n_top})
  126.                         end
  127.                             if y < lvl then
  128.                             minetest.env:add_node(p, {name=n_dn})
  129.                             end
  130.                 end
  131.             end
  132.         end
  133.     end
  134.     end
  135. end)
  136.  
  137. minetest.register_on_generated(function(minp, maxp)
  138.     if minetest.setting_getbool("flatland") then
  139.         for x = minp.x, maxp.x do
  140.             for z = minp.z, maxp.z do
  141.                 for ly = minp.y, maxp.y do
  142.                 local y = maxp.y + minp.y - ly
  143.                 local p = {x = x, y = y, z = z}
  144.                     if y > lvl then
  145.                     minetest.env:remove_node(p)
  146.                     end
  147.  
  148.                     if y > ylimit then
  149.                     minetest.env:remove_node(p)
  150.                     end
  151.  
  152.  
  153.                     if x > xlimit then
  154.                     minetest.env:remove_node(p)
  155.                     end
  156.  
  157.  
  158.                     if z > zlimit then
  159.                     minetest.env:remove_node(p)
  160.                     end
  161.  
  162.                     if y < -ylimit then
  163.                     minetest.env:remove_node(p)
  164.                     end
  165.  
  166.  
  167.                     if x < -xlimit then
  168.                     minetest.env:remove_node(p)
  169.                     end
  170.  
  171.  
  172.                     if z < -zlimit then
  173.                     minetest.env:remove_node(p)
  174.                     end
  175.                 end
  176.             end
  177.         end
  178.     end
  179. end)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×