Page 19 of 23

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun Mar 01, 2020 17:02
by Termos
runs wrote:I've check the lua manual and it has sense: http://www.lua.org/manual/5.2/manual.html#3.5

If yaw is global and has a nil value, doing "yaw = yaw + pi" produces nil + pi. So it should be better make "local yaw = ...get_yaw() + pi" than "local yaw = ...get_yaw(); yaw = yaw + pi"
No, the global one shouldn't have anything to with it, local yaw has been defined in that scope already so that is used, and the report says it was local anyway.

One reason i can think of is you're probably calling remove() somewhere before within the same engine step.
Engine behavior might have changed in that regard, i think it used to be so they get removed only after exiting lua.

Try cleaning the queues before you call remove()

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun Mar 01, 2020 20:32
by runs
Termos wrote:
runs wrote:I've check the lua manual and it has sense: http://www.lua.org/manual/5.2/manual.html#3.5

If yaw is global and has a nil value, doing "yaw = yaw + pi" produces nil + pi. So it should be better make "local yaw = ...get_yaw() + pi" than "local yaw = ...get_yaw(); yaw = yaw + pi"
No, the global one shouldn't have anything to with it, local yaw has been defined in that scope already so that is used, and the report says it was local anyway.

One reason i can think of is you're probably calling remove() somewhere before within the same engine step.
Engine behavior might have changed in that regard, i think it used to be so they get removed only after exiting lua.

Try cleaning the queues before you call remove()
This could be, cos bees die if the beehive "die" or go to their behive at night (remove). I will check...

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Tue Mar 03, 2020 00:07
by runs
That was the issue, previous a remove function it should be the behaviours cleaned.

I added a mokapi.remove_mob to do the trick.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Mon Apr 06, 2020 13:08
by Termos
.
Update 200406

mobkit
  • get_nodes_in_area(): fixed possible crash when in the world there are leftover undefined nodes.
wildlife
  • animals are now animated

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu Apr 09, 2020 14:35
by runs
Can you help me:

I get this code:
AsyncErr: ServerThread::run Lua: Runtime error from mod 'petz' in callback node_on_dig(): Runtime error from mod 'petz' in callback node_on_destruct(): /home/codesound/.minetest/mods/mobkit/init.lua:640: attempt to index field 'memory' (a nil value)
stack traceback:
It occurs when (in an external function out of the brain) I spawn a mob, inmediately force to die (mobkit.hq_die) (second line), and I try to set a mobkit.remember (third line). 'Is_alive' function does not help because the mob is still "alive". I think the status between the mob dies and then dissapears (limbo?) is problematic.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu Apr 09, 2020 14:53
by Termos
You probably shouldn't do stuff with entities in the same place where you spawn them, because technically they don't exist yet and their on_activate hasn't run yet.

I'd try doing it in on_activate instead, remember to call mobkit.actfunc first.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Mon Apr 13, 2020 22:47
by Extex
@Termos: I have made a discord server for mobkit!
https://discord.gg/NNN7BNk
Could you please join it?
I can give you all privs and stuff

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Tue Apr 14, 2020 05:48
by Extex
--Deleted message--

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun Apr 19, 2020 11:56
by runs
I want to implement a herd behavoiur, but I have some doubts.

Code: Select all

function mobkit.get_nearby_entity(self,name)
	-- returns random nearby entity of name or nil
function mobkit.get_closest_entity(self,name)
	-- returns closest entity of name or nil
What's the difference? Random what means (refered this function, I mean the word)?

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun Apr 19, 2020 16:01
by Wuzzy
Is there a list of mods that depend on this mod, and why is it not in the first post? :P

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun Apr 19, 2020 17:06
by u18398
Wuzzy wrote:Is there a list of mods that depend on this mod, and why is it not in the first post? :P
How should he know who is using his mobkit :D

A few I know of are:
  • wildlife
    petz
    water_life
    aerotest
    sailing_kit
maybe there are more

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun Apr 19, 2020 18:27
by Termos
Extex wrote:@Termos: I have made a discord server for mobkit!
https://discord.gg/NNN7BNk
Could you please join it?
Thanks.
To be honest I don't know what a discord is. I'll try to find the time to learn.
runs wrote:I want to implement a herd behavoiur, but I have some doubts.
'nearby' gets you a random alive and active entity within range (48n iirc), 'closest' is what I'd probably use to implement herd behavior.
Wuzzy wrote:Is there a list of mods that depend on this mod, and why is it not in the first post? :P
That's beyond my control, but listing some of them I know of in the first post is probably a good idea, thanks.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun Apr 19, 2020 18:29
by Eran
Wuzzy wrote:Is there a list of mods that depend on this mod, and why is it not in the first post? :P
I've got two:
One for talking parrots.
and a goat mod.

Noodlemire's Voxel Dungeon game also has mobs using mobkit.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu Apr 30, 2020 18:35
by twoelk
added a mobkit section to https://wiki.minetest.net/Mods:Mobs

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu Apr 30, 2020 18:56
by u18398
twoelk wrote:
Thu Apr 30, 2020 18:35
added a mobkit section to https://wiki.minetest.net/Mods:Mobs
Yay! That's great. Thumbs up for my favorite mob api :)

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu Apr 30, 2020 20:01
by Termos
twoelk wrote:
Thu Apr 30, 2020 18:35
added a mobkit section to https://wiki.minetest.net/Mods:Mobs
Cool stuff, thanks!

Just a little update, my PR got merged into 5.3 dev, if it doesn't get reverted and makes it into the next stable then we get back to work on this one.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Wed May 06, 2020 18:39
by acidzebra
Mobkit is pretty fun to play around with, the queue functions are interesting.

Is there any way to restrict spawns to certain slices like min_height and max_height? I poked around the API doc but couldn't find anything offhand.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Wed May 06, 2020 19:15
by runs
acidzebra wrote:
Wed May 06, 2020 18:39
Mobkit is pretty fun to play around with, the queue functions are interesting.

Is there any way to restrict spawns to certain slices like min_height and max_height? I poked around the API doc but couldn't find anything offhand.
Yes, see my api_spawn.lua in Petz. Not in mobkit itself but out.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Wed May 06, 2020 22:17
by acidzebra
runs wrote:
Wed May 06, 2020 19:15
acidzebra wrote:
Wed May 06, 2020 18:39
Mobkit is pretty fun to play around with, the queue functions are interesting.

Is there any way to restrict spawns to certain slices like min_height and max_height? I poked around the API doc but couldn't find anything offhand.
Yes, see my api_spawn.lua in Petz. Not in mobkit itself but out.
Ah, I see it, thanks runs. This also explains why people saw a camel deep underground (I have some mods that mess with nodes and caves) and I think you only restricted fishies.

I guess every mod/modpack can define this stuff for themselves but I think this should be a core feature of a mob framework - be able to restrict highland/lowland/flying/water mobs with a single instruction rather than implementing checks for each.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu May 07, 2020 00:22
by runs
acidzebra wrote:
Wed May 06, 2020 22:17
runs wrote:
Wed May 06, 2020 19:15
acidzebra wrote:
Wed May 06, 2020 18:39
Mobkit is pretty fun to play around with, the queue functions are interesting.

Is there any way to restrict spawns to certain slices like min_height and max_height? I poked around the API doc but couldn't find anything offhand.
Yes, see my api_spawn.lua in Petz. Not in mobkit itself but out.
I guess every mod/modpack can define this stuff for themselves but I think this should be a core feature of a mob framework - be able to restrict highland/lowland/flying/water mobs with a single instruction rather than implementing checks for each.
Simply do a "spawn.y" check:

Code: Select all

if spawn.y < 0 then
  return --discard spawn
end
Ah, I see it, thanks runs. This also explains why people saw a camel deep underground (I have some mods that mess with nodes and caves) and I think you only restricted fishies.
My bats should spawn only into caves too.

mobkit already does search for caves (or my mod?) but the main problem is: what height has a cave or a sub-underground-world?

In fact, in Minetest you can create totally different worlds by levels. If you want to spawn in a Netherworld, Skyworld?

mobkit could integrate it but doing a few 'ifs' won't be a problem either.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu May 07, 2020 04:33
by u18398
Mobkit is not responsible for spawning.

Your spawning function is it. So you have to write it accordingly to your needs :)

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Thu May 07, 2020 13:29
by Termos
acidzebra wrote:
Wed May 06, 2020 18:39
Is there any way to restrict spawns to certain slices like min_height and max_height? I poked around the API doc but couldn't find anything offhand.
There are multiple ways to do spawns, so specific implementation is best left to mods,
however there's an example spawn function included - mobkit.get_spawn_pos_abr().

It works on a different principle than what people seem to be used to here - at regular intervals it returns a position on the surface that's in approx active_block_range distance from the nearest player - then it's mod's responsibility to determine what to spawn there, based on whatever specific criteria apply, and they are countless - Y, X, Z, biome, heat, humidity, node, light, time of day, nearby objects plus an infinite number of other imaginable criteria.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun May 10, 2020 16:40
by apercy
Hello Termos

Based on your excellent Sailing kit I made the Motorboat mod. Testing it I found a problem that affects your sailing kit too, when it sinks at flowing water. After some research I found that the problem is on mobkit and can be bypassed with a edit at line 817, in the while loop of mobkit.physics method. So I put the following:

Code: Select all

while surfnode and (surfnode.drawtype == 'liquid' or surfnode.drawtype == 'flowingliquid') do
I believe you must test it on some mobs to ensure that it will not break any other mod.

Thank you for the great work.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun May 10, 2020 18:14
by Termos
apercy wrote:
Sun May 10, 2020 16:40
Testing it I found a problem that affects your sailing kit too, when it sinks at flowing water.
This is intended, allowing floating in flowing liquids causes other problems.

Luckily you can customize physics, just copy mobkit.physics into your mod, rename it e.g. yourmod.funname, and make the modifications.
Then in entity definition use physics = yourmod.funname and you're set.

Re: Mobkit - Entity API [mobkit][alpha]

Posted: Sun May 10, 2020 18:17
by apercy
Ok!!!!