summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-10-16 21:35:24 -0600
committerFaceDeer <derksenmobile@gmail.com>2017-10-16 21:35:24 -0600
commitabc7f2e4147734783176e6cce84891b99b2c001b (patch)
tree52d0ff622380ee0243032e7ea99212db94899d1c /init.lua
parent0430d423f7e185736061bb119ca27f4a31f02880 (diff)
fakeplayer for callbacks, switch to whitelist for on_place calls
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 981bb39..0b457c6 100644
--- a/init.lua
+++ b/init.lua
@@ -20,8 +20,28 @@ digtron.builder_read_item_substitutions = {
["farming:desert_sand_soil_wet"] = "default:desert_sand",
}
+-- Sometimes we want builder heads to call an item's "on_place" method, other times we
+-- don't want them to. There's no way to tell which situation is best programmatically
+-- so we have to rely on whitelists to be on the safe side.
+
+--first exact matches are tested, and the value given in this global table is returned
+digtron.builder_on_place_items = {
+ ["default:torch"] = true,
+}
+
+-- Then a string prefix is checked, returning this value. Useful for enabling on_placed on a mod-wide basis.
+digtron.builder_on_place_prefixes = {
+ ["farming:"] = true,
+}
+
+-- Finally, items belonging to group "digtron_on_place" will have their on_place methods called.
+
local digtron_modpath = minetest.get_modpath( "digtron" )
+dofile( digtron_modpath .. "/class_fakeplayer.lua")
+
+digtron.fake_player = DigtronFakePlayer.create({x=0,y=0,z=0}, "fake_player") -- since we only need one fake player at a time and it doesn't retain useful state, create a global one and just update it as needed.
+
dofile( digtron_modpath .. "/config.lua" )
dofile( digtron_modpath .. "/util.lua" )
dofile( digtron_modpath .. "/doc.lua" )