diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index fbb5c2669..5bffb0e8f 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1,7 +1,7 @@ mcl_util = {} -local modname = minetest.get_current_modname() -local modpath = minetest.get_modpath(modname) +local modname = core.get_current_modname() +local modpath = core.get_modpath(modname) dofile(modpath.."/roman_numerals.lua") dofile(modpath.."/nodes.lua") diff --git a/mods/CORE/mcl_util/nodes.lua b/mods/CORE/mcl_util/nodes.lua index 9e8d8a7a3..07010e4a7 100644 --- a/mods/CORE/mcl_util/nodes.lua +++ b/mods/CORE/mcl_util/nodes.lua @@ -5,20 +5,20 @@ -- debugging. See: -- https://git.minetest.land/VoxeLibre/VoxeLibre/issues/1392 function mcl_util.get_natural_light (pos, time) - local status, retVal = pcall(minetest.get_natural_light, pos, time) + local status, retVal = pcall(core.get_natural_light, pos, time) if status then return retVal else - minetest.log("warning", "Failed to get natural light at pos: " .. dump(pos) .. ", time: " .. dump(time)) + core.log("warning", "Failed to get natural light at pos: " .. dump(pos) .. ", time: " .. dump(time)) if (pos) then - local node = minetest.get_node(pos) - minetest.log("warning", "Node at pos: " .. dump(node.name)) + local node = core.get_node(pos) + core.log("warning", "Node at pos: " .. dump(node.name)) end end return 0 end --- Based on minetest.rotate_and_place +-- Based on core.rotate_and_place --[[ Attempt to predict the desired orientation of the pillar-like node @@ -30,16 +30,16 @@ field is false or omitted (else, the itemstack is not changed). * `invert_wall`: if `true`, place wall-orientation on the ground and ground- orientation on wall -This function is a simplified version of minetest.rotate_and_place. +This function is a simplified version of core.rotate_and_place. The Luanti function is seen as inappropriate because this includes mirror images of possible orientations, causing problems with pillar shadings. ]] function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infinitestacks, invert_wall) - local unode = minetest.get_node_or_nil(pointed_thing.under) + local unode = core.get_node_or_nil(pointed_thing.under) if not unode then return end - local undef = minetest.registered_nodes[unode.name] + local undef = core.registered_nodes[unode.name] if undef and undef.on_rightclick and not invert_wall then undef.on_rightclick(pointed_thing.under, unode, placer, itemstack, pointed_thing) @@ -50,7 +50,7 @@ function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infini local above = pointed_thing.above local under = pointed_thing.under - local anode = minetest.get_node_or_nil(above) + local anode = core.get_node_or_nil(above) if not anode then return end @@ -62,12 +62,12 @@ function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infini node = unode end - if minetest.is_protected(pos, placer:get_player_name()) then - minetest.record_protection_violation(pos, placer:get_player_name()) + if core.is_protected(pos, placer:get_player_name()) then + core.record_protection_violation(pos, placer:get_player_name()) return end - local ndef = minetest.registered_nodes[node.name] + local ndef = core.registered_nodes[node.name] if not ndef or not ndef.buildable_to then return end @@ -80,7 +80,7 @@ function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infini elseif above.z ~= under.z then p2 = 6 end - minetest.set_node(pos, {name = wield_name, param2 = p2}) + core.set_node(pos, {name = wield_name, param2 = p2}) if not infinitestacks then itemstack:take_item() @@ -89,10 +89,10 @@ function mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, infini end -- Wrapper of above function for use as `on_place` callback (Recommended). --- Similar to minetest.rotate_node. +-- Similar to core.rotate_node. function mcl_util.rotate_axis(itemstack, placer, pointed_thing) mcl_util.rotate_axis_and_place(itemstack, placer, pointed_thing, - minetest.is_creative_enabled(placer:get_player_name()), + core.is_creative_enabled(placer:get_player_name()), placer:get_player_control().sneak) return itemstack end @@ -132,8 +132,8 @@ function mcl_util.generate_on_place_plant_function(condition) end -- Call on_rightclick if the pointed node defines it - local node = minetest.get_node(pointed_thing.under) - local node_def = minetest.registered_nodes[node.name] + local node = core.get_node(pointed_thing.under) + local node_def = core.registered_nodes[node.name] if placer and not placer:get_player_control().sneak then if node_def and node_def.on_rightclick then @@ -142,8 +142,8 @@ function mcl_util.generate_on_place_plant_function(condition) end local place_pos - local def_under = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] - local def_above = minetest.registered_nodes[minetest.get_node(pointed_thing.above).name] + local def_under = core.registered_nodes[core.get_node(pointed_thing.under).name] + local def_above = core.registered_nodes[core.get_node(pointed_thing.above).name] if not def_under or not def_above then return itemstack end @@ -160,11 +160,11 @@ function mcl_util.generate_on_place_plant_function(condition) local result, param2 = condition(place_pos, node, itemstack) if result == true then local idef = itemstack:get_definition() - local new_itemstack, success = minetest.item_place_node(itemstack, placer, pointed_thing, param2) + local new_itemstack, success = core.item_place_node(itemstack, placer, pointed_thing, param2) if success then if idef.sounds and idef.sounds.place then - minetest.sound_play(idef.sounds.place, {pos = pointed_thing.above, gain = 1}, true) + core.sound_play(idef.sounds.place, {pos = pointed_thing.above, gain = 1}, true) end end itemstack = new_itemstack @@ -202,7 +202,7 @@ function mcl_util.bypass_buildable_to(func) -- Returns a logging function. For empty names, does not log. Copied from minetest builtin -- https://github.com/minetest/minetest/blob/526a2f7b8c45504088e194a83d54a19045227bbd/builtin/game/item.lua#L142-L144 local function make_log(name) - return name ~= "" and minetest.log or function() end + return name ~= "" and core.log or function() end end -- Copied from minetest builtin @@ -260,24 +260,24 @@ function mcl_util.bypass_buildable_to(func) end local under = pointed_thing.under - local oldnode_under = minetest.get_node_or_nil(under) + local oldnode_under = core.get_node_or_nil(under) local above = pointed_thing.above - local oldnode_above = minetest.get_node_or_nil(above) + local oldnode_above = core.get_node_or_nil(above) local playername = user_name(placer) local log = make_log(playername) if not oldnode_under or not oldnode_above then log("info", playername .. " tried to place" - .. " node in unloaded position " .. minetest.pos_to_string(above)) + .. " node in unloaded position " .. core.pos_to_string(above)) return itemstack end - local olddef_under = minetest.registered_nodes[oldnode_under.name] or minetest.nodedef_default - local olddef_above = minetest.registered_nodes[oldnode_above.name] or minetest.nodedef_default + local olddef_under = core.registered_nodes[oldnode_under.name] or core.nodedef_default + local olddef_above = core.registered_nodes[oldnode_above.name] or core.nodedef_default if not olddef_above.buildable_to and not olddef_under.buildable_to then log("info", playername .. " tried to place" - .. " node in invalid position " .. minetest.pos_to_string(above) + .. " node in invalid position " .. core.pos_to_string(above) .. ", replacing " .. oldnode_above.name) return itemstack end @@ -292,16 +292,16 @@ function mcl_util.bypass_buildable_to(func) place_to = under end - if minetest.is_protected(place_to, playername) then + if core.is_protected(place_to, playername) then log("action", playername .. " tried to place " .. def.name .. " at protected position " - .. minetest.pos_to_string(place_to)) - minetest.record_protection_violation(place_to, playername) + .. core.pos_to_string(place_to)) + core.record_protection_violation(place_to, playername) return itemstack end - local oldnode = minetest.get_node(place_to) + local oldnode = core.get_node(place_to) local newnode = {name = def.name, param1 = 0, param2 = param2 or 0} -- Calculate direction for wall mounted stuff like torches and signs @@ -309,7 +309,7 @@ function mcl_util.bypass_buildable_to(func) newnode.param2 = def.place_param2 elseif (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted") and not param2 then - newnode.param2 = minetest.dir_to_wallmounted(vector.subtract(under, above)) + newnode.param2 = core.dir_to_wallmounted(vector.subtract(under, above)) -- Calculate the direction for furnaces and chests and stuff elseif (def.paramtype2 == "facedir" or def.paramtype2 == "colorfacedir" or @@ -317,7 +317,7 @@ function mcl_util.bypass_buildable_to(func) def.paramtype2 == "color4dir") and not param2 then local placer_pos = placer and placer:get_pos() if placer_pos then - newnode.param2 = minetest.dir_to_facedir(vector.subtract(above, placer_pos)) + newnode.param2 = core.dir_to_facedir(vector.subtract(above, placer_pos)) log("info", "facedir: " .. newnode.param2) end end @@ -346,23 +346,23 @@ function mcl_util.bypass_buildable_to(func) end -- Check if the node is attached and if it can be placed there - local an = minetest.get_item_group(def.name, "attached_node") + local an = core.get_item_group(def.name, "attached_node") if an ~= 0 and not check_attached_node(place_to, newnode, an) then log("action", "attached node " .. def.name .. - " cannot be placed at " .. minetest.pos_to_string(place_to)) + " cannot be placed at " .. core.pos_to_string(place_to)) return itemstack end log("action", playername .. " places node " - .. def.name .. " at " .. minetest.pos_to_string(place_to)) + .. def.name .. " at " .. core.pos_to_string(place_to)) -- Add node and update - minetest.add_node(place_to, newnode) + core.add_node(place_to, newnode) -- Play sound if it was done by a player if playername ~= "" and def.sounds and def.sounds.place then - minetest.sound_play(def.sounds.place, { + core.sound_play(def.sounds.place, { pos = place_to, exclude_player = playername, }, true) @@ -382,7 +382,7 @@ function mcl_util.bypass_buildable_to(func) end -- Run script hook - for _, callback in ipairs(minetest.registered_on_placenodes) do + for _, callback in ipairs(core.registered_on_placenodes) do -- Deepcopy pos, node and pointed_thing because callback can modify them local place_to_copy = vector.copy(place_to) local newnode_copy = {name = newnode.name, param1 = newnode.param1, param2 = newnode.param2} @@ -402,10 +402,10 @@ end local DEFAULT_PALETTE_INDEXES = {grass_palette_index = 0, foliage_palette_index = 0, water_palette_index = 0} function mcl_util.get_palette_indexes_from_pos(pos) - local biome_data = minetest.get_biome_data(pos) + local biome_data = core.get_biome_data(pos) local biome = biome_data.biome - local biome_name = minetest.get_biome_name(biome) - local reg_biome = minetest.registered_biomes[biome_name] + local biome_name = core.get_biome_name(biome) + local reg_biome = core.registered_biomes[biome_name] if reg_biome and reg_biome._mcl_grass_palette_index and reg_biome._mcl_foliage_palette_index and reg_biome._mcl_water_palette_index then return { grass_palette_index = reg_biome._mcl_grass_palette_index, @@ -418,7 +418,7 @@ function mcl_util.get_palette_indexes_from_pos(pos) end function mcl_util.get_colorwallmounted_rotation(pos) - local colorwallmounted_node = minetest.get_node(pos) + local colorwallmounted_node = core.get_node(pos) for i = 0, 32, 1 do local colorwallmounted_rotation = colorwallmounted_node.param2 - (i * 8) if colorwallmounted_rotation < 6 then @@ -432,7 +432,7 @@ function mcl_util.match_node_to_filter(node_name, filters) local filter = filters[i] if node_name == filter then return true end - if string.sub(filter,1,6) == "group:" and minetest.get_item_group(node_name, string.sub(filter,7)) ~= 0 then return true end + if string.sub(filter,1,6) == "group:" and core.get_item_group(node_name, string.sub(filter,7)) ~= 0 then return true end end return false diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index 10141880c..d6166c80e 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -427,7 +427,7 @@ function mcl_mobs.register_arrow(name, def) pos.y = pos.y + 1 self.lastpos = self.lastpos or pos - minetest.add_item(self.lastpos, self.object:get_luaentity().name) + core.add_item(self.lastpos, self.object:get_luaentity().name) end mcl_util.remove_entity(self) @@ -479,7 +479,7 @@ function mcl_mobs.register_arrow(name, def) -- does arrow have a tail (fireball) if def.tail == 1 and def.tail_texture then - minetest.add_particle({ + core.add_particle({ pos = pos, velocity = {x = 0, y = 0, z = 0}, acceleration = {x = 0, y = 0, z = 0}, diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index f74bc4bb5..43b80d476 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -163,7 +163,7 @@ mcl_mobs.register_arrow("mobs_mc:dragon_fireball", { end, hit_mob = function(self, mob) - minetest.sound_play("tnt_explode", {pos = mob:get_pos(), gain = 1.5, max_hear_distance = 2*64}, true) + core.sound_play("tnt_explode", {pos = mob:get_pos(), gain = 1.5, max_hear_distance = 2*64}, true) end, -- node hit, explode diff --git a/mods/ENTITIES/mobs_mc/ghast.lua b/mods/ENTITIES/mobs_mc/ghast.lua index a4f1d160d..93e12f320 100644 --- a/mods/ENTITIES/mobs_mc/ghast.lua +++ b/mods/ENTITIES/mobs_mc/ghast.lua @@ -128,7 +128,7 @@ mcl_mobs.register_arrow("mobs_mc:fireball", { local name = mob:get_luaentity().name mcl_mobs.mob_class.boom(self,self.object:get_pos(), 1, true) local ent = mob:get_luaentity() - if (not ent or ent.health <= 0) and self._owner and minetest.get_player_by_name(self._owner) and name == "mobs_mc:ghast" then + if (not ent or ent.health <= 0) and self._owner and core.get_player_by_name(self._owner) and name == "mobs_mc:ghast" then awards.unlock(self._owner, "mcl:fireball_redir_serv") end end, diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 98933fa24..e09b822da 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -127,7 +127,7 @@ local arrow_entity = { end -- Item definition entity collision hook - local item_def = minetest.registered_items[self._arrow_item] + local item_def = core.registered_items[self._arrow_item] local hook = item_def and item_def._on_collide_with_entity if hook then hook(self, pos, obj) end @@ -162,13 +162,13 @@ local arrow_entity = { -- Preserve entity properties out.properties = self.object:get_properties() - return minetest.serialize(out) + return core.serialize(out) end, on_activate = function(self, staticdata, dtime_s) self.object:set_armor_groups({ immortal = 1 }) self._time_in_air = 1.0 - local data = minetest.deserialize(staticdata) + local data = core.deserialize(staticdata) if not data then return end -- Restore entity properties @@ -189,7 +189,7 @@ local arrow_entity = { end if data.shootername then - local shooter = minetest.get_player_by_name(data.shootername) + local shooter = core.get_player_by_name(data.shootername) if shooter and shooter:is_player() then self._shooter = shooter end @@ -206,7 +206,7 @@ mcl_bows.arrow_entity = table.copy(arrow_entity) vl_projectile.register("mcl_bows:arrow_entity", arrow_entity) -minetest.register_on_respawnplayer(function(player) +core.register_on_respawnplayer(function(player) for _, obj in pairs(player:get_children()) do local ent = obj:get_luaentity() if ent and ent.name and string.find(ent.name, "mcl_bows:arrow_entity") then @@ -215,8 +215,8 @@ minetest.register_on_respawnplayer(function(player) end end) -if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then - minetest.register_craft({ +if core.get_modpath("mcl_core") and core.get_modpath("mcl_mobitems") then + core.register_craft({ output = "mcl_bows:arrow 4", recipe = { {"mcl_core:flint"}, diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index c0727944f..0964c4aad 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator(minetest.get_current_modname()) +local S = core.get_translator(core.get_current_modname()) local BOW_DURABILITY = 385 @@ -68,11 +68,11 @@ function mcl_bows.shoot_arrow(arrow_item, pos, dir, yaw, shooter, power, damage, le._knockback = knockback le._collectable = collectable le._arrow_item = arrow_item - local item_def = minetest.registered_items[le._arrow_item] + local item_def = core.registered_items[le._arrow_item] if item_def and item_def._arrow_image then obj:set_properties({ textures = item_def._arrow_image }) end - minetest.sound_play("mcl_bows_bow_shoot", {pos=pos, max_hear_distance=16}, true) + core.sound_play("mcl_bows_bow_shoot", {pos=pos, max_hear_distance=16}, true) if shooter and shooter:is_player() then if le.player == "" then le.player = shooter diff --git a/mods/ITEMS/mcl_bows/crossbow.lua b/mods/ITEMS/mcl_bows/crossbow.lua index 391087a25..685a54bef 100644 --- a/mods/ITEMS/mcl_bows/crossbow.lua +++ b/mods/ITEMS/mcl_bows/crossbow.lua @@ -66,7 +66,7 @@ function mcl_bows_s.shoot_arrow_crossbow(arrow_item, pos, dir, yaw, shooter, pow le._knockback = knockback le._collectable = collectable le._arrow_item = arrow_item - minetest.sound_play("mcl_bows_crossbow_shoot", {pos=pos, max_hear_distance=16}, true) + core.sound_play("mcl_bows_crossbow_shoot", {pos=pos, max_hear_distance=16}, true) if shooter and shooter:is_player() then if obj:get_luaentity().player == "" then obj:get_luaentity().player = shooter diff --git a/mods/ITEMS/mcl_bows/init.lua b/mods/ITEMS/mcl_bows/init.lua index c2db4b6f3..3709b1f43 100644 --- a/mods/ITEMS/mcl_bows/init.lua +++ b/mods/ITEMS/mcl_bows/init.lua @@ -1,12 +1,13 @@ mcl_bows = {} +local modpath = core.get_modpath("mcl_bows") --Bow -dofile(minetest.get_modpath("mcl_bows") .. "/arrow.lua") -dofile(minetest.get_modpath("mcl_bows") .. "/bow.lua") -dofile(minetest.get_modpath("mcl_bows") .. "/rocket.lua") +dofile(modpath.."/arrow.lua") +dofile(modpath.."/bow.lua") +dofile(modpath.."/rocket.lua") --Crossbow -dofile(minetest.get_modpath("mcl_bows") .. "/crossbow.lua") +dofile(modpath.."/crossbow.lua") --Compatiblility with older MineClone worlds minetest.register_alias("mcl_throwing:bow", "mcl_bows:bow") diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index 47d99f8f9..48f91a026 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -14,7 +14,7 @@ local function damage_explosion(self, damagemulitplier, pos) local p = pos or self.object:get_pos() if not p then return end mcl_explosions.explode(p, 3, {}) - local objects = minetest.get_objects_inside_radius(p, 8) + local objects = core.get_objects_inside_radius(p, 8) for _,obj in pairs(objects) do if obj:is_player() then mcl_util.deal_damage(obj, damagemulitplier - vector.distance(p, obj:get_pos()), {type = "explosion"}) @@ -45,14 +45,14 @@ local function particle_explosion(pos) end if type == 1 then - minetest.sound_play("mcl_bows_firework", { + core.sound_play("mcl_bows_firework", { pos = pos, max_hear_distance = 100, gain = 3.0, pitch = fpitch/100 }, true) else - minetest.sound_play("mcl_bows_firework_soft", { + core.sound_play("mcl_bows_firework_soft", { pos = pos, max_hear_distance = 100, gain = 4.0, @@ -61,7 +61,7 @@ local function particle_explosion(pos) end if particle_pattern == 1 then - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 400 * size, time = 0.0001, minpos = pos, @@ -77,7 +77,7 @@ local function particle_explosion(pos) texture = "mcl_bows_firework_"..this_colors[1]..".png", glow = 14, }) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 400 * size, time = 0.0001, minpos = pos, @@ -93,7 +93,7 @@ local function particle_explosion(pos) texture = "mcl_bows_firework_"..this_colors[2]..".png", glow = 14, }) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 100 * size, time = 0.0001, minpos = pos, @@ -111,7 +111,7 @@ local function particle_explosion(pos) }) elseif particle_pattern == 2 then - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 240 * size, time = 0.0001, minpos = pos, @@ -127,7 +127,7 @@ local function particle_explosion(pos) texture = "mcl_bows_firework_"..this_colors[1]..".png", glow = 14, }) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 500 * size, time = 0.0001, minpos = pos, @@ -143,7 +143,7 @@ local function particle_explosion(pos) texture = "mcl_bows_firework_"..this_colors[2]..".png", glow = 14, }) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 350 * size, time = 0.0001, minpos = pos, @@ -161,7 +161,7 @@ local function particle_explosion(pos) }) elseif particle_pattern == 3 then - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 400 * size, time = 0.0001, minpos = pos, @@ -177,7 +177,7 @@ local function particle_explosion(pos) texture = "mcl_bows_firework_"..this_colors[1]..".png", glow = 14, }) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 120 * size, time = 0.0001, minpos = pos, @@ -193,7 +193,7 @@ local function particle_explosion(pos) texture = "mcl_bows_firework_"..this_colors[2]..".png", glow = 14, }) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 130 * size, time = 0.0001, minpos = pos, @@ -215,7 +215,7 @@ local function particle_explosion(pos) end -minetest.register_craftitem("mcl_bows:rocket", { +core.register_craftitem("mcl_bows:rocket", { description = S("Arrow"), _tt_help = S("Ammunition").."\n"..S("Damage from bow: 1-10").."\n"..S("Damage from dispenser: 3"), _doc_items_longdesc = S("Arrows are ammunition for bows and dispensers.").."\n".. @@ -278,8 +278,8 @@ end vl_projectile.register("mcl_bows:rocket_entity", rocket_entity) -if minetest.get_modpath("mcl_core") and minetest.get_modpath("mcl_mobitems") then - minetest.register_craft({ +if core.get_modpath("mcl_core") and core.get_modpath("mcl_mobitems") then + core.register_craft({ output = "mcl_bows:rocket 1", recipe = { {"mcl_core:paper"}, diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index 66cfb1607..a3d51eb1c 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -310,7 +310,7 @@ end bobber_ENTITY.on_step = bobber_on_step -minetest.register_entity("mcl_fishing:bobber_entity", bobber_ENTITY) +core.register_entity("mcl_fishing:bobber_entity", bobber_ENTITY) vl_projectile.register("mcl_fishing:flying_bobber_entity", { physical = false, @@ -336,11 +336,11 @@ vl_projectile.register("mcl_fishing:flying_bobber_entity", { -- Make sure the player field is valid for when we create the floating bobber if not player then return end - local def = minetest.registered_nodes[node.name] + local def = core.registered_nodes[node.name] if not def then return end if def.walkable or def.liquidtype == "flowing" or def.liquidtype == "source" then - local ent = minetest.add_entity(pos, "mcl_fishing:bobber_entity"):get_luaentity() + local ent = core.add_entity(pos, "mcl_fishing:bobber_entity"):get_luaentity() ent.player = player ent.child = true end diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index b51ce94bb..a12b9084e 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -1,7 +1,7 @@ -local S = minetest.get_translator(minetest.get_current_modname()) +local S = core.get_translator(core.get_current_modname()) local PARTICLE_DENSITY = 4 -local mod_target = minetest.get_modpath("mcl_target") +local mod_target = core.get_modpath("mcl_target") local function lingering_image(colorstring, opacity) if not opacity then @@ -37,7 +37,7 @@ local function linger_particles(pos, d, texture, color) end local lingering_timer = 0 -minetest.register_globalstep(function(dtime) +core.register_globalstep(function(dtime) lingering_timer = lingering_timer + dtime if lingering_timer >= 1 then @@ -150,7 +150,7 @@ function mcl_potions.register_lingering(name, descr, color, def) local velocity = 10 local dir = placer:get_look_dir(); local pos = placer:getpos(); - minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) + core.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) local obj = vl_projectile.create(id.."_flying",{ pos = vector.offset(pos, dir.x, dir.y + 1.64, dir.z), owner = placer, diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index de36971d9..f5147b4e5 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -1,5 +1,5 @@ -local S = minetest.get_translator(minetest.get_current_modname()) -local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) +local S = core.get_translator(core.get_current_modname()) +local GRAVITY = tonumber(core.settings:get("movement_gravity")) local REDUX_MAP = {7/8,0.5,0.25} local PARTICLE_DIAMETER = 0.1 local PARTICLE_MIN_VELOCITY = vector.new(-2, 0, -2) @@ -26,7 +26,7 @@ function mcl_potions.register_splash(name, descr, color, def) local groups = {brewitem=1, bottle=1, splash_potion=1, _mcl_potion=1} if def.nocreative then groups.not_in_creative_inventory = 1 end - minetest.register_craftitem(id, { + core.register_craftitem(id, { description = descr, _tt_help = def._tt, _dynamic_tt = def._dynamic_tt, @@ -96,7 +96,7 @@ function mcl_potions.register_splash(name, descr, color, def) particle_texture = particle_texture.."^[colorize:"..color..":127" local function splash_effects(self, pos, def, range) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 50, time = 0.1, minpos = vector.offset(pos, -PARTICLE_DIAMETER, 0.5, -PARTICLE_DIAMETER), @@ -114,7 +114,7 @@ function mcl_potions.register_splash(name, descr, color, def) texture = particle_texture, }) - for _,obj in pairs(minetest.get_objects_inside_radius(pos, range)) do + for _,obj in pairs(core.get_objects_inside_radius(pos, range)) do -- Make sure the potion can interact with this object local entity = obj:get_luaentity() if obj:is_player() or entity and entity.is_mob then diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 0e17328ff..7874993c2 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -1,4 +1,4 @@ -local S = minetest.get_translator(minetest.get_current_modname()) +local S = core.get_translator(core.get_current_modname()) local math = math @@ -11,10 +11,10 @@ local function arrow_image(colorstring, opacity) return {"mcl_bows_arrow.png^(mcl_bows_arrow_overlay.png^[colorize:"..colorstring..":"..tostring(opacity)..")"} end -local how_to_shoot = minetest.registered_items["mcl_bows:arrow"]._doc_items_usagehelp +local how_to_shoot = core.registered_items["mcl_bows:arrow"]._doc_items_usagehelp -local arrow_longdesc = minetest.registered_items["mcl_bows:arrow"]._doc_items_longdesc or "" -local arrow_tt = minetest.registered_items["mcl_bows:arrow"]._tt_help or "" +local arrow_longdesc = core.registered_items["mcl_bows:arrow"]._doc_items_longdesc or "" +local arrow_tt = core.registered_items["mcl_bows:arrow"]._tt_help or "" function mcl_potions.register_arrow(name, desc, color, def) local longdesc = def._longdesc or "" @@ -22,7 +22,7 @@ function mcl_potions.register_arrow(name, desc, color, def) local groups = {ammo=1, ammo_bow=1, brewitem=1, _mcl_potion=1} if def.nocreative then groups.not_in_creative_inventory = 1 end local arrow_item = "mcl_potions:"..name.."_arrow" - minetest.register_craftitem(arrow_item, { + core.register_craftitem(arrow_item, { description = desc, _tt_help = arrow_tt .. "\n" .. tt, _dynamic_tt = def._dynamic_tt, @@ -83,8 +83,8 @@ function mcl_potions.register_arrow(name, desc, color, def) end vl_projectile.register("mcl_potions:"..name.."_arrow_entity", arrow_entity) - if minetest.get_modpath("mcl_bows") then - minetest.register_craft({ + if core.get_modpath("mcl_bows") then + core.register_craft({ output = "mcl_potions:"..name.."_arrow 8", recipe = { {"mcl_bows:arrow","mcl_bows:arrow","mcl_bows:arrow"}, @@ -94,7 +94,7 @@ function mcl_potions.register_arrow(name, desc, color, def) }) end - if minetest.get_modpath("doc_identifier") then + if core.get_modpath("doc_identifier") then doc.sub.identifier.register_object("mcl_bows:arrow_entity", "craftitems", "mcl_bows:arrow") end end diff --git a/mods/ITEMS/mcl_throwing/egg.lua b/mods/ITEMS/mcl_throwing/egg.lua index af6200b13..7e4f92d51 100644 --- a/mods/ITEMS/mcl_throwing/egg.lua +++ b/mods/ITEMS/mcl_throwing/egg.lua @@ -1,11 +1,11 @@ -local modname = minetest.get_current_modname() -local S = minetest.get_translator(modname) +local modname = core.get_current_modname() +local S = core.get_translator(modname) -local mod_target = minetest.get_modpath("mcl_target") +local mod_target = core.get_modpath("mcl_target") local how_to_throw = S("Use the punch key to throw.") -- Egg -minetest.register_craftitem("mcl_throwing:egg", { +core.register_craftitem("mcl_throwing:egg", { description = S("Egg"), _tt_help = S("Throwable").."\n"..S("Chance to hatch chicks when broken"), _doc_items_longdesc = S("Eggs can be thrown or launched from a dispenser and breaks on impact. There is a small chance that 1 or even 4 chicks will pop out of the egg."), diff --git a/mods/ITEMS/mcl_throwing/ender_pearl.lua b/mods/ITEMS/mcl_throwing/ender_pearl.lua index 73c0cd237..dd0497af3 100644 --- a/mods/ITEMS/mcl_throwing/ender_pearl.lua +++ b/mods/ITEMS/mcl_throwing/ender_pearl.lua @@ -1,16 +1,16 @@ -local modname = minetest.get_current_modname() -local S = minetest.get_translator(modname) +local modname = core.get_current_modname() +local S = core.get_translator(modname) local math = math local vector = vector -local mod_target = minetest.get_modpath("mcl_target") +local mod_target = core.get_modpath("mcl_target") local how_to_throw = S("Use the punch key to throw.") -- Ender Pearl -minetest.register_craftitem("mcl_throwing:ender_pearl", { +core.register_craftitem("mcl_throwing:ender_pearl", { description = S("Ender Pearl"), - _tt_help = S("Throwable").."\n"..minetest.colorize(mcl_colors.YELLOW, S("Teleports you on impact for cost of 5 HP")), + _tt_help = S("Throwable").."\n"..core.colorize(mcl_colors.YELLOW, S("Teleports you on impact for cost of 5 HP")), _doc_items_longdesc = S("An ender pearl is an item which can be used for teleportation at the cost of health. It can be thrown and teleport the thrower to its impact location when it hits a solid block or a plant. Each teleportation hurts the user by 5 hit points."), _doc_items_usagehelp = how_to_throw, wield_image = "mcl_throwing_ender_pearl.png", @@ -31,7 +31,7 @@ function on_collide(self, pos, node) end -- Make sure we have a reference to the player - local player = self._thrower and minetest.get_player_by_name(self._thrower) + local player = self._thrower and core.get_player_by_name(self._thrower) if not player then return end -- Teleport and hurt player @@ -40,7 +40,7 @@ function on_collide(self, pos, node) local dir = vector.zero() local v = self.object:get_velocity() - local node_def = minetest.registered_nodes[node.name] + local node_def = core.registered_nodes[node.name] if node_def and node_def.walkable then local vc = vector.normalize(v) -- vector for calculating -- Node is walkable, we have to find a place somewhere outside of that node @@ -75,12 +75,12 @@ function on_collide(self, pos, node) -- Final teleportation position local telepos = vector.add(pos, dir) - local telenode = minetest.get_node(telepos) + local telenode = core.get_node(telepos) --[[ It may be possible that telepos is walkable due to the algorithm. Especially when the ender pearl is faster horizontally than vertical. This applies final fixing, just to be sure we're not in a walkable node ]] - if not minetest.registered_nodes[telenode.name] or minetest.registered_nodes[telenode.name].walkable then + if not core.registered_nodes[telenode.name] or core.registered_nodes[telenode.name].walkable then if v.y < 0 then telepos.y = telepos.y + 0.5 else @@ -95,7 +95,7 @@ function on_collide(self, pos, node) -- 5% chance to spawn endermite at the player's origin if math.random(1,20) == 1 then - minetest.add_entity(oldpos, "mobs_mc:endermite") + core.add_entity(oldpos, "mobs_mc:endermite") end end @@ -131,7 +131,7 @@ vl_projectile.register("mcl_throwing:ender_pearl_entity",{ return le and (le.is_mob or le._hittable_by_projectile) or object:is_player() end, on_collide_with_entity = function(self, pos, entity) - on_collide(self, pos, minetest.get_node(pos)) + on_collide(self, pos, core.get_node(pos)) end, on_collide_with_solid = on_collide, }, diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index da731d6c3..ebc361638 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -1,6 +1,6 @@ mcl_throwing = {} -local modpath = minetest.get_modpath(minetest.get_current_modname()) +local modpath = core.get_modpath(core.get_current_modname()) -- -- Snowballs and other throwable items @@ -12,13 +12,13 @@ local velocities = {} function mcl_throwing.register_throwable_object(name, entity, velocity) entity_mapping[name] = entity velocities[name] = velocity - assert(minetest.registered_entities[entity], entity.." not registered") - assert(minetest.registered_entities[entity]._vl_projectile) + assert(core.registered_entities[entity], entity.." not registered") + assert(core.registered_entities[entity]._vl_projectile) end function mcl_throwing.throw(throw_item, pos, dir, velocity, thrower) velocity = velocity or velocities[throw_item] or 22 - minetest.sound_play("mcl_throwing_throw", {pos=pos, gain=0.4, max_hear_distance=16}, true) + core.sound_play("mcl_throwing_throw", {pos=pos, gain=0.4, max_hear_distance=16}, true) local itemstring = ItemStack(throw_item):get_name() local obj = vl_projectile.create(entity_mapping[itemstring], { @@ -67,7 +67,7 @@ function mcl_throwing.get_staticdata(self) end function mcl_throwing.on_activate(self, staticdata, dtime_s) - local data = minetest.deserialize(staticdata) + local data = core.deserialize(staticdata) self._staticdata = data if data then self._lastpos = data._lastpos diff --git a/mods/ITEMS/mcl_throwing/register.lua b/mods/ITEMS/mcl_throwing/register.lua index eac582b4b..2e0407d39 100644 --- a/mods/ITEMS/mcl_throwing/register.lua +++ b/mods/ITEMS/mcl_throwing/register.lua @@ -1,5 +1,5 @@ -local modname = minetest.get_current_modname() -local modpath = minetest.get_modpath(modname) +local modname = core.get_current_modname() +local modpath = core.get_modpath(modname) dofile(modpath.."/snowball.lua") dofile(modpath.."/egg.lua") diff --git a/mods/ITEMS/mcl_throwing/snowball.lua b/mods/ITEMS/mcl_throwing/snowball.lua index fbfe7931b..842f93dbb 100644 --- a/mods/ITEMS/mcl_throwing/snowball.lua +++ b/mods/ITEMS/mcl_throwing/snowball.lua @@ -1,11 +1,11 @@ -local modname = minetest.get_current_modname() -local S = minetest.get_translator(modname) +local modname = core.get_current_modname() +local S = core.get_translator(modname) -local mod_target = minetest.get_modpath("mcl_target") +local mod_target = core.get_modpath("mcl_target") local how_to_throw = S("Use the punch key to throw.") -- Snowball -minetest.register_craftitem("mcl_throwing:snowball", { +core.register_craftitem("mcl_throwing:snowball", { description = S("Snowball"), _tt_help = S("Throwable"), _doc_items_longdesc = S("Snowballs can be thrown or launched from a dispenser for fun. Hitting something with a snowball does nothing."), @@ -20,7 +20,7 @@ minetest.register_craftitem("mcl_throwing:snowball", { -- The snowball entity local function snowball_particles(pos, vel) local vel = vector.normalize(vector.multiply(vel, -1)) - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 20, time = 0.001, minpos = pos, diff --git a/mods/ITEMS/vl_projectile/api.md b/mods/ITEMS/vl_projectile/api.md index 7e5711f17..614c18e18 100644 --- a/mods/ITEMS/vl_projectile/api.md +++ b/mods/ITEMS/vl_projectile/api.md @@ -6,8 +6,8 @@ Registers a projectile entity. Arguments: -* `entity_name`: The name the entity will be refered to by the minetest engine -* `def`: Projectile defintion. Supports all fields that standard minetest entities support. +* `entity_name`: The name the entity will be refered to by the Luanti engine +* `def`: Projectile defintion. Supports all fields that standard Luanti entities support. Must include the field `_vl_projectile` for projectile-specific behaviors. These are the supported fields: * `ignore_gravity`: if true, the projectile will not be affected by gravity @@ -25,7 +25,7 @@ Arguments: behaviors: `vl_projectiles.collides_with_solids`, `vl_projectiles.collides_with_entities` and `vl_projectiles.raycast_collides_with_entities` * `maximum_time`: number of seconds until projectiles are removed. * `sounds`: sounds for this projectile. All fields take a table with three parameters corresponding to the - three parameters for `minetest.play_sound()`. Supported sounds are: + three parameters for `core.play_sound()`. Supported sounds are: * `on_collision`: played when no other more specific sound is defined. May be a function of type `function(projectile, entity_def, projectile_def, type, ...)` * `on_solid_collision`: played when the projectile collides with a solid node. May be a function of type `funciton(projectile, entity_def, projectile_def, type, pos, node, node_def)` with `type = "node"` @@ -93,7 +93,7 @@ Arguments: * `self`: The lua entity of the projectile * `dtime`: The amount of time that has passed since the last update. Nomally the `dtime` parameter of the entity's `on_step(self, dtime)` callback. -* `entity_def`: The definition from `minetest.registered_entities` for the projectile. +* `entity_def`: The definition from `core.registered_entities` for the projectile. * `projectile_def`: Same as `entity_def._vl_projectile` diff --git a/mods/ITEMS/vl_projectile/init.lua b/mods/ITEMS/vl_projectile/init.lua index 6aa725091..e05d084c9 100644 --- a/mods/ITEMS/vl_projectile/init.lua +++ b/mods/ITEMS/vl_projectile/init.lua @@ -1,20 +1,20 @@ vl_projectile = {} local mod = vl_projectile -local vl_physics_path = minetest.get_modpath("vl_physics") +local vl_physics_path = core.get_modpath("vl_physics") local DEBUG = false local YAW_OFFSET = -math.pi/2 -local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) +local GRAVITY = tonumber(core.settings:get("movement_gravity")) local STUCK_TIMEOUT = 60 local STUCK_RECHECK_TIME = 0.25 -local enable_pvp = minetest.settings:get_bool("enable_pvp") +local enable_pvp = core.settings:get_bool("enable_pvp") function mod.projectile_physics(obj, entity_def, v, a) local le = obj:get_luaentity() if not le then return end - local entity_def = minetest.registered_entities[le.name] + local entity_def = core.registered_entities[le.name] local pos = obj:get_pos() if not pos then return end @@ -30,7 +30,7 @@ function mod.projectile_physics(obj, entity_def, v, a) end if entity_def.liquid_drag then - local def = minetest.registered_nodes[minetest.get_node(pos).name] + local def = core.registered_nodes[core.get_node(pos).name] if def and def.liquidtype ~= "none" then -- Slow down arrow in liquids local visc = def.liquid_viscosity or 0 @@ -53,7 +53,7 @@ function mod.projectile_physics(obj, entity_def, v, a) -- Update projectile yaw to match velocity direction if v and le and not le._stuck then - local yaw = minetest.dir_to_yaw(v) + YAW_OFFSET + (entity_def._vl_projectile.yaw_offset or 0) + local yaw = core.dir_to_yaw(v) + YAW_OFFSET + (entity_def._vl_projectile.yaw_offset or 0) local pitch = math.asin(vector.normalize(v).y) + (entity_def._vl_projectile.pitch_offset or 0) obj:set_rotation(vector.new(0,yaw,pitch)) end @@ -77,7 +77,7 @@ function mod.update_projectile(self, dtime) end local entity_name = self.name - local entity_def = minetest.registered_entities[entity_name] or {} + local entity_def = core.registered_entities[entity_name] or {} local entity_vl_projectile = entity_def._vl_projectile or {} -- Update entity timer and remove expired projectiles @@ -106,7 +106,7 @@ end local function damage_particles(pos, is_critical) if is_critical then - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 15, time = 0.1, minpos = vector.offset(pos, -0.5, -0.5, -0.5), @@ -147,8 +147,10 @@ local function check_hitpoint(hitpoint) return true end - if not hitpoint.ref:is_player() and hitpoint.ref:get_luaentity() then - if (hitpoint.ref:get_luaentity().is_mob or hitpoint.ref:get_luaentity()._hittable_by_projectile) then + local obj = hitpoint.ref + local le = obj:get_luaentity() + if not obj:is_player() and le then + if (le.is_mob or le._hittable_by_projectile) then return true end end @@ -159,7 +161,7 @@ local function handle_player_sticking(self, entity_def, projectile_def, entity) if self._in_player or self._blocked then return end if not projectile_def.sticks_in_players then return end - minetest.after(150, function() mcl_util.remove_entity(self) end) + core.after(150, function() mcl_util.remove_entity(self) end) -- Handle blocking projectiles if mcl_shields.is_blocking(entity) then @@ -207,10 +209,10 @@ function mod.burns(self, dtime, entity_def, projectile_def) if not pos then return true end -- Handle getting set on fire - local node = minetest.get_node(vector.round(pos)) + local node = core.get_node(vector.round(pos)) if not node or node.name == "ignore" then return end - local set_on_fire = minetest.get_item_group(node.name, "set_on_fire") + local set_on_fire = core.get_item_group(node.name, "set_on_fire") if set_on_fire ~= 0 then mcl_burning.set_on_fire(self.object, set_on_fire) end @@ -228,7 +230,7 @@ function mod.has_tracer(self, dtime, entity_def, projectile_def) if hide_tracer and hide_tracer(self) then return end -- Add tracer - minetest.add_particlespawner({ + core.add_particlespawner({ amount = 20, time = .2, minpos = vector.zero(), @@ -257,8 +259,8 @@ function mod.replace_with_item_drop(self, pos, projectile_def) item = projectile_def.item end - if item and self._collectable and not minetest.is_creative_enabled("") then - local item = minetest.add_item(pos, item) + if item and self._collectable and not core.is_creative_enabled("") then + local item = core.add_item(pos, item) item:set_velocity(vector.zero()) item:set_yaw(self.object:get_yaw()) end @@ -285,8 +287,8 @@ local function stuck_on_step(self, dtime, entity_def, projectile_def) if self._stuckrechecktimer > 1 then self._stuckrechecktimer = 0 if self._stuckin then - local node = minetest.get_node(self._stuckin) - local node_def = minetest.registered_nodes[node.name] + local node = core.get_node(self._stuckin) + local node_def = core.registered_nodes[node.name] if node_def and node_def.walkable == false then mod.replace_with_item_drop(self, pos, projectile_def) return @@ -300,21 +302,21 @@ local function stuck_on_step(self, dtime, entity_def, projectile_def) -- Pickup arrow if player is nearby (not in Creative Mode) if self._removed then return end - local objects = minetest.get_objects_inside_radius(pos, 1) + local objects = core.get_objects_inside_radius(pos, 1) for i = 1,#objects do local obj = objects[i] if obj:is_player() then local player_name = obj:get_player_name() - local creative = minetest.is_creative_enabled(player_name) + local creative = core.is_creative_enabled(player_name) if self._collectable and not creative then local arrow_item = self._itemstring or self._arrow_item - if arrow_item and minetest.registered_items[arrow_item] and obj:get_inventory():room_for_item("main", arrow_item) then + if arrow_item and core.registered_items[arrow_item] and obj:get_inventory():room_for_item("main", arrow_item) then obj:get_inventory():add_item("main", arrow_item) self._picked_up = true end end - minetest.sound_play("item_drop_pickup", { + core.sound_play("item_drop_pickup", { pos = pos, max_hear_distance = 16, gain = 1.0, @@ -346,8 +348,8 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def) if not self._last_pos then return end -- Check if the object can collide with this node - local node = minetest.get_node(pos) - local node_def = minetest.registered_nodes[node.name] + local node = core.get_node(pos) + local node_def = core.registered_nodes[node.name] local collides_with = projectile_def.collides_with if entity_def.physical then @@ -386,12 +388,12 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def) dir = vector.new(0, -1, 0) end else - dir = minetest.facedir_to_dir(minetest.dir_to_facedir(minetest.yaw_to_dir(self.object:get_yaw()-YAW_OFFSET))) + dir = core.facedir_to_dir(core.dir_to_facedir(core.yaw_to_dir(self.object:get_yaw()-YAW_OFFSET))) end self._stuckin = vector.add(dpos, dir) - local snode = minetest.get_node(self._stuckin) - local sdef = minetest.registered_nodes[snode.name] + local snode = core.get_node(self._stuckin) + local sdef = core.registered_nodes[snode.name] -- If node is non-walkable, unknown or ignore, don't make arrow stuck. -- This causes a deflection in the engine. @@ -436,7 +438,7 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def) if sound then local arg2 = table.copy(sound[2]) arg2.pos = pos - minetest.sound_play(sound[1], arg2, sound[3]) + core.sound_play(sound[1], arg2, sound[3]) end -- Normally objects should be removed on collision with solids @@ -508,7 +510,7 @@ local function handle_entity_collision(self, entity_def, projectile_def, object) if hook then hook(self, pos, object) end -- Call reverse entity collision hook - local other_entity_def = minetest.registered_entities[object.name] or {} + local other_entity_def = core.registered_entities[object.name] or {} local other_entity_vl_projectile = other_entity_def._vl_projectile or {} local hook = other_entity_vl_projectile and other_entity_vl_projectile.on_collide if hook then hook(object, self) end @@ -520,7 +522,7 @@ local function handle_entity_collision(self, entity_def, projectile_def, object) if sound then local arg2 = table.copy(sound[2]) arg2.pos = pos - minetest.sound_play(sound[1], arg2, sound[3]) + core.sound_play(sound[1], arg2, sound[3]) end -- Remove the projectile if it didn't survive @@ -537,7 +539,7 @@ end function mod.collides_with_entities(self, dtime, entity_def, projectile_def) local pos = self.object:get_pos() - local objects = minetest.get_objects_inside_radius(pos, 1.5) + local objects = core.get_objects_inside_radius(pos, 1.5) for i = 1,#objects do local object = objects[i] local entity = object:get_luaentity() @@ -561,7 +563,7 @@ function mod.raycast_collides_with_entities(self, dtime, entity_def, projectile_ local arrow_dir = self.object:get_velocity() --create a raycast from the arrow based on the velocity of the arrow to deal with lag - local raycast = minetest.raycast(pos, vector.add(pos, vector.multiply(arrow_dir, 0.1)), true, false) + local raycast = core.raycast(pos, vector.add(pos, vector.multiply(arrow_dir, 0.1)), true, false) for hitpoint in raycast do if check_hitpoint(hitpoint) then local hitpoint_ref = hitpoint.ref @@ -580,7 +582,7 @@ end function mod.create(entity_id, options) local pos = options.pos - local obj = minetest.add_entity(pos, entity_id, options.staticdata) + local obj = core.add_entity(pos, entity_id, options.staticdata) -- Set initial velocity and acceleration local a, v @@ -591,7 +593,7 @@ function mod.create(entity_id, options) a = vector.zero() v = a end - local entity_def = minetest.registered_entities[entity_id] + local entity_def = core.registered_entities[entity_id] mod.projectile_physics(obj, entity_def, v, a) -- Update projectile parameters @@ -645,6 +647,6 @@ function mod.register(name, def) def._shooter = nil def._last_pos = nil - minetest.register_entity(name, def) + core.register_entity(name, def) end