diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-17 11:22:24 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:49 +0200 |
commit | cc03718d3c492a401bbc4b071d0ae1f0c808de95 (patch) | |
tree | d3b701f5ab5ca0b2d94a22a0c49eeeb0ba98fb51 /data/mods | |
parent | d7cb6146c8ddbd3e1c03c9743e32d7d4e86ec78e (diff) | |
download | minetest-cc03718d3c492a401bbc4b071d0ae1f0c808de95.tar.gz minetest-cc03718d3c492a401bbc4b071d0ae1f0c808de95.tar.bz2 minetest-cc03718d3c492a401bbc4b071d0ae1f0c808de95.zip |
Node place/dig Lua callbacks
Diffstat (limited to 'data/mods')
-rw-r--r-- | data/mods/default/init.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index 5f8eeadee..966b807ae 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -78,7 +78,12 @@ end -- -- Global functions: -- minetest.register_entity(name, prototype_table) +-- minetest.register_tool(name, {lots of stuff}) +-- minetest.register_node(name, {lots of stuff}) +-- minetest.register_craft({output=item, recipe={...}) -- minetest.register_globalstep(func) +-- minetest.register_on_placenode(func) +-- minetest.register_on_dignode(func) -- -- Global objects: -- minetest.env - environment reference @@ -91,9 +96,12 @@ end -- minetest.luaentities -- ^ List of lua entities, indexed by active object id -- +-- EnvRef is basically ServerEnvironment and ServerMap combined. -- EnvRef methods: -- - add_node(pos, content); pos={x=num, y=num, z=num} +-- TODO: content -> MapNode as described below -- +-- ObjectRef is basically ServerActiveObject. -- ObjectRef methods: -- - remove(): remove object (after returning from Lua) -- - getpos(): returns {x=num, y=num, z=num} @@ -106,6 +114,9 @@ end -- - It has the member .object, which is an ObjectRef pointing to the object -- - The original prototype stuff is visible directly via a metatable -- +-- MapNode representation: +-- {name="name", param1=num, param2=num} +-- print("omg lol") print("minetest dump: "..dump(minetest)) @@ -117,6 +128,18 @@ end minetest.register_globalstep(on_step) +function on_placenode(p, node) + print("on_placenode") +end + +minetest.register_on_placenode(on_placenode) + +function on_dignode(p, node) + print("on_dignode") +end + +minetest.register_on_dignode(on_dignode) + minetest.register_tool("WPick", { image = "tool_woodpick.png", basetime = 2.0, |