[help needed]M.I.L.A. 0.7 !UPDATE! [community][mod][api]

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

[help needed]M.I.L.A. 0.7 !UPDATE! [community][mod][api]

by azekill_DIABLO » Thu Aug 18, 2016 18:15

It fits for Mobs Intelligence : Lightweight Api

Image
Website

Features :
  • Smoothly moving Mobs
  • Flying mobs
  • Physics
  • Healthbar
  • Spawneggs
  • Ability to climb blocks
  • Hostile monsters
  • Passive animals
  • Rotating entities
  • A "/mila_clean" chat command
  • Very flexible mobs definition
  • Unlaggy dropping system
  • Meat that you can cook and eat
  • Soon swimming

This is an API so it don't add mobs. You need to use another mod to get the entities!

+ List of mods that use the API :


[On Github] the API.
[Download] from github.
Last edited by azekill_DIABLO on Sat Feb 18, 2017 13:13, edited 40 times in total.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: M.I.L.A.

by pithy » Thu Aug 18, 2016 22:02

I bet it will have bugs.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Fri Aug 19, 2016 09:40

e'
Last edited by azekill_DIABLO on Thu Oct 13, 2016 19:39, edited 1 time in total.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: M.I.L.A.

by pithy » Fri Aug 19, 2016 14:45

sorry thought it be an ok thing to say because your signature says "i'm an exelent bug-maker(yeah...i know...i have a bad reputation)",
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Fri Aug 19, 2016 17:10

Yeah. i already know that :)
i'm encountering some problems but i will find a solution :D
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: M.I.L.A.

by Sokomine » Fri Aug 19, 2016 20:07

azekill_DIABLO wrote:
pithy wrote:I bet it will have bugs.

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?

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.
A list of my mods can be found here.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Sat Aug 20, 2016 09:36

you're true.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: M.I.L.A.

by taikedz » Tue Aug 23, 2016 22:36

I quite like mobs_redo... but am intrigued!

Post github and collab? You should set out aims rules and target design so people know what you are likely to accept.

Je fais traducs si tu veux :-P
 

User avatar
octacian
Member
 
Posts: 408
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian

Re: M.I.L.A.

by octacian » Wed Aug 24, 2016 00:06

Why do so many people want monsters? Monsters have ruined almost every game I know of. Real life animals are just as challenging if that's what people want.
God isn't dead!

My Coolest Mods:
MicroExpansion, Working Computers, Interchangeable Hands

Check out my YouTube channel! (octacian)
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: M.I.L.A.

by taikedz » Wed Aug 24, 2016 00:42

So you dont want mobs on your servers? Fine.

Why did you bother entering a discussion for those who do?
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Wed Aug 24, 2016 12:33

A little problem is that the register entity fonction is not very well defined... What are the basics arguments i can use? like health or speed?i didn't found anything about it....
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: M.I.L.A.

by taikedz » Wed Aug 24, 2016 13:40

As far as I am aware, entities have no such thing as HP - that's something you define for yourself.

you can do

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_entity("modname:entityname", {
type = "milamob",
hp = 40,
mp = 100,
speed = 2,
speed_on_speed = 30,
name = "Gandalf",
}
)


And the entity will carry that. It is up to your own code to then manage the HP as you want it to.

When the HP reaches zero, it is your code's responsibility to remove the lua entity from te world.

There is no such thing as a mob at minetest level. Just lua entities.
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: M.I.L.A.

by TenPlus1 » Wed Aug 24, 2016 15:09

Entities have the 'hp_max' flag to set health and will automatically remove points for different tools used on it.
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: M.I.L.A.

by taikedz » Wed Aug 24, 2016 15:22

Hi azekill,

Following TenPlus1's post, yes indeed, there is an HP. Check the documentation for LuaEntitySAO. I should have too, before replying so fast :-P

http://dev.minetest.net/LuaEntitySAO

You call register_entity with the name of the entity, then a table with the default values you want your entity to have.

I will confess that I am by no means an expert on this - just I have been picking at TenPlus1's mobs_redo so as to determine how to modify mob behaviour at load-time for my game, without changing his code.... so..... take my advice with my basic level knowledge in mind :-P

Still, if you thought that Minetest engine had some built-in system for mobs so that you could make something even simpler than mobs_redo or mobf, well... go talk to the core dev team to ask them for an engine-level API :-)



There is a lot of work to be done here, and I think that rather than building a new mob framework, you should probably fork an existing mob engine and remove things that you think are surplus to a basic mob engine.

Bearing in mind the goal of MILA to be lightweight, I expect the following things need to be taken into account at minimum, and at most:

    Prototype:

    Default data:
    * A default routine to move towards a target position
    * A default routine to seek for players
    * A default attack routine
    * A default runaway routine
    * A default routine to handle being punched
    * A default state = "idle"

    Instances:
    * Current state -- whether the mob is walking, running, or attacking, or merely idle

    Mod-provided data:
    * behaviour = one of {"hostile","friendly"}
    * Mesh -- the meshfile to use
    * Texture -- texture to use on the mesh
    * animation keyframe indices, with animation speeds
    * A right-click callback routine

Calling the library -- I suggest the following be a reference example:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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"},
})


The key areas that MILA would have to manage then will be:


    * locating targets
    * moving the mob
    * animating the mob
    * handling the activity state
    * spawning mobs to populate the world
    * spawning from egg placement
    * removing mobs to prevent overpopulation

This should be all that is necessary for a MILA mob. Many fancy things such as spawn time and conditions, environment damage, flight, eating, reproduction etc are absent from this, to keep it light.

Any thoughts? Anything I missed? Should an effort for a lightweight framework be its own project or a pared-down fork of something else?

You're going to need a good reason to be making a new mob engine from scratch when we already have a couple of good, well-featured ones ;-)
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Wed Aug 24, 2016 16:58

yeah i will have a lot of work. lol. feel dumb right now.
But thank you for your answers!

Edit: looks like mob redo with 'mila' instead of 'mobs' :D
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: M.I.L.A.

by taikedz » Wed Aug 24, 2016 17:06

azekill_DIABLO wrote:Edit: looks like mob redo with 'mila' instead of 'mobs' :D


Yes, because that's what I've been working with until now :-P But I feel they would be the appropriate minimum.

Also there a re a lot less options :-)
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Wed Aug 24, 2016 17:08

yes. i'm working on this right now. looks not so hard to register a working entity.

Edit i say that and i will post something like : "argh keeps bugging" in 10 seconds
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Wed Aug 24, 2016 17:21

god seems like it worked holy... oh a bug.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Wed Aug 24, 2016 17:52

ideas of code to make an entity move? i use setacceleration but it kinda do, nothing at all. please help! remenber it's a community project!
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: M.I.L.A.

by taikedz » Wed Aug 24, 2016 18:47

azekill_DIABLO wrote:ideas of code to make an entity move? i use setacceleration but it kinda do, nothing at all.


http://dev.minetest.net/LuaEntitySAO

You want setvelocity(vector)

Probably something like this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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})


azekill_DIABLO wrote:please help!


Remember to search, and try to understand what already exists.

This is how mobs_redo implements walking

https://github.com/tenplus1/mobs_redo/b ... 1295-L1331 (highglighted code)

azekill_DIABLO wrote:remenber it's a community project!


Really? It looks like you are working on the code in secret.... :-P

You did not post any URL where we can see the code, so you have not yet opened it to the community ;-)
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: M.I.L.A.

by azekill_DIABLO » Thu Aug 25, 2016 10:04

sorry
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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,})

it looks like that

the problem is here
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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)

looks like getpos is nil.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: M.I.L.A.

by taikedz » Thu Aug 25, 2016 10:23

[EDIT - code has been subsequently posted!]

Don't care. If you want help, post the code.

Show your project while you develop it, and we'll believe you're serious. Bad code can be improved only if it is seen.

Hidden code is not worth a community's time. Not in Minetest, not in Apache, not in Firefox, not anywhere.
Last edited by taikedz on Thu Aug 25, 2016 11:50, edited 1 time in total.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [help needed]M.I.L.A. [community][mod][api]

by azekill_DIABLO » Thu Aug 25, 2016 10:40

i've pasted it in my last post. and in my 1st post too
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: [help needed]M.I.L.A. [community][mod][api]

by taikedz » Thu Aug 25, 2016 11:08

\o/

:D

Will take a look!
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: [help needed]M.I.L.A. [community][mod][api]

by taikedz » Thu Aug 25, 2016 11:37

[EDIT corrected the step routine]

azekill_DIABLO wrote:i've pasted it in my last post. and in my 1st post too


Thanks :)

So here's an improved version and some notes in the comments. Try following the logic there.

First adjustment: everything defined for mila should be a function associated with the mila object

Second adjustment: you need to pass the functions to the lua entity after it is created

Third adjustment: do not require the mod creator who uses mila to make their own walking algorithms. We need to define that.

This is what the code should look like. There are probably still some bugs, but they should be fewer.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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,
})
Last edited by taikedz on Thu Aug 25, 2016 18:50, edited 2 times in total.
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: [help needed]M.I.L.A. [community][mod][api]

by taikedz » Thu Aug 25, 2016 12:03

I adjusted the code in the forum post.

I also added a github repo so as to share the demo with clean code. I made there a register_egg function too
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [help needed]M.I.L.A. [community][mod][api]

by azekill_DIABLO » Thu Aug 25, 2016 13:49

pls don't do this, every thing will be done on my github account, since it's my mod :)

Thanks for the code.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [help needed]M.I.L.A. [community][mod][api]

by azekill_DIABLO » Thu Aug 25, 2016 13:56

hey he doesn't like the luae !

keep saying it's nil.

it still not move... checking the code.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [help needed]M.I.L.A. [community][mod][api]

by azekill_DIABLO » Thu Aug 25, 2016 14:10

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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)

   --find entities
   local entitylist = minetest.get_objects_inside_radius(s, self.view_range)
   if not entitylist then return end -- no players in range, stand still.
   
   -- list players and mobs
   local moblist = {}
   local playerlist = {}
   for _,entity in pairs(entitylist) do
      if entity:is_player() then
         playerlist = playerlist + entity
      elseif entity.mobengine and entity.mobengine == "milamob" then
         moblist = moblist + entity
      end
   end

   -- if player found, choose one
   local playerobj = nil
   if playerlist then
      playerobj = playerlist[math.random(1,#playerlist)]
   end
   
   
   -- move towards player if exists
   if playerobj then
      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
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,
   })
  --mila.mila_step = luae.on_step -- add moving function ourselves, use '.' notation to access the variables' references, don't call them
end

--register the egg function

function mila:add_egg(name,description,inventory_image,wield_image)
  minetest.register_craftitem(name, {
     description = description,
     inventory_image = inventory_image,
     wield_image = wield_image,
     wield_scale = {x = 1, y = 1, z = 0.5},
     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, name)
        end
     end,
  })
end

--try to register the first entity.

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,
})
   
--then the egg

mila:add_egg("mila:sheep", {
   description = "Sheep Egg",
   inventory_image = "default_dirt.png",
   wield_image = "default_dirt.png",
   on_place = on_place,
})

here is the whole code!
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
octacian
Member
 
Posts: 408
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian

Re: M.I.L.A.

by octacian » Thu Aug 25, 2016 17:12

taikedz wrote:So you dont want mobs on your servers? Fine.

Why did you bother entering a discussion for those who do?


I do want mobs. I just see no point in Monsters. Real life animals are good enough. And, BTW, what we really need is a better API in the "core" rather than another mod (no offence).

EDIT: where did I get the idea that this was for monsters specifically? IDK, but I'd possibly be willing to help in the future once everything is on GitHub. However, if it does transition from real life animals to monsters... :D
God isn't dead!

My Coolest Mods:
MicroExpansion, Working Computers, Interchangeable Hands

Check out my YouTube channel! (octacian)
 

Next

Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 10 guests

cron