External Publication
Visit Post

Problems • Stupid Lua Error!

Luanti Forums - Index page [Unofficial] February 27, 2026
Source

ModError: Failed to load and run script from C:\Users\ThePropheticWarrior\AppData\Roaming\Minetest\mods\mobs_api\init.lua: ...cWarrior\AppData\Roaming\Minetest\mods\mobs_api\init.lua:181: '}' expected (to close '{' at line 62) near '_mobs_api_health_max' Check debug.txt for details.

Here is what is actually in the file:

function mobs_api.register_mob(def) if not def.name then return false, "Needs a name!" end if not def.health_max then return false, "Needs health_max = <num> field!" end

local entity = { get_staticdata = function(self) local table = {}

for k, v in pairs(self) do if not(type(v) == "userdata" or type(v) == "function") then table[k] = v end end

return core.write_json(table) end,

on_activate = function(self, staticdata, dtime_s) if staticdata and staticdata ~= "" then local table = core.parse_json(staticdata) or {} for k, v in pairs(table) do self[k] = v end

elseif not self._mobs_api_spawned then if self._mobs_api_health_min then self.object:set_hp(mobs_api.pr:next(self._mobs_api_health_min, self._mobs_api_health_max)) end

self._mobs_api_spawned = true

if self._mobs_api_on_spawn then self._mobs_api_on_spawn(self) end end end,

on_deactivate = function(self, removal) if (not removal) and (self._mobs_api_static ~= true) then self.object:remove() return end end,

on_step = function(self, dtime, moveresult) if not self._mobs_api_spawned then return end

self._mobs_api_last_step = self._mobs_api_last_step + dtime

if self._mobs_api_last_step >= mobs_api.step_time then self._mobs_api_age = self._mobs_api_age + self._mobs_api_last_step if self._mobs_api_life_time and self._mobs_api_age >= self._mobs_api_life_time then self.object:remove() return end

local m_pos = self.object:get_pos()

local despawn = true for object in core.objects_inside_radius(m_pos, self._mobs_api_despawn_distance) do if object:is_player() then despawn = false break end end if despawn then self.object:remove() return end

if self._mobs_api_chase_distance ~= nil then local player_to_chase = nil for object in core.objects_inside_radius(self.object:get_pos(), self._mobs_api_chase_distance) do if object:is_player() then player_to_chase = object break end end

if player_to_chase ~= nil then local p_pos = player_to_chase:get_pos() local dir = p_pos - m_pos local mag = math.sqrt(dir.xdir.x + dir.ydir.y + dir.z*dir.z)

if mag > 2 then local v = vector.new(dir.x / mag, dir.y / mag, dir.z / mag) self.object:set_velocity(v * self._mobs_api_walk_speed + vector.new(0, self._mobs_api_gravity, 0)) if self._mobs_api_on_chase ~= nil then self._mobs_api_on_chase(self, player_to_chase) end

else self.object:set_velocity(vector.new(0, self._mobs_api_gravity, 0)) if self._mobs_api_on_at_player ~= nil then self._mobs_api_on_at_player(self, player_to_chase)

elseif self._mobs_api_on_stop ~= nil then self._mobs_api_on_stop(self) end end

else self.object:set_velocity(vector.new(0, self._mobs_api_gravity, 0))

if self._mobs_api_on_idle ~= nil then self._mobs_api_on_idle(self) end end end

if self._mobs_api_on_step ~= nil then self._mobs_api_on_step(self, dtime, moveresult) end

self._mobs_api_last_step = 0 end end,

on_punched = def.on_punched, on_rightclick = def.on_rightclick

-- Vars _mobs_api_health_max = def.health_max, _mobs_api_static = def.static, _mobs_api_despawn_distance = def.despawn_distance or 32, _mobs_api_chase_distance = def.chase_distance, _mobs_api_walk_speed = def.walk_speed or 1, _mobs_api_gravity = -(def.gravity or 0), _mobs_api_spawned = false, _mobs_api_last_step = 0, _mobs_api_age = 0,

-- Callbacks _mobs_api_on_spawn = def.on_spawn, _mobs_api_life_time = def.life_time, _mobs_api_on_step = def.on_step, _mobs_api_on_chase = def.on_chase, _mobs_api_on_stop = def.on_stop, _mobs_api_on_at_player = def.on_at_player, _mobs_api_on_idle = def.on_idle,

_mobs_api_spawned = false, }

It is definately there, at the end of above text - at line 282 (using Notepad++)! What, is it too far away or something?

I think either Lua needs to be updated, or Luanti needs help!

Statistics: Posted by ThePropheticWarrior — Fri Feb 27, 2026 22:55


Discussion in the ATmosphere

Loading comments...