Call 'core.*' instead of 'minetest.*'

This commit is contained in:
AntumDeluge 2017-07-28 17:10:57 -07:00 committed by Jordan Irwin
parent 88794f7a8f
commit 3497f917f9
5 changed files with 62 additions and 62 deletions

@ -1,13 +1,13 @@
-- Functions for sneeker mod -- Functions for sneeker mod
local log_mods = minetest.settings:get_bool("log_mods", false) local log_mods = core.settings:get_bool("log_mods", false)
-- Displays a message in log output -- Displays a message in log output
function sneeker.log(message) function sneeker.log(message)
if log_mods then if log_mods then
minetest.log('action', '[' .. sneeker.modname .. '] ' .. message) core.log('action', '[' .. sneeker.modname .. '] ' .. message)
end end
end end
@ -20,7 +20,7 @@ end
-- Spawns a sneeker entity -- Spawns a sneeker entity
function sneeker.spawn(pos) function sneeker.spawn(pos)
minetest.add_entity(pos, sneeker.mob_name) core.add_entity(pos, sneeker.mob_name)
sneeker.log_debug('Spawned entity "' .. sneeker.mob_name .. '" at ' .. tostring(pos.x) .. ',' .. tostring(pos.y)) sneeker.log_debug('Spawned entity "' .. sneeker.mob_name .. '" at ' .. tostring(pos.x) .. ',' .. tostring(pos.y))
end end

@ -2,11 +2,11 @@
sneeker = {} sneeker = {}
sneeker.modname = minetest.get_current_modname() sneeker.modname = core.get_current_modname()
sneeker.modpath = minetest.get_modpath(sneeker.modname) sneeker.modpath = core.get_modpath(sneeker.modname)
if minetest.settings:get_bool("log_mods", false) then if core.settings:get_bool("log_mods", false) then
minetest.log("action", "Loading mod \"" .. sneeker.modname .. "\" ...") core.log("action", "Loading mod \"" .. sneeker.modname .. "\" ...")
end end
dofile(sneeker.modpath .. "/settings.lua") dofile(sneeker.modpath .. "/settings.lua")
@ -28,21 +28,21 @@ end
local function jump(self,pos,direction) local function jump(self,pos,direction)
local velocity = self.object:get_velocity() local velocity = self.object:get_velocity()
if minetest.registered_nodes[minetest.get_node(pos).name].climbable then if core.registered_nodes[core.get_node(pos).name].climbable then
self.object:set_velocity({x=velocity.x,y=4,z=velocity.z}) self.object:set_velocity({x=velocity.x,y=4,z=velocity.z})
return return
end end
local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z} local spos = {x=pos.x+direction.x,y=pos.y,z=pos.z+direction.z}
local node = minetest.get_node_or_nil(spos) local node = core.get_node_or_nil(spos)
spos.y = spos.y+1 spos.y = spos.y+1
local node2 = minetest.get_node_or_nil(spos) local node2 = core.get_node_or_nil(spos)
local def,def2 = {} local def,def2 = {}
if node and node.name then if node and node.name then
def = minetest.registered_items[node.name] def = core.registered_items[node.name]
end end
if node2 and node2.name then if node2 and node2.name then
def2 = minetest.registered_items[node2.name] def2 = core.registered_items[node2.name]
end end
if def and def.walkable if def and def.walkable
and def2 and not def2.walkable and def2 and not def2.walkable
@ -105,7 +105,7 @@ def.on_activate = function(self,staticdata)
self.state = math.random(1,2) self.state = math.random(1,2)
self.old_y = self.object:get_pos().y self.old_y = self.object:get_pos().y
local data = minetest.deserialize(staticdata) local data = core.deserialize(staticdata)
if data and type(data) == "table" then if data and type(data) == "table" then
if data.powered == true then if data.powered == true then
self.powered = true self.powered = true
@ -134,7 +134,7 @@ def.on_step = function(self, dtime)
local pos = self.object:get_pos() local pos = self.object:get_pos()
local yaw = self.object:get_yaw() local yaw = self.object:get_yaw()
local inside = minetest.get_objects_inside_radius(pos,10) local inside = core.get_objects_inside_radius(pos,10)
local walk_speed = self.walk_speed local walk_speed = self.walk_speed
local animation = self.animation local animation = self.animation
local anim_speed = self.animation_speed local anim_speed = self.animation_speed
@ -164,7 +164,7 @@ def.on_step = function(self, dtime)
if self.chase and self.visualx < 2 then if self.chase and self.visualx < 2 then
if self.hiss == false then if self.hiss == false then
minetest.sound_play("sneeker_hiss",{pos=pos,gain=1.5,max_hear_distance=2*64}) core.sound_play("sneeker_hiss",{pos=pos,gain=1.5,max_hear_distance=2*64})
end end
self.visualx = self.visualx+0.05 self.visualx = self.visualx+0.05
self.object:set_properties({ self.object:set_properties({
@ -220,7 +220,7 @@ def.on_step = function(self, dtime)
local direction = self.direction local direction = self.direction
local npos = {x=pos.x+direction.x,y=pos.y+0.2,z=pos.z+direction.z} local npos = {x=pos.x+direction.x,y=pos.y+0.2,z=pos.z+direction.z}
if velocity.x == 0 or velocity.z == 0 if velocity.x == 0 or velocity.z == 0
or minetest.registered_nodes[minetest.get_node(npos).name].walkable then or core.registered_nodes[core.get_node(npos).name].walkable then
local select_turn = math.random(1,2) local select_turn = math.random(1,2)
if select_turn == 1 then if select_turn == 1 then
self.turn = "left" self.turn = "left"
@ -246,7 +246,7 @@ def.on_step = function(self, dtime)
self.turn = "straight" self.turn = "straight"
local inside_2 = minetest.get_objects_inside_radius(pos,2) local inside_2 = core.get_objects_inside_radius(pos,2)
-- Boom -- Boom
if #inside_2 ~= 0 then if #inside_2 ~= 0 then
@ -256,7 +256,7 @@ def.on_step = function(self, dtime)
if self.visualx >= 2 then if self.visualx >= 2 then
self.object:remove() self.object:remove()
sneeker.boom(pos,self.powered) sneeker.boom(pos,self.powered)
minetest.sound_play("sneeker_explode",{pos=pos,gain=1.5,max_hear_distance=2*64}) core.sound_play("sneeker_explode",{pos=pos,gain=1.5,max_hear_distance=2*64})
end end
end end
end end
@ -316,8 +316,8 @@ def.on_step = function(self, dtime)
end end
-- Swim -- Swim
local node = minetest.get_node(pos) local node = core.get_node(pos)
if minetest.get_item_group(node.name,"water") ~= 0 then if core.get_item_group(node.name,"water") ~= 0 then
self.object:set_acceleration({x=0,y=1,z=0}) self.object:set_acceleration({x=0,y=1,z=0})
local velocity = self.object:get_velocity() local velocity = self.object:get_velocity()
if self.object:get_velocity().y > 5 then if self.object:get_velocity().y > 5 then
@ -335,7 +335,7 @@ def.on_punch = function(self,puncher,time_from_last_punch,tool_capabilities,dir)
local knockback_level = self.knockback_level local knockback_level = self.knockback_level
self.object:set_velocity({x=dir.x*knockback_level,y=3,z=dir.z*knockback_level}) self.object:set_velocity({x=dir.x*knockback_level,y=3,z=dir.z*knockback_level})
self.knockback = true self.knockback = true
minetest.after(0.6,function() core.after(0.6,function()
self.knockback = false self.knockback = false
end) end)
end end
@ -344,24 +344,24 @@ def.on_punch = function(self,puncher,time_from_last_punch,tool_capabilities,dir)
local x = 1/math.random(1,5)*dir.x local x = 1/math.random(1,5)*dir.x
local z = 1/math.random(1,5)*dir.z local z = 1/math.random(1,5)*dir.z
local p = {x=pos.x+x,y=pos.y,z=pos.z+z} local p = {x=pos.x+x,y=pos.y,z=pos.z+z}
local node = minetest.get_node_or_nil(p) local node = core.get_node_or_nil(p)
if node == nil or not node.name or node.name ~= "air" then if node == nil or not node.name or node.name ~= "air" then
p = pos p = pos
end end
local obj = minetest.add_item(p, {name="tnt:gunpowder",count=math.random(0,2)}) local obj = core.add_item(p, {name="tnt:gunpowder",count=math.random(0,2)})
end end
end end
def.get_staticdata = function(self) def.get_staticdata = function(self)
return minetest.serialize({ return core.serialize({
powered = self.powered powered = self.powered
}) })
end end
minetest.register_entity(sneeker.mob_name, def) core.register_entity(sneeker.mob_name, def)
if minetest.global_exists("spawneggs") then if core.global_exists("spawneggs") then
minetest.register_craftitem(sneeker.spawnegg_name, { core.register_craftitem(sneeker.spawnegg_name, {
description = "Sneeker Spawn Egg", description = "Sneeker Spawn Egg",
inventory_image = "sneeker_spawnegg.png", inventory_image = "sneeker_spawnegg.png",
stack_max = 64, stack_max = 64,
@ -369,8 +369,8 @@ if minetest.global_exists("spawneggs") then
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local pos = pointed_thing.above local pos = pointed_thing.above
pos.y = pos.y+1 pos.y = pos.y+1
minetest.add_entity(pos, sneeker.mob_name) core.add_entity(pos, sneeker.mob_name)
if not minetest.settings:get_bool("creative_mode", false) then if not core.settings:get_bool("creative_mode", false) then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack
@ -378,11 +378,11 @@ if minetest.global_exists("spawneggs") then
end end
}) })
minetest.register_craft({ core.register_craft({
output = sneeker.spawnegg_name, output = sneeker.spawnegg_name,
type = "shapeless", type = "shapeless",
recipe = {"spawneggs:egg", "tnt:tnt",}, recipe = {"spawneggs:egg", "tnt:tnt",},
}) })
minetest.register_alias("spawneggs:sneeker", sneeker.spawnegg_name) core.register_alias("spawneggs:sneeker", sneeker.spawnegg_name)
end end

@ -1,4 +1,4 @@
-- Settings for sneeker mod -- Settings for sneeker mod
sneeker.debug = minetest.settings:get_bool("enable_debug_mods", false) sneeker.debug = core.settings:get_bool("enable_debug_mods", false)

@ -5,10 +5,10 @@ local time_min = 60
local time_hr = time_min * 60 local time_hr = time_min * 60
local time_day = time_hr * 24 local time_day = time_hr * 24
local spawn_cap = tonumber(minetest.settings:get("sneeker.spawn_cap")) or 10 -- Maximum number of spawns active at one time local spawn_cap = tonumber(core.settings:get("sneeker.spawn_cap")) or 10 -- Maximum number of spawns active at one time
local spawn_chance = tonumber(minetest.settings:get("sneeker.spawn_chance")) or 1000 -- 1/1000 chance of spawn local spawn_chance = tonumber(core.settings:get("sneeker.spawn_chance")) or 1000 -- 1/1000 chance of spawn
local spawn_interval = tonumber(minetest.settings:get("sneeker.spawn_interval")) or time_min * 4 -- Default interval is 4 minutes local spawn_interval = tonumber(core.settings:get("sneeker.spawn_interval")) or time_min * 4 -- Default interval is 4 minutes
local spawn_maxlight = tonumber(minetest.settings:get("sneeker.spawn_maxlight")) or 5 -- Maximum light of node for spawn local spawn_maxlight = tonumber(core.settings:get("sneeker.spawn_maxlight")) or 5 -- Maximum light of node for spawn
-- Display spawn chance as percentage in log -- Display spawn chance as percentage in log
local spawn_chance_percent = math.floor(1 / spawn_chance * 100) local spawn_chance_percent = math.floor(1 / spawn_chance * 100)
@ -23,7 +23,7 @@ sneeker.log("Spawn chance: " .. spawn_chance_percent)
sneeker.log("Spawn interval: " .. tostring(spawn_interval) .. " (" .. tostring(spawn_interval/60) .. " minute(s))") sneeker.log("Spawn interval: " .. tostring(spawn_interval) .. " (" .. tostring(spawn_interval/60) .. " minute(s))")
sneeker.log("Maximum light value for spawn: " .. tostring(spawn_maxlight)) sneeker.log("Maximum light value for spawn: " .. tostring(spawn_maxlight))
minetest.register_abm({ core.register_abm({
nodenames = {"default:dirt_with_grass", "default:stone"}, nodenames = {"default:dirt_with_grass", "default:stone"},
neighbors = {"air"}, neighbors = {"air"},
interval = spawn_interval, interval = spawn_interval,
@ -35,7 +35,7 @@ minetest.register_abm({
-- Check light value of node -- Check light value of node
pos.y = pos.y+1 pos.y = pos.y+1
local node_light = minetest.get_node_light(pos) local node_light = core.get_node_light(pos)
-- Debugging spawning -- Debugging spawning
sneeker.log_debug("Node light level at " .. sneeker.get_pos_string(pos) .. ": " .. tostring(node_light)) sneeker.log_debug("Node light level at " .. sneeker.get_pos_string(pos) .. ": " .. tostring(node_light))
@ -51,18 +51,18 @@ minetest.register_abm({
end end
-- Node must be touching air -- Node must be touching air
if minetest.get_node(pos).name ~= "air" then if core.get_node(pos).name ~= "air" then
return return
end end
pos.y = pos.y+1 pos.y = pos.y+1
if minetest.get_node(pos).name ~= "air" then if core.get_node(pos).name ~= "air" then
return return
end end
-- Get total count of sneekers in world -- Get total count of sneekers in world
local count = 0 local count = 0
for I in pairs(minetest.luaentities) do for I in pairs(core.luaentities) do
if minetest.luaentities[I].name == sneeker.mob_name then if core.luaentities[I].name == sneeker.mob_name then
count = count + 1 count = count + 1
end end
end end

@ -3,15 +3,15 @@
-- From TNT -- From TNT
local cid_data = {} local cid_data = {}
local radius = tonumber(minetest.settings:get("tnt_radius") or 3) local radius = tonumber(core.settings:get("tnt_radius") or 3)
local large_radius = 5 local large_radius = 5
local loss_prob = { local loss_prob = {
["default:cobble"] = 3, ["default:cobble"] = 3,
["default:dirt"] = 4, ["default:dirt"] = 4,
} }
minetest.after(0, function() core.after(0, function()
for name, def in pairs(minetest.registered_nodes) do for name, def in pairs(core.registered_nodes) do
cid_data[minetest.get_content_id(name)] = { cid_data[core.get_content_id(name)] = {
name = name, name = name,
drops = def.drops, drops = def.drops,
flammable = def.groups.flammable, flammable = def.groups.flammable,
@ -37,7 +37,7 @@ local function eject_drops(drops, pos, radius)
item:set_count(count) item:set_count(count)
end end
rand_pos(pos, drop_pos, radius) rand_pos(pos, drop_pos, radius)
local obj = minetest.add_item(drop_pos, item) local obj = core.add_item(drop_pos, item)
if obj then if obj then
obj:get_luaentity().collect = true obj:get_luaentity().collect = true
obj:set_acceleration({x=0, y=-10, z=0}) obj:set_acceleration({x=0, y=-10, z=0})
@ -65,7 +65,7 @@ local function add_drop(drops, item)
end end
local function destroy(drops, pos, cid) local function destroy(drops, pos, cid)
if minetest.is_protected(pos, "") then if core.is_protected(pos, "") then
return return
end end
local def = cid_data[cid] local def = cid_data[cid]
@ -73,9 +73,9 @@ local function destroy(drops, pos, cid)
def.on_blast(vector.new(pos), 1) def.on_blast(vector.new(pos), 1)
return return
end end
minetest.remove_node(pos) core.remove_node(pos)
if def then if def then
local node_drops = minetest.get_node_drops(def.name, "") local node_drops = core.get_node_drops(def.name, "")
for _, item in ipairs(node_drops) do for _, item in ipairs(node_drops) do
add_drop(drops, item) add_drop(drops, item)
end end
@ -101,7 +101,7 @@ end
local function entity_physics(pos, radius) local function entity_physics(pos, radius)
-- Make the damage radius larger than the destruction radius -- Make the damage radius larger than the destruction radius
radius = radius * 2 radius = radius * 2
local objs = minetest.get_objects_inside_radius(pos, radius) local objs = core.get_objects_inside_radius(pos, radius)
for _, obj in pairs(objs) do for _, obj in pairs(objs) do
local obj_pos = obj:get_pos() local obj_pos = obj:get_pos()
local obj_vel = obj:get_velocity() local obj_vel = obj:get_velocity()
@ -118,7 +118,7 @@ local function entity_physics(pos, radius)
end end
local function add_effects(pos, radius) local function add_effects(pos, radius)
minetest.add_particlespawner({ core.add_particlespawner({
amount = 128, amount = 128,
time = 1, time = 1,
minpos = vector.subtract(pos, radius / 2), minpos = vector.subtract(pos, radius / 2),
@ -149,16 +149,16 @@ local function explode(pos, radius)
local drops = {} local drops = {}
local p = {} local p = {}
local c_air = minetest.get_content_id("air") local c_air = core.get_content_id("air")
local c_tnt = nil local c_tnt = nil
if minetest.settings:get_bool("enable_tnt", false) then if core.settings:get_bool("enable_tnt", false) then
c_tnt = minetest.get_content_id("tnt:tnt") c_tnt = core.get_content_id("tnt:tnt")
end end
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning") local c_tnt_burning = core.get_content_id("tnt:tnt_burning")
local c_gunpowder = minetest.get_content_id("tnt:gunpowder") local c_gunpowder = core.get_content_id("tnt:gunpowder")
local c_gunpowder_burning = minetest.get_content_id("tnt:gunpowder_burning") local c_gunpowder_burning = core.get_content_id("tnt:gunpowder_burning")
local c_boom = minetest.get_content_id("tnt:boom") local c_boom = core.get_content_id("tnt:boom")
for z = -radius, radius do for z = -radius, radius do
for y = -radius, radius do for y = -radius, radius do
@ -192,9 +192,9 @@ function sneeker.boom(pos,large)
if large then if large then
radius = large_radius radius = large_radius
end end
minetest.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64}) core.sound_play("sneeker_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
minetest.set_node(pos, {name="tnt:boom"}) core.set_node(pos, {name="tnt:boom"})
minetest.get_node_timer(pos):start(0.5) core.get_node_timer(pos):start(0.5)
local drops = explode(pos, radius) local drops = explode(pos, radius)
entity_physics(pos, radius) entity_physics(pos, radius)
eject_drops(drops, pos, radius) eject_drops(drops, pos, radius)