[Solved] Does anyone know how to do a killcount

Post Reply
ChristienChapman
Member
Posts: 52
Joined: Sat May 28, 2022 00:04

[Solved] Does anyone know how to do a killcount

by ChristienChapman » Post

Beem searching ContentDB and there is nothing out there to count entities killed. :( This is a crucial part to my game. Please help. God bless.
Last edited by ChristienChapman on Thu Jun 23, 2022 15:12, edited 1 time in total.
God bless you.

ChristienChapman
Member
Posts: 52
Joined: Sat May 28, 2022 00:04

Re: Does anyone know how to do a killcount

by ChristienChapman » Post

Inside of function mob_class:item_drop() in mobs api.lua, make a int for counter.

Code: Select all

 -- drop items
function mob_class:item_drop() 
PublicCounter = 0 
PublicCounter = PublicCounter + 1
minetest.chat_send_all(PublicCounter)
)
end
Each time you kill a mob, the counter will add one. You can check the counter within item_drop() by using

if PublicCounter == 1 then

end
God bless you.

User avatar
sirrobzeroone
Member
Posts: 425
Joined: Mon Jul 16, 2018 07:56

Re: Does anyone know how to do a killcount

by sirrobzeroone » Post

Set some meta_data against the player. I think the modding book had an example very close to this so have a look there and see how you go:

https://rubenwardy.com/minetest_modding ... orage.html

I don't quite follow the on_drop part, for a player to check there counter I'd probably go with either an updated hud element if it's that crucial to your game or add a chat command that returns the current total in the chat for that player.

Your code Snippet also seems to indicate the counter is for all players or maybe all players of a faction? Not sure TBH, anyways if that's the case you may need to store the meta against the mod:

https://rubenwardy.com/minetest_modding ... od-storage

Good Luck

ChristienChapman
Member
Posts: 52
Joined: Sat May 28, 2022 00:04

Re: Does anyone know how to do a killcount

by ChristienChapman » Post

The killcount I needed is global. I maybe should have said that earlier lol.
God bless you.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests