Skip to content

Commit

Permalink
set min_timer between settlement creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeb187 committed Aug 18, 2018
1 parent 5092a07 commit 8414334
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ settlements.debug = false
-- switch for lvm
settlements.lvm = false
--
-- timer between creation of two settlements
--
settlements.last_settlement = 0;
settlements.min_timer = 5
--
--
-- material to replace cobblestone with
--
Expand Down
17 changes: 14 additions & 3 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--package.cpath = package.cpath .. ";/usr/share/lua/5.2/?.so"
--package.path = package.path .. ";/usr/share/zbstudio/lualibs/mobdebug/?.lua"
--require('mobdebug').start()
package.cpath = package.cpath .. ";/usr/share/lua/5.2/?.so"
package.path = package.path .. ";/usr/share/zbstudio/lualibs/mobdebug/?.lua"
require('mobdebug').start()

settlements = {}
settlements.modpath = minetest.get_modpath("settlements");
Expand Down Expand Up @@ -59,6 +59,13 @@ minetest.register_on_generated(function(minp, maxp)
-- randomly try to build settlements
--
if math.random(1,10)<6 then
--
-- time between cration of two settlements
--
if os.difftime(os.time(), settlements.last_settlement) < settlements.min_timer
then
return
end
--
-- don't build settlement underground
--
Expand Down Expand Up @@ -112,6 +119,10 @@ minetest.register_on_generated(function(minp, maxp)
return
end
--
-- set timestamp of actual settlement
--
settlements.last_settlement = os.time()
--
-- evaluate settlement_info and prepair terrain
--
if settlements.lvm == true
Expand Down

0 comments on commit 8414334

Please sign in to comment.