Code Monkey home page Code Monkey logo

Comments (7)

rubenwardy avatar rubenwardy commented on June 14, 2024 3

I think it's acceptable for entities to handle their own events and for other mods to hook into the callbacks. So I'd consider this low priority

from minetest.

SmallJoker avatar SmallJoker commented on June 14, 2024

As an alternative approach, you could overwrite the on_death callback of the entities that are considered as "monster":

minetest/doc/lua_api.md

Lines 5092 to 5094 in eb432d3

* `on_death(self, killer)`
* Called when the object dies.
* `killer`: an `ObjectRef` (can be `nil`)

local function register_entity_as_monster(name)
	local def = minetest.registered_entities[name]
	local old_cb = def.on_death
	def.on_death = function(self, killer)
		my_achievements_callback("entity died", name)

		if old_cb then
			old_cb(self, killer)
		end
	end
end

register_entity_as_monster("monsters:monster_a")

from minetest.

SkyBuilder1717 avatar SkyBuilder1717 commented on June 14, 2024

I think it's acceptable for entities to handle their own events and for other mods to hook into the callbacks. So I'd consider this low priority

aw man(

from minetest.

SkyBuilder1717 avatar SkyBuilder1717 commented on June 14, 2024

As an alternative approach, you could overwrite the on_death callback of the entities that are considered as "monster":

minetest/doc/lua_api.md

Lines 5092 to 5094 in eb432d3

* `on_death(self, killer)`
* Called when the object dies.
* `killer`: an `ObjectRef` (can be `nil`)

local function register_entity_as_monster(name)
	local def = minetest.registered_entities[name]
	local old_cb = def.on_death
	def.on_death = function(self, killer)
		my_achievements_callback("entity died", name)

		if old_cb then
			old_cb(self, killer)
		end
	end
end

register_entity_as_monster("monsters:monster_a")

Code_BFBsHZLHVl
it didnt work for me for some reason

from minetest.

SkyBuilder1717 avatar SkyBuilder1717 commented on June 14, 2024

As an alternative approach, you could overwrite the on_death callback of the entities that are considered as "monster":

minetest/doc/lua_api.md

Lines 5092 to 5094 in eb432d3

* `on_death(self, killer)`
* Called when the object dies.
* `killer`: an `ObjectRef` (can be `nil`)

local function register_entity_as_monster(name)
	local def = minetest.registered_entities[name]
	local old_cb = def.on_death
	def.on_death = function(self, killer)
		my_achievements_callback("entity died", name)

		if old_cb then
			old_cb(self, killer)
		end
	end
end

register_entity_as_monster("monsters:monster_a")

i wanted answers, why it dont work for me? please

from minetest.

rubenwardy avatar rubenwardy commented on June 14, 2024

What does "didn't work" mean?

The issue tracker isn't a place to receive modding help

from minetest.

SkyBuilder1717 avatar SkyBuilder1717 commented on June 14, 2024

What does "didn't work" mean?

The issue tracker isn't a place to receive modding help

oh god😭

from minetest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.