2 Commits 9e103f7814 ... 7b1da36479

Author SHA1 Message Date
  Freeman 7b1da36479 uwu.timer as func 1 year ago
  Freeman 798212505a uwu entity spawn optional in settings 1 year ago
4 changed files with 54 additions and 46 deletions
  1. 41 39
      entity.lua
  2. 6 3
      functions.lua
  3. 4 4
      nodes.lua
  4. 3 0
      settingtypes.txt

+ 41 - 39
entity.lua

@@ -22,6 +22,7 @@
 -----------------UWU-----------------
 
 local S = core.get_translator(core.get_current_modname())
+local uwu_spawn = core.settings:get_bool("uwu.entity_spawn") or true
 
 local uwu_big = {
    description = S("UwU"),
@@ -179,45 +180,46 @@ local cave_min = mcl_vars.mg_overworld_min
 local cave_max = water_level - 23
 local light_level = 7 --minetest.LIGHT_MAX+1
 
-mcl_mobs:spawn_specific(
-   "uwu:uwu_tiny",
-   "overworld",
-   "ground",
-   cave_biomes,
-   0,
-   light_level,
-   30, -- interval
-   35000, -- chance
-   1, -- count
-   cave_min,
-   cave_max)
-
-mcl_mobs:spawn_specific(
-   "uwu:uwu_small",
-   "overworld",
-   "ground",
-   cave_biomes,
-   0,
-   light_level,
-   30, -- interval
-   85000, -- chance
-   1, -- count
-   cave_min,
-   cave_max)
-
-mcl_mobs:spawn_specific(
-   "uwu:uwu_big",
-   "overworld",
-   "ground",
-   cave_biomes,
-   0,
-   light_level,
-   30, -- interval
-   55000, -- chance
-   1, -- count
-   cave_min,
-   cave_max)
-
+if uwu_spawn then
+	mcl_mobs:spawn_specific(
+		"uwu:uwu_tiny",
+		"overworld",
+		"ground",
+		cave_biomes,
+		0,
+		light_level,
+		30, -- interval
+		35000, -- chance
+		1, -- count
+		cave_min,
+		cave_max)
+	
+	mcl_mobs:spawn_specific(
+		"uwu:uwu_small",
+		"overworld",
+		"ground",
+		cave_biomes,
+		0,
+		light_level,
+		30, -- interval
+		85000, -- chance
+		1, -- count
+		cave_min,
+		cave_max)
+	
+	mcl_mobs:spawn_specific(
+		"uwu:uwu_big",
+		"overworld",
+		"ground",
+		cave_biomes,
+		0,
+		light_level,
+		30, -- interval
+		55000, -- chance
+		1, -- count
+		cave_min,
+		cave_max)
+end
 
 mcl_mobs.register_egg("uwu:uwu_tiny", S("UwU tiny"), "#FEE41A", "#ED5FF9")
 mcl_mobs.register_egg("uwu:uwu_small", S("UwU small"), "#FEE41A", "#ED5FF9")

+ 6 - 3
functions.lua

@@ -22,9 +22,12 @@ local S = core.get_translator(core.get_current_modname())
 
 uwu = {}
 
-uwu.timer = math.random(30, 50)
 uwu.growhappiness = 50
 
+function uwu.timer()
+	return math.random(30, 50)
+end
+
 function uwu.newpos(pos)
    -- return nearest air node pos or nil
    local up = {x=pos.x, y=pos.y+1, z=pos.z}
@@ -67,7 +70,7 @@ function uwu.walk(pos)
    if newpos then
       core.set_node(newpos, oldnode)
       core.get_meta(newpos):from_table(oldnodemeta)
-      core.get_node_timer(newpos):start(uwu.timer)
+      core.get_node_timer(newpos):start(uwu.timer())
       core.set_node(pos, {name = "air"})
    end
 end
@@ -163,7 +166,7 @@ function uwu.grow(pos)
 	 core.set_node(newpos, {name = "uwu:little"} )
 	 uwu.add_happiness(pos, 1-uwu.growhappiness)
 	 uwu.add_happiness(newpos, 1-uwu.growhappiness)
-	 core.get_node_timer(newpos):start(uwu.timer)
+	 core.get_node_timer(newpos):start(uwu.timer())
 	 uwu.say_uwu(pos)
       end
    end

+ 4 - 4
nodes.lua

@@ -46,7 +46,7 @@ core.register_node("uwu:block", {
 
       after_place_node = function(pos, placer, itemstack, pointed_thing)
 	 uwu.add_happiness(pos, 1)
-	 core.get_node_timer(pos):start(uwu.timer)
+	 core.get_node_timer(pos):start(uwu.timer())
       end,
       
       on_rightclick = function(pos, node, clicker, itemstack)
@@ -64,7 +64,7 @@ core.register_node("uwu:block", {
 	    uwu.rotate(pos)
 	    uwu.walk(pos)
 	 end
-	 core.get_node_timer(pos):start(uwu.timer)
+	 core.get_node_timer(pos):start(uwu.timer())
       end,
 })
 
@@ -99,7 +99,7 @@ core.register_node("uwu:little", {
 
       after_place_node = function(pos, placer, itemstack, pointed_thing)
 	 uwu.add_happiness(pos, 1)
-	 core.get_node_timer(pos):start(uwu.timer)
+	 core.get_node_timer(pos):start(uwu.timer())
       end,
       
       on_rightclick = function(pos, node, clicker, itemstack)
@@ -117,7 +117,7 @@ core.register_node("uwu:little", {
 	    uwu.rotate(pos)
 	    uwu.walk(pos)
 	 end
-	 core.get_node_timer(pos):start(uwu.timer)
+	 core.get_node_timer(pos):start(uwu.timer())
       end,
 
       on_punch = function(pos, node, puncher, pointed_thing)

+ 3 - 0
settingtypes.txt

@@ -0,0 +1,3 @@
+
+# UwU creatures spawn in caves
+uwu.entity_spawn (UwU creatures spawn) bool true