From 3409ac4b543ceaa9580c56da978682e880ca228e Mon Sep 17 00:00:00 2001 From: Leslie Krause Date: Sat, 9 May 2020 08:34:00 -0400 Subject: [PATCH] Build 12 - Closes #19 --- README.txt | 5 ++++- init.lua | 24 +++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 5aeb31e..8039f5f 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -Mobs Lite Mod v1.2 +Mobs Lite Mod v1.3 By Leslie E. Krause Mobs Lite is a fully-working proof of concept for the Extended Motion Mechanics API for @@ -36,6 +36,9 @@ Here are some of the other highlights of the Mobs Lite engine: * Timekeeper helper class ensures efficient dispatching of mob-related callbacks at the appropriate server step. + * Builtin lookup table allows for efficiently iterating over multiple classes of objects + within a specific radius. + * And of course, much much more! Since Mobs Lite is still in early beta, there is the likelihood of lingering bugs. The API diff --git a/init.lua b/init.lua index ce2f0e5..f2daa52 100644 --- a/init.lua +++ b/init.lua @@ -98,7 +98,7 @@ end -------------------- -mobs.effect( pos, amount, texture, min_size, max_size, radius, gravity ) +mobs.effect = function ( pos, amount, texture, min_size, max_size, radius, gravity ) minetest.add_particlespawner({ amount = amount, time = 0.5, @@ -1401,6 +1401,28 @@ mobs.presets = { -------------------- +local emit_defs = { "mobs:griefer_ghost" } + +minetest.register_chatcommand( "mobs", { + description = "Spawn random mobs in the area (for testing purposes or just plain fun).", + privs = { server = true }, + func = function( player_name, param ) + local pos = minetest.get_player_by_name( player_name ):getpos( ) + local total = param ~= "" and tonumber( param ) or 10 + + for count = 1, total do + local index = math.random( #emit_defs ) + local y = pos.y + minetest.registered_entities[ emit_defs[ index ] ].y_offset + 2 + local x = pos.x + math.random( -5, 5 ) + local z = pos.z + math.random( -5, 5 ) + + minetest.add_entity( { x = x, y = y, z = z }, emit_defs[ index ] ) + end + end +} ) + +-------------------- + dofile( minetest.get_modpath( "mobs" ) .. "/extras.lua" ) dofile( minetest.get_modpath( "mobs" ) .. "/monsters.lua" ) dofile( minetest.get_modpath( "mobs" ) .. "/animals.lua" )