Mobs Intelligence : Lightweight Api > see also Website :
Spoiler
Links and Download :
[On Github] the API.[Download] from github.
┬┴┬┴┤ ͜ʖ ͡°) ├┬┴┬┴ Have fun!
Might as well see that comment in a positive way :-) Any reasonably large (not trivial) programming porject *will* have bugs. They're hard to avoid. Some very few exceptional projects manage to get by with very few bugs, but those are extremly rare projects. TeX comes to mind. And then..er...there might be similar ones, but they're few and sparse.azekill_DIABLO wrote:Hey, please don't say things like that. If you think it will have bugs before the project is really started, you think it's funny?pithy wrote: I bet it will have bugs.
Code: Select all
minetest.register_entity("modname:entityname", {
type = "milamob",
hp = 40,
mp = 100,
speed = 2,
speed_on_speed = 30,
name = "Gandalf",
}
)
Code: Select all
mila:register_mob("modpack:mobname",
{
mesh = "meshname.x",
textures = {"texture_1.png","texture_2.png"},
hp_max = 30,
animations = {
walk = {start=0,end=20,speed=10},
run = {start=0,end=20,speed=20},
attack = {start=21,end=30,speed=5},
idle = {start=31,end=35,speed = 5}
},
behaviour = "friendly",
})
mila:register_egg("modpack:mobname",{
inventory_image = "texture.png"
})
mila:register_spawn("modpack:mobname",{
min_alt = -100,
max_alt = 31000,
spawn_on = "default:dirt_with_grass",
spawn_by = {"default:tree","default:water_source","group:flowers"},
})
Yes, because that's what I've been working with until now :-P But I feel they would be the appropriate minimum.azekill_DIABLO wrote:Edit: looks like mob redo with 'mila' instead of 'mobs' :D
http://dev.minetest.net/LuaEntitySAOazekill_DIABLO wrote:ideas of code to make an entity move? i use setacceleration but it kinda do, nothing at all.
Code: Select all
local speed = 1
local playerposition = playerobject:getpos()
local mobposition = mobobject:getpos()
local direction = vector.direction(playerposition,mobposition)
local displacement = vector.distance(playerposition,mobposition)
mobobject:setvector({x=speed*direction.x/displacement, y=speed*direction.y/displacement,z=speed*direction.z/displacement})
Remember to search, and try to understand what already exists.azekill_DIABLO wrote:please help!
Really? It looks like you are working on the code in secret.... :-Pazekill_DIABLO wrote:remenber it's a community project!
Code: Select all
--say that Mila is running.
mila = {}
--for the entities
player= {}
--register some basic things. (here the move. needs some improvements)
local speed = 1
local playerposition = player:getpos()
local mobposition = self.object:getpos()
local direction = vector.direction(playerposition,mobposition)
local displacement = vector.distance(playerposition,mobposition)
--register the first function (add).
function mila.add_entity(name,def)
minetest.register_entity(name, {
mesh = def.mesh,
textures = def.textures,
hp_max = def.hp_max,
on_step = def.on_step,
})
end
--try to register the first entity.
mila.add_entity("mila:attack", {
hp_max = 30,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
mesh = "sheep.x",
textures = {"default_dirt.png"},
on_step = {obj:setvector({x=speed*direction.x/displacement, y=speed*direction.y/displacement,z=speed*direction.z/displacement})},
})
--then the egg. (needs some work to be a function tough)
minetest.register_craftitem("mila:sheep_egg", {
description = "Sheep Egg",
inventory_image = "default_dirt.png",
wield_image = "default_dirt.png",
wield_scale = {x = 1, y = 1, z = 0.5},
liquids_pointable = true,
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
pointed_thing.under.y = pointed_thing.under.y + 1
minetest.add_entity(pointed_thing.under, "mila:attack")
end
end,})
Code: Select all
local speed = 1
local playerposition = player:getpos()
local mobposition = self.object:getpos()
local direction = vector.direction(playerposition,mobposition)
local displacement = vector.distance(playerposition,mobposition)
Thanks :)azekill_DIABLO wrote:i've pasted it in my last post. and in my 1st post too
Code: Select all
--define a global mila table
mila = {}
--register some basic things. (here the move. needs some improvements)
function mila:mila_step(self,dtime) -- we define a general stepping function that we will give to all mobs that get registered
--find a player
playerlist = minetest.get_objects_inside_radius(s, self.view_range)
if not playerlist then return end -- no players in range, stand still.
-- if player found, choose one
local playerobj = playerlist[math.random(1,#playerlist)] -- number between 1 and number of items in playerlist
-- move towards player
local playerposition = playerobject:getpos()
local mobposition = self:getpos() -- .... it should be self I think. else try self.ref:getpos()
local direction = vector.direction(playerposition,mobposition)
local displacement = vector.distance(playerposition,mobposition)
self:setvector({x=self.speed*direction.x/displacement, y=self.speed*direction.y/displacement,z=self.speed*direction.z/displacement})
end
--register the first function (add).
function mila:add_entity(name,def) -- define and access functions on Lua tables using the ":" operator
local luae = minetest.register_entity(name, {
mesh = def.mesh,
textures = def.textures,
hp_max = def.hp_max,
speed = def.speed, -- register speed per entity, not globally
view_range = def.view_range,
-- on_step = def.on_step, -- don't require the modder to define this function.
})
luae.on_step = mila.mila_step -- add moving function ourselves, use '.' notation to access the variables' references, don't call them
end
--try to register the first entity.
--mila.add_entity("mila:attack", { -- you meant mila:sheep, right?
mila:add_entity("mila:sheep", { -- define and access functions on Lua tables using the ":" operator
hp_max = 30,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
mesh = "sheep.x",
textures = {"default_dirt.png"},
speed = 1,
view_range = 5,
--entites should not need to define their own walking algorithms - this is what the framework should be doing !
--on_step = {obj:setvector({x=speed*direction.x/displacement, y=speed*direction.y/displacement,z=speed*direction.z/displacement})},
})
--then the egg. (needs some work to be a function tough)
minetest.register_craftitem("mila:sheep_egg", {
description = "Sheep Egg",
inventory_image = "default_dirt.png",
wield_image = "default_dirt.png",
wield_scale = {x = 1, y = 1, z = 0.5},
liquids_pointable = true, -- oh le pauvre! :-P
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
pointed_thing.under.y = pointed_thing.under.y + 1
local mobe = minetest.add_entity(pointed_thing.under, "mila:sheep") -- sheep!
mobe.hp = math.ceil(math.random(mobe.hp_max*0.8,mobe.hp_max) ) -- set a random actual HP between 80-100% of mob's max_hp
end
end,
})