Page 42 of 47

Re: [Mod] Petz [v13.2] [petz]

Posted: Mon Jun 15, 2020 23:02
by runs
acidzebra wrote:
Wed May 13, 2020 16:56
running petz on a server, I've been trying to bring down the system load of the mod. It's fine in singleplayer.

I see two main bottlenecks, in api_spawn.lua you register_globalstep and then check for a node to spawn a mob on every step; I think this could be toned down a little by adding a timer like in the example here https://dev.minetest.net/minetest.register_globalstep

Then in api_on_step.lua for every server step you run (assuming every option is set to true)
petz.init_tamagochi_timer(self)
petz.pregnant_timer(self, dtime)
petz.growth_timer(self, dtime)
petz.gallop(self, dtime)
petz.dreamcatcher_save_metadata(self)

I'm still digging through the code, but is it crucial these things are called every server step?

Just some suggestions, I'm an absolute beginner in lua.
I'm going to implement your ideas. :-)

Re: [Mod] Petz [v14.2] [petz]

Posted: Tue Jun 16, 2020 21:17
by runs
v14.3

- The on_step functions are checked every 1 second now.
- Workaround for parrot perch issue in 5.3-dev.

Re: [Mod] Petz [v14.3] [petz]

Posted: Tue Jun 16, 2020 21:20
by runs
I see two main bottlenecks, in api_spawn.lua you register_globalstep and then check for a node to spawn a mob on every step; I think this could be toned down a little by adding a timer like in the example here https://dev.minetest.net/minetest.register_globalstep
I think that does not matter cos the mobkit function has a interval value for checking a spawn node.

Re: [Mod] Petz [v14.3] [petz]

Posted: Tue Jun 16, 2020 21:23
by runs
I will implement a death function so that the petz will not be eternal. Especially the less intelligent ones. It may be useful in servers to control overcrowding.

Re: [Mod] Petz [v14.3] [petz]

Posted: Wed Jun 17, 2020 13:35
by Termos
runs wrote:
Tue Jun 16, 2020 21:20
I think that does not matter cos the mobkit function has a interval value for checking a spawn node.
Yup, there is a timer in the function, it doesn't do anything on most steps so it's really cheap unless something weird is done with it.

Re: [Mod] Petz [v14.3] [petz]

Posted: Thu Jun 18, 2020 17:49
by Gundul
I got a squirrel crash loop on my server jungle:

Code: Select all

2020-06-18 19:37:16: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'petz' in callback luaentity_Step(): .../mods/petz/petz/mobkit/bh_arboreal.lua:74: attempt to index a nil value
2020-06-18 19:37:16: ERROR[Main]: stack traceback:
2020-06-18 19:37:16: ERROR[Main]:       .../mods/petz/petz/mobkit/bh_arboreal.lua:74: in function 'func'
2020-06-18 19:37:16: ERROR[Main]:       /.minetest/mods/mobkit/init.lua:741: in function 'execute_queues'
2020-06-18 19:37:16: ERROR[Main]:       /.minetest/mods/mobkit/init.lua:959: in function 'stepfunc'
2020-06-18 19:37:16: ERROR[Main]:       ...rs/.minetest/mods/petz/petz/petz/squirrel_mobkit.lua:79: in function 'func'
It is not a true loop, but the player can't login anymore because server crashes when he logs in because of the squirrel.

Re: [Mod] Petz [v14.3] [petz]

Posted: Thu Jun 18, 2020 19:57
by runs
v14.4
- Solved crash with squirrel.

Re: [Mod] Petz [v14.3] [petz]

Posted: Thu Jun 18, 2020 20:02
by runs
Gundul wrote:
Thu Jun 18, 2020 17:49
I got a squirrel crash loop on my server jungle:

Code: Select all

2020-06-18 19:37:16: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'petz' in callback luaentity_Step(): .../mods/petz/petz/mobkit/bh_arboreal.lua:74: attempt to index a nil value
2020-06-18 19:37:16: ERROR[Main]: stack traceback:
2020-06-18 19:37:16: ERROR[Main]:       .../mods/petz/petz/mobkit/bh_arboreal.lua:74: in function 'func'
2020-06-18 19:37:16: ERROR[Main]:       /.minetest/mods/mobkit/init.lua:741: in function 'execute_queues'
2020-06-18 19:37:16: ERROR[Main]:       /.minetest/mods/mobkit/init.lua:959: in function 'stepfunc'
2020-06-18 19:37:16: ERROR[Main]:       ...rs/.minetest/mods/petz/petz/petz/squirrel_mobkit.lua:79: in function 'func'
It is not a true loop, but the player can't login anymore because server crashes when he logs in because of the squirrel.
Try the last version.

Re: [Mod] Petz [v14.4] [petz]

Posted: Fri Jun 19, 2020 11:53
by runs
v14.5

- Fixed regression with timers (cause of the on_step change): grow, pregnant...

Image

Lifetime Mode


You can set the lifetime for the petz in the 'petz-conf' file:

- lifetime = -1
-- General lifetime for all the petz. Set a value in seconds.
-- Set to -1 to disable

- You can configure individual lifetime for each type of petz, simply create a "_lifetime" setting. I.e.: "kitty_lifetime = 1200".
-- This particular setting overrides the general lifetime setting.
-- This also works if general lifetime is -1.
-- If you put this setting to -1, the lifetime general setting also would be overrided. You can use this to avoid some type of petz to die when general lifetime is set.

- A dreamcatcher in a petz disables all the lifetime.

- Some fine tunings:
-- lifetime_only_non_tamed = false
-- lifetime_avoid_non_breedable = false

Re: [Mod] Petz [v14.4] [petz]

Posted: Fri Jun 19, 2020 11:56
by runs
...

Re: [Mod] Petz [v14.5] [petz]

Posted: Fri Jun 19, 2020 16:27
by runs
v14.6

- Now the lifetime of a petz is shown in its form (tab "Other") (if applies).
- Fix to avoid a crash: Now an opened formspec is automatically closed when a petz dies.

Re: [Mod] Petz [v14.6] [petz]

Posted: Fri Jun 19, 2020 16:42
by runs
Be Cautious when you define and use the Lifetime Mode

Or you could get some or all the petz dead. I recommend you to test it in a test server.

Re: [Mod] Petz [v14.6] [petz]

Posted: Fri Jun 19, 2020 21:54
by runs
v14.7
- Added the lifetime_variability (0.2 by default) to add some individual variety in the lifetime. This means that the lifetime can change +-20% for each individual entity.

Re: [Mod] Petz [v14.7] [petz]

Posted: Fri Jun 19, 2020 22:11
by LMD
For increased intuitivity, I would rather recommend something like lifetime_min and lifetime_max.

Re: [Mod] Petz [v14.7] [petz]

Posted: Sat Jun 20, 2020 09:54
by runs
LMD wrote:
Fri Jun 19, 2020 22:11
For increased intuitivity, I would rather recommend something like lifetime_min and lifetime_max.
Probably it would be a better approach.

Re: [Mod] Petz [v14.7] [petz]

Posted: Sun Jun 21, 2020 21:03
by Bastrabun
A player reported there's a duplicate crafting recipe of the shears of mobs_redo and petz. Could you add a recipe that lets players exchange them, when both mods are installed? There may be other duplicate recipes that we haven't come across yet

Re: [Mod] Petz [v14.7] [petz]

Posted: Sun Jun 21, 2020 21:06
by runs
Bastrabun wrote:
Sun Jun 21, 2020 21:03
A player reported there's a duplicate crafting recipe of the shears of mobs_redo and petz. Could you add a recipe that lets players exchange them, when both mods are installed? There may be other duplicate recipes that we haven't come across yet
Maybe set the default shear as with the lasso.

You should use an advanced craft/inventory, those allow multiple same recipes (duplicates), simply you select the output you want.

Re: [Mod] Petz [v14.7] [petz]

Posted: Sun Jun 21, 2020 21:20
by runs
v14.8

- Now you can define the shears to use in "petz.conf".

Re: [Mod] Petz [v14.8] [petz]

Posted: Sun Jun 21, 2020 21:49
by Bastrabun
17 minutes from bug report to fix. Awesome :)

You could also let the mobs_redo shears be crafted from the petz shears and vice versa. I am using unified inventory, it does not seem to have such an option you mentioned?

Re: [Mod] Petz [v14.8] [petz]

Posted: Mon Jun 22, 2020 20:12
by runs
v14.9
- Fixed crash with the parchment in 5.3-dev

Re: [Mod] Petz [v14.8] [petz]

Posted: Mon Jun 22, 2020 20:15
by runs
Bastrabun wrote:
Sun Jun 21, 2020 21:49
17 minutes from bug report to fix. Awesome :)

You could also let the mobs_redo shears be crafted from the petz shears and vice versa. I am using unified inventory, it does not seem to have such an option you mentioned?
I use the addon: unified_inventory_plus

Re: [Mod] Petz [v14.2] [petz]

Posted: Wed Jun 24, 2020 09:13
by runs
Bastrabun wrote:
Mon Jun 15, 2020 13:33
- I can reproduce the model-too-big issue. Having wieldview, 3darmor and petz enabled, as soon as I sit on a pony and change the item I wield, my model grows n times in size
I checked and I have not the issue.

Make 2 things:

- Test 1: Download the last 3D Armor (it is not the official one= outdated): https://github.com/minetest-mods/3d_armor

- Test 2: Move the 3darmor mod to another location and check without it.

Re: [Mod] Petz [v14.9] [petz]

Posted: Sun Jun 28, 2020 09:48
by shazen
Hi, Just found a bug with server crash and when the player reconnect that crash the server again.

Code: Select all

2020-06-28 11:27:06: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'petz' in callback luaentity_Step(): .../mobkit/init.lua:1495: attempt to index local 'node3' (a nil value)
2020-06-28 11:27:06: ERROR[Main]: stack traceback:
2020-06-28 11:27:06: ERROR[Main]: 	.../mobkit/init.lua:1495: in function 'is_in_deep'
2020-06-28 11:27:06: ERROR[Main]: 	.../petz/petz/mobkit/br_aquatic.lua:58: in function 'logic'
2020-06-28 11:27:06: ERROR[Main]: 	.../mobkit/init.lua:958: in function 'stepfunc'
2020-06-28 11:27:06: ERROR[Main]: 	.../petz/petz/petz/dolphin_mobkit.lua:81: in function <.../petz/petz/petz/dolphin_mobkit.lua:80>

Re: [Mod] Petz [v14.9] [petz]

Posted: Sun Jun 28, 2020 22:29
by runs
shazen wrote:
Sun Jun 28, 2020 09:48
Hi, Just found a bug with server crash and when the player reconnect that crash the server again.

Code: Select all

2020-06-28 11:27:06: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'petz' in callback luaentity_Step(): .../mobkit/init.lua:1495: attempt to index local 'node3' (a nil value)
2020-06-28 11:27:06: ERROR[Main]: stack traceback:
2020-06-28 11:27:06: ERROR[Main]: 	.../mobkit/init.lua:1495: in function 'is_in_deep'
2020-06-28 11:27:06: ERROR[Main]: 	.../petz/petz/mobkit/br_aquatic.lua:58: in function 'logic'
2020-06-28 11:27:06: ERROR[Main]: 	.../mobkit/init.lua:958: in function 'stepfunc'
2020-06-28 11:27:06: ERROR[Main]: 	.../petz/petz/petz/dolphin_mobkit.lua:81: in function <.../petz/petz/petz/dolphin_mobkit.lua:80>
It is a mobkit error. I will report it.

Re: [Mod] Petz [v14.9] [petz]

Posted: Sun Jun 28, 2020 22:39
by runs
This can be solved changing the line 1494 of the mobkit's init.lua to:

if node1 and node2 and node3 and node1.drawtype=='liquid' and (node2.drawtype=='liquid' or node3.drawtype=='liquid') then