Revert "Phew, use the core namespace for everything instead of minetest"

This reverts commit 4af67a5d54.
This commit is contained in:
KaadmY 2017-05-11 19:29:55 -07:00
parent 4af67a5d54
commit b667b4561e
58 changed files with 1169 additions and 1169 deletions

View File

@ -9,7 +9,7 @@ achievements.achievements = {}
achievements.registered_achievements = {} achievements.registered_achievements = {}
achievements.registered_achievements_list = {} achievements.registered_achievements_list = {}
local achievements_file = core.get_worldpath() .. "/achievements" local achievements_file = minetest.get_worldpath() .. "/achievements"
function achievements.register_achievement(name, def) function achievements.register_achievement(name, def)
local rd = { local rd = {
@ -28,7 +28,7 @@ end
local function save_achievements() local function save_achievements()
local f = io.open(achievements_file, "w") local f = io.open(achievements_file, "w")
f:write(core.serialize(achievements.achievements)) f:write(minetest.serialize(achievements.achievements))
io.close(f) io.close(f)
end end
@ -37,7 +37,7 @@ local function load_achievements()
local f = io.open(achievements_file, "r") local f = io.open(achievements_file, "r")
if f then if f then
achievements.achievements = core.deserialize(f:read("*all")) achievements.achievements = minetest.deserialize(f:read("*all"))
io.close(f) io.close(f)
else else
@ -69,8 +69,8 @@ function achievements.trigger_achievement(player, aname, times)
if achievements.achievements[name][aname] >= achievements.registered_achievements[aname].times then if achievements.achievements[name][aname] >= achievements.registered_achievements[aname].times then
achievements.achievements[name][aname] = -1 achievements.achievements[name][aname] = -1
core.after(2.0, function() minetest.after(2.0, function()
core.chat_send_all( minetest.chat_send_all(
core.colorize("#0f0", "*** " .. name .." has earned the achievement [" .. core.colorize("#0f0", "*** " .. name .." has earned the achievement [" ..
achievements.registered_achievements[aname].title .. "]")) achievements.registered_achievements[aname].title .. "]"))
end) end)
@ -101,7 +101,7 @@ local function on_craft(itemstack, player, craftgrid, craftinv)
else else
local group = string.match(def.craftitem, "group:(.*)") local group = string.match(def.craftitem, "group:(.*)")
if group and core.get_item_group(itemstack:get_name(), group) ~= 0 then if group and minetest.get_item_group(itemstack:get_name(), group) ~= 0 then
achievements.trigger_achievement(player, aname) achievements.trigger_achievement(player, aname)
end end
end end
@ -118,7 +118,7 @@ local function on_dig(pos, oldnode, player)
else else
local group = string.match(def.dignode, "group:(.*)") local group = string.match(def.dignode, "group:(.*)")
if group and core.get_item_group(oldnode.name, group) ~= 0 then if group and minetest.get_item_group(oldnode.name, group) ~= 0 then
achievements.trigger_achievement(player, aname) achievements.trigger_achievement(player, aname)
end end
end end
@ -134,7 +134,7 @@ local function on_place(pos, newnode, player, oldnode, itemstack, pointed_thing)
else else
local group = string.match(def.placenode, "group:(.*)") local group = string.match(def.placenode, "group:(.*)")
if group and core.get_item_group(newnode.name, group) ~= 0 then if group and minetest.get_item_group(newnode.name, group) ~= 0 then
achievements.trigger_achievement(player, aname) achievements.trigger_achievement(player, aname)
end end
end end
@ -144,13 +144,13 @@ end
-- Add callback functions -- Add callback functions
core.after(0, on_load) minetest.after(0, on_load)
core.register_on_newplayer(on_newplayer) minetest.register_on_newplayer(on_newplayer)
core.register_on_craft(on_craft) minetest.register_on_craft(on_craft)
core.register_on_dignode(on_dig) minetest.register_on_dignode(on_dig)
core.register_on_placenode(on_place) minetest.register_on_placenode(on_place)
-- Formspecs -- Formspecs
@ -187,8 +187,8 @@ function achievements.get_formspec(name, row)
achievement_list = achievement_list .. "," achievement_list = achievement_list .. ","
end end
achievement_list = achievement_list .. core.formspec_escape(def.title) .. "," achievement_list = achievement_list .. minetest.formspec_escape(def.title) .. ","
achievement_list = achievement_list .. core.formspec_escape(def.description) .. "," achievement_list = achievement_list .. minetest.formspec_escape(def.description) .. ","
achievement_list = achievement_list .. progress achievement_list = achievement_list .. progress
end end
@ -210,12 +210,12 @@ function achievements.get_formspec(name, row)
progress = "Missing" progress = "Missing"
end end
form = form .. "label[0.25,8.15;" .. core.formspec_escape(amt_gotten .. " of " .. #achievements.registered_achievements_list .. " achievements gotten, " .. amt_progress .. " in progress") .. "]" form = form .. "label[0.25,8.15;" .. minetest.formspec_escape(amt_gotten .. " of " .. #achievements.registered_achievements_list .. " achievements gotten, " .. amt_progress .. " in progress") .. "]"
form = form .. "label[0.25,0.25;" .. core.formspec_escape(def.title) .. "]" form = form .. "label[0.25,0.25;" .. minetest.formspec_escape(def.title) .. "]"
form = form .. "label[7.25,0.25;" .. core.formspec_escape(progress) .. "]" form = form .. "label[7.25,0.25;" .. minetest.formspec_escape(progress) .. "]"
form = form .. "label[0.5,0.75;" .. core.formspec_escape(def.description) .. "]" form = form .. "label[0.5,0.75;" .. minetest.formspec_escape(def.description) .. "]"
return form return form
end end
@ -230,17 +230,17 @@ local function receive_fields(player, form_name, fields)
local selected = 1 local selected = 1
if fields.achievement_list then if fields.achievement_list then
local selection = core.explode_table_event(fields.achievement_list) local selection = minetest.explode_table_event(fields.achievement_list)
if selection.type == "CHG" or selection.type == "DCL" then if selection.type == "CHG" or selection.type == "DCL" then
selected = selection.row selected = selection.row
end end
end end
core.show_formspec(name, "core_achievements", achievements.get_formspec(name, selected)) minetest.show_formspec(name, "core_achievements", achievements.get_formspec(name, selected))
end end
core.register_on_player_receive_fields(receive_fields) minetest.register_on_player_receive_fields(receive_fields)
-- --
-- Below are the default achievements -- Below are the default achievements

View File

@ -14,7 +14,7 @@ ambiance.sounds["birds"] = {
dist = 8, dist = 8,
nodename = "group:leaves", nodename = "group:leaves",
can_play = function(pos) can_play = function(pos)
local tod = (core.get_timeofday() or 1) * 2 local tod = (minetest.get_timeofday() or 1) * 2
if tod > 0.47 and tod < 1.53 then -- bit of overlap into crickets if tod > 0.47 and tod < 1.53 then -- bit of overlap into crickets
return true return true
@ -31,7 +31,7 @@ ambiance.sounds["crickets"] = {
dist = 8, dist = 8,
nodename = "group:grass", nodename = "group:grass",
can_play = function(pos) can_play = function(pos)
local tod = (core.get_timeofday() or 1) * 2 local tod = (minetest.get_timeofday() or 1) * 2
if tod < 0.5 or tod > 1.5 then if tod < 0.5 or tod > 1.5 then
return true return true
@ -49,13 +49,13 @@ ambiance.sounds["flowing_water"] = {
nodename = "group:flowing_water", nodename = "group:flowing_water",
} }
local ambiance_volume = tonumber(core.setting_get("ambiance_volume")) or 1.0 local ambiance_volume = tonumber(minetest.setting_get("ambiance_volume")) or 1.0
local soundspec = {} local soundspec = {}
local lastsound = {} local lastsound = {}
local function ambient_node_near(sound, pos) local function ambient_node_near(sound, pos)
local nodepos = core.find_node_near(pos, sound.dist, sound.nodename) local nodepos = minetest.find_node_near(pos, sound.dist, sound.nodename)
if nodepos ~= nil and math.random(1, sound.chance) == 1 then if nodepos ~= nil and math.random(1, sound.chance) == 1 then
return nodepos return nodepos
@ -67,12 +67,12 @@ end
local function step(dtime) local function step(dtime)
local player_positions = {} local player_positions = {}
for _, player in ipairs(core.get_connected_players()) do for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:getpos() local pos = player:getpos()
local name = player:get_player_name() local name = player:get_player_name()
for soundname, sound in pairs(ambiance.sounds) do for soundname, sound in pairs(ambiance.sounds) do
if not core.setting_getbool("ambiance_disable_" .. soundname) then if not minetest.setting_getbool("ambiance_disable_" .. soundname) then
if lastsound[name][soundname] then if lastsound[name][soundname] then
lastsound[name][soundname] = lastsound[name][soundname] + dtime lastsound[name][soundname] = lastsound[name][soundname] + dtime
else else
@ -88,7 +88,7 @@ local function step(dtime)
if sourcepos == nil then if sourcepos == nil then
if soundspec[name][soundname] then if soundspec[name][soundname] then
core.sound_stop(soundspec[name][soundname]) minetest.sound_stop(soundspec[name][soundname])
soundspec[name][soundname] = nil soundspec[name][soundname] = nil
lastsound[name][soundname] = 0 lastsound[name][soundname] = 0
@ -102,7 +102,7 @@ local function step(dtime)
end end
if ok then if ok then
soundspec[name][soundname] = core.sound_play( soundspec[name][soundname] = minetest.sound_play(
sound.file, sound.file,
{ {
pos = sourcepos, pos = sourcepos,
@ -135,8 +135,8 @@ local function on_leaveplayer(player)
lastsound[name] = nil lastsound[name] = nil
end end
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer) minetest.register_on_leaveplayer(on_leaveplayer)
core.register_globalstep(step) minetest.register_globalstep(step)
default.log("mod:ambiance", "loaded") default.log("mod:ambiance", "loaded")

View File

@ -21,12 +21,12 @@ armor.slots = {"helmet", "chestplate", "boots"}
local form_armor = default.ui.get_page("core_2part") local form_armor = default.ui.get_page("core_2part")
default.ui.register_page("core_armor", form_armor) default.ui.register_page("core_armor", form_armor)
local enable_drop = core.setting_getbool("drop_items_on_die") or false local enable_drop = minetest.setting_getbool("drop_items_on_die") or false
local armor_timer = 10 local armor_timer = 10
function armor.is_armor(itemname) function armor.is_armor(itemname)
local item = core.registered_items[itemname] local item = minetest.registered_items[itemname]
if item ~= nil and item.groups ~= nil then if item ~= nil and item.groups ~= nil then
if item.groups.is_armor then if item.groups.is_armor then
@ -45,7 +45,7 @@ function armor.is_slot(itemname, slot)
end end
function armor.get_base_skin(player) function armor.get_base_skin(player)
if core.get_modpath("player_skins") ~= nil then if minetest.get_modpath("player_skins") ~= nil then
return player_skins.get_skin(player:get_player_name()) return player_skins.get_skin(player:get_player_name())
else else
return armor.player_skin return armor.player_skin
@ -61,7 +61,7 @@ function armor.get_texture(player, base)
local itemstack = inv:get_stack("armor_"..slot, 1) local itemstack = inv:get_stack("armor_"..slot, 1)
local itemname = itemstack:get_name() local itemname = itemstack:get_name()
if armor.is_armor(itemname) and armor.is_slot(itemname, slot) then if armor.is_armor(itemname) and armor.is_slot(itemname, slot) then
local item = core.registered_items[itemname] local item = minetest.registered_items[itemname]
local mat = armor.materials[item.groups.armor_material][1] local mat = armor.materials[item.groups.armor_material][1]
image = image .. "^armor_" .. slot .. "_" .. mat ..".png" image = image .. "^armor_" .. slot .. "_" .. mat ..".png"
@ -86,7 +86,7 @@ function armor.get_groups(player)
local itemname = itemstack:get_name() local itemname = itemstack:get_name()
if armor.is_armor(itemname) then if armor.is_armor(itemname) then
local item = core.registered_items[itemname] local item = minetest.registered_items[itemname]
for mat_index, _ in ipairs(armor.materials) do for mat_index, _ in ipairs(armor.materials) do
local mat = armor.materials[mat_index][1] local mat = armor.materials[mat_index][1]
@ -157,7 +157,7 @@ local function on_die(player)
z = pos.z + math.random(-0.2, 0.2) z = pos.z + math.random(-0.2, 0.2)
} }
local drop = core.add_item(rpos, item) local drop = minetest.add_item(rpos, item)
if drop then if drop then
drop:setvelocity( drop:setvelocity(
@ -177,14 +177,14 @@ local function step(dtime)
armor_timer = armor_timer + dtime armor_timer = armor_timer + dtime
if armor_timer > armor.update_time then if armor_timer > armor.update_time then
for _, player in pairs(core.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
armor.update(player) armor.update(player)
end end
armor_timer = 0 armor_timer = 0
end end
end end
core.register_craftitem( minetest.register_craftitem(
"armor:chainmail_sheet", "armor:chainmail_sheet",
{ {
description = "Chainmail sheet", description = "Chainmail sheet",
@ -195,7 +195,7 @@ core.register_craftitem(
stack_max = 20, stack_max = 20,
}) })
core.register_craft( minetest.register_craft(
{ {
output = "armor:chainmail_sheet 3", output = "armor:chainmail_sheet 3",
recipe = { recipe = {
@ -213,7 +213,7 @@ for mat_index, _ in ipairs(armor.materials) do
-- print("Material " .. mat .. ": " .. armor_def) -- print("Material " .. mat .. ": " .. armor_def)
for _, slot in ipairs(armor.slots) do for _, slot in ipairs(armor.slots) do
core.register_craftitem( minetest.register_craftitem(
"armor:"..slot.."_"..mat, "armor:"..slot.."_"..mat,
{ {
description = def[4].." "..slot, description = def[4].." "..slot,
@ -233,7 +233,7 @@ for mat_index, _ in ipairs(armor.materials) do
local n = def[2] local n = def[2]
core.register_craft( minetest.register_craft(
{ {
output = "armor:helmet_"..mat, output = "armor:helmet_"..mat,
recipe = { recipe = {
@ -242,7 +242,7 @@ for mat_index, _ in ipairs(armor.materials) do
{"", "", ""}, {"", "", ""},
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "armor:chestplate_"..mat, output = "armor:chestplate_"..mat,
recipe = { recipe = {
@ -251,7 +251,7 @@ for mat_index, _ in ipairs(armor.materials) do
{n, n, n}, {n, n, n},
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "armor:boots_"..mat, output = "armor:boots_"..mat,
recipe = { recipe = {
@ -262,12 +262,12 @@ for mat_index, _ in ipairs(armor.materials) do
}) })
end end
core.register_on_newplayer(on_newplayer) minetest.register_on_newplayer(on_newplayer)
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
if enable_drop then if enable_drop then
core.register_on_dieplayer(on_die) minetest.register_on_dieplayer(on_die)
end end
core.register_globalstep(step) minetest.register_globalstep(step)
local form_armor = default.ui.get_page("core_2part") local form_armor = default.ui.get_page("core_2part")
form_armor = form_armor .. "list[current_player;main;0.25,4.75;8,4;]" form_armor = form_armor .. "list[current_player;main;0.25,4.75;8,4;]"

View File

@ -6,7 +6,7 @@
local players_in_bed = {} local players_in_bed = {}
core.register_node( minetest.register_node(
"bed:bed_foot", "bed:bed_foot",
{ {
description = "Bed", description = "Bed",
@ -29,34 +29,34 @@ core.register_node(
}, },
after_place_node = function(pos) after_place_node = function(pos)
local node = core.get_node(pos) local node = minetest.get_node(pos)
local dir = core.facedir_to_dir(node.param2) local dir = minetest.facedir_to_dir(node.param2)
local head_pos = vector.add(pos, dir) local head_pos = vector.add(pos, dir)
node.name = "bed:bed_head" node.name = "bed:bed_head"
if core.registered_nodes[core.get_node(head_pos).name].buildable_to then if minetest.registered_nodes[minetest.get_node(head_pos).name].buildable_to then
core.set_node(head_pos, node) minetest.set_node(head_pos, node)
else else
core.remove_node(pos) minetest.remove_node(pos)
end end
end, end,
on_destruct = function(pos) on_destruct = function(pos)
local node = core.get_node(pos) local node = minetest.get_node(pos)
local dir = core.facedir_to_dir(node.param2) local dir = minetest.facedir_to_dir(node.param2)
local head_pos = vector.add(pos, dir) local head_pos = vector.add(pos, dir)
if core.get_node(head_pos).name == "bed:bed_head" then if minetest.get_node(head_pos).name == "bed:bed_head" then
core.remove_node(head_pos) minetest.remove_node(head_pos)
end end
end, end,
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
if not clicker:is_player() or not core.setting_getbool("bed_enabled") then if not clicker:is_player() or not minetest.setting_getbool("bed_enabled") then
return return
end end
local name = clicker:get_player_name() local name = clicker:get_player_name()
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local put_pos = vector.add(pos, vector.divide(core.facedir_to_dir(node.param2), 2)) local put_pos = vector.add(pos, vector.divide(minetest.facedir_to_dir(node.param2), 2))
if clicker:get_player_name() == meta:get_string("player") then if clicker:get_player_name() == meta:get_string("player") then
put_pos.y = put_pos.y - 0.5 put_pos.y = put_pos.y - 0.5
@ -94,11 +94,11 @@ core.register_node(
end, end,
can_dig = function(pos) can_dig = function(pos)
return core.get_meta(pos):get_string("player") == "" return minetest.get_meta(pos):get_string("player") == ""
end end
}) })
core.register_node( minetest.register_node(
"bed:bed_head", "bed:bed_head",
{ {
drawtype = "nodebox", drawtype = "nodebox",
@ -114,9 +114,9 @@ core.register_node(
} }
}) })
core.register_alias("bed:bed", "bed:bed_foot") minetest.register_alias("bed:bed", "bed:bed_foot")
core.register_craft( minetest.register_craft(
{ {
output = "bed:bed", output = "bed:bed",
recipe = { recipe = {
@ -127,16 +127,16 @@ core.register_craft(
bed_player_spawns = {} bed_player_spawns = {}
local file = io.open(core.get_worldpath().."/bed.txt", "r") local file = io.open(minetest.get_worldpath().."/bed.txt", "r")
if file then if file then
bed_player_spawns = core.deserialize(file:read("*all")) bed_player_spawns = minetest.deserialize(file:read("*all"))
file:close() file:close()
end end
local timer = 0 local timer = 0
local wait = false local wait = false
core.register_globalstep( minetest.register_globalstep(
function(dtime) function(dtime)
if timer < 2 then if timer < 2 then
timer = timer + dtime timer = timer + dtime
@ -151,24 +151,24 @@ core.register_globalstep(
end end
end end
local players = #core.get_connected_players() local players = #minetest.get_connected_players()
if players > 0 and players * 0.5 < sleeping_players then if players > 0 and players * 0.5 < sleeping_players then
if core.get_timeofday() < 0.2 or core.get_timeofday() > 0.8 then if minetest.get_timeofday() < 0.2 or minetest.get_timeofday() > 0.8 then
if not wait then if not wait then
core.chat_send_all("[zzz] "..sleeping_players.." of "..players.." players slept, skipping to day.") minetest.chat_send_all("[zzz] "..sleeping_players.." of "..players.." players slept, skipping to day.")
wait = true wait = true
core.after(2, function() minetest.after(2, function()
core.set_timeofday(0.23) minetest.set_timeofday(0.23)
wait = false wait = false
end) end)
for _, player in ipairs(core.get_connected_players()) do for _, player in ipairs(minetest.get_connected_players()) do
bed_player_spawns[player:get_player_name()] = player:getpos() bed_player_spawns[player:get_player_name()] = player:getpos()
end end
local file = io.open(core.get_worldpath().."/bed.txt", "w") local file = io.open(minetest.get_worldpath().."/bed.txt", "w")
file:write(core.serialize(bed_player_spawns)) file:write(minetest.serialize(bed_player_spawns))
file:close() file:close()
end end
end end
@ -188,7 +188,7 @@ player_effects.register_effect(
} }
}) })
core.register_on_respawnplayer( minetest.register_on_respawnplayer(
function(player) function(player)
local name = player:get_player_name() local name = player:get_player_name()
if bed_player_spawns[name] then if bed_player_spawns[name] then
@ -196,7 +196,7 @@ core.register_on_respawnplayer(
end end
end) end)
core.register_on_leaveplayer( minetest.register_on_leaveplayer(
function(player) function(player)
players_in_bed[player:get_player_name()] = nil players_in_bed[player:get_player_name()] = nil
end) end)

View File

@ -4,7 +4,7 @@
-- By Kaadmy, for Pixture -- By Kaadmy, for Pixture
-- --
core.register_craftitem( minetest.register_craftitem(
":default:book", ":default:book",
{ {
description = "Book", description = "Book",
@ -12,7 +12,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
on_use = function(itemstack, player, pointed_thing) on_use = function(itemstack, player, pointed_thing)
local name = player:get_player_name() local name = player:get_player_name()
local data = core.deserialize(itemstack:get_metadata()) local data = minetest.deserialize(itemstack:get_metadata())
local title = "" local title = ""
local text = "" local text = ""
@ -23,26 +23,26 @@ core.register_craftitem(
end end
local form = default.ui.get_page("core_notabs") local form = default.ui.get_page("core_notabs")
form = form .. "field[0.5,1.25;8,0;title;Title:;"..core.formspec_escape(title).."]" form = form .. "field[0.5,1.25;8,0;title;Title:;"..minetest.formspec_escape(title).."]"
form = form .. "textarea[0.5,1.75;8,6.75;text;Contents:;"..core.formspec_escape(text).."]" form = form .. "textarea[0.5,1.75;8,6.75;text;Contents:;"..minetest.formspec_escape(text).."]"
form = form .. default.ui.button_exit(2.75, 7.75, 3, 1, "write", "Write") form = form .. default.ui.button_exit(2.75, 7.75, 3, 1, "write", "Write")
core.show_formspec(name, "book:book", form) minetest.show_formspec(name, "book:book", form)
end, end,
}) })
core.register_on_player_receive_fields( minetest.register_on_player_receive_fields(
function(player, form_name, fields) function(player, form_name, fields)
if form_name ~= "book:book" or not fields.write then return end if form_name ~= "book:book" or not fields.write then return end
local itemstack = player:get_wielded_item() local itemstack = player:get_wielded_item()
local data = core.deserialize(itemstack:get_metadata()) local data = minetest.deserialize(itemstack:get_metadata())
if not data then data = {} end if not data then data = {} end
data.text = fields.text data.text = fields.text
data.title = fields.title data.title = fields.title
itemstack:set_metadata(core.serialize(data)) itemstack:set_metadata(minetest.serialize(data))
player:set_wielded_item(itemstack) player:set_wielded_item(itemstack)
end) end)

View File

@ -4,7 +4,7 @@
-- Tweaked by Kaadmy, for Pixture -- Tweaked by Kaadmy, for Pixture
-- --
core.register_entity( minetest.register_entity(
":__builtin:item", ":__builtin:item",
{ {
initial_properties = { initial_properties = {
@ -39,9 +39,9 @@ core.register_entity(
local item_texture = nil local item_texture = nil
local item_type = "" local item_type = ""
if core.registered_items[itemname] then if minetest.registered_items[itemname] then
item_texture = core.registered_items[itemname].inventory_image item_texture = minetest.registered_items[itemname].inventory_image
item_type = core.registered_items[itemname].type item_type = minetest.registered_items[itemname].type
end end
local prop = { local prop = {
is_visible = true, is_visible = true,
@ -63,7 +63,7 @@ core.register_entity(
get_staticdata = function(self) get_staticdata = function(self)
--return self.itemstring --return self.itemstring
return core.serialize( return minetest.serialize(
{ {
itemstring = self.itemstring, itemstring = self.itemstring,
always_collect = self.always_collect, always_collect = self.always_collect,
@ -73,7 +73,7 @@ core.register_entity(
on_activate = function(self, staticdata, dtime_s) on_activate = function(self, staticdata, dtime_s)
if string.sub(staticdata, 1, string.len("return")) == "return" then if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = core.deserialize(staticdata) local data = minetest.deserialize(staticdata)
if data and type(data) == "table" then if data and type(data) == "table" then
self.itemstring = data.itemstring self.itemstring = data.itemstring
self.always_collect = data.always_collect self.always_collect = data.always_collect
@ -93,7 +93,7 @@ core.register_entity(
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
local time = tonumber(core.setting_get("remove_items")) local time = tonumber(minetest.setting_get("remove_items"))
if not time then time = 600 end if not time then time = 600 end
if not self.timer then self.timer = 0 end if not self.timer then self.timer = 0 end
@ -104,17 +104,17 @@ core.register_entity(
local p = self.object:getpos() local p = self.object:getpos()
local name = core.get_node(p).name local name = minetest.get_node(p).name
if core.registered_nodes[name].damage_per_second > 0 or name == "maptools:igniter" then if minetest.registered_nodes[name].damage_per_second > 0 or name == "maptools:igniter" then
core.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.45}) minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.45})
self.object:remove() self.object:remove()
return return
end end
p.y = p.y - 0.3 p.y = p.y - 0.3
local nn = core.get_node(p).name local nn = minetest.get_node(p).name
-- If node is not registered or node is walkably solid: -- If node is not registered or node is walkably solid:
if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable then if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
if self.physical_state then if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0}) self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0}) self.object:setacceleration({x=0, y=0, z=0})

View File

@ -21,7 +21,7 @@ function craftingguide.get_formspec(name)
form = form .. "label[0.41,1.74;"..user.itemno.."/"..#craftingguide.items[user.item].."]" -- itemno form = form .. "label[0.41,1.74;"..user.itemno.."/"..#craftingguide.items[user.item].."]" -- itemno
form = form .. "label[3.9,8.15;"..page.."/"..max_pages.."]" -- page form = form .. "label[3.9,8.15;"..page.."/"..max_pages.."]" -- page
form = form .. "label[4.4,2.5;"..core.formspec_escape(core.registered_items[user.item].description).."]" -- itemname form = form .. "label[4.4,2.5;"..minetest.formspec_escape(minetest.registered_items[user.item].description).."]" -- itemname
local method = craftingguide.items[user.item][user.itemno].type local method = craftingguide.items[user.item][user.itemno].type
if method == "normal" or method == "crafting" then if method == "normal" or method == "crafting" then
@ -129,7 +129,7 @@ local function receive_fields(player, form_name, fields)
craftingguide.users[name].page = page craftingguide.users[name].page = page
craftingguide.users[name].itemno = itemno craftingguide.users[name].itemno = itemno
core.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name)) minetest.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
end end
end end
@ -146,8 +146,8 @@ local function on_leaveplayer(player)
end end
local function load_recipes() local function load_recipes()
for itemname, itemdef in pairs(core.registered_items) do for itemname, itemdef in pairs(minetest.registered_items) do
local recipes = core.get_all_craft_recipes(itemname) local recipes = minetest.get_all_craft_recipes(itemname)
if recipes ~= nil and itemname ~= "" then if recipes ~= nil and itemname ~= "" then
-- print(dump(recipes)) -- print(dump(recipes))
@ -161,11 +161,11 @@ local function load_recipes()
print("Got "..#craftingguide.itemlist.." craftable items") print("Got "..#craftingguide.itemlist.." craftable items")
end end
core.after(0, load_recipes) minetest.after(0, load_recipes)
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer) minetest.register_on_leaveplayer(on_leaveplayer)
core.register_on_player_receive_fields(receive_fields) minetest.register_on_player_receive_fields(receive_fields)
local form_craftingguide = default.ui.get_page("core") local form_craftingguide = default.ui.get_page("core")
form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(0.25, 4, 8, 4) form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(0.25, 4, 8, 4)
@ -176,7 +176,7 @@ form_craftingguide = form_craftingguide .. default.ui.image_button(0.25, 0.5, 1,
form_craftingguide = form_craftingguide .. default.ui.image_button(0.25, 2.5, 1, 1, "guide_prev_recipe", "ui_arrow_bg.png^[transformFY") form_craftingguide = form_craftingguide .. default.ui.image_button(0.25, 2.5, 1, 1, "guide_prev_recipe", "ui_arrow_bg.png^[transformFY")
form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(1.25, 0.5, 3, 3) form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(1.25, 0.5, 3, 3)
form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(6.25, 1.5, 1, 1) form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(6.25, 1.5, 1, 1)
form_craftingguide = form_craftingguide .. "image[5.25,1.5;1,1;"..core.formspec_escape("ui_arrow.png^[transformR270").."]" form_craftingguide = form_craftingguide .. "image[5.25,1.5;1,1;"..minetest.formspec_escape("ui_arrow.png^[transformR270").."]"
default.ui.register_page("core_craftingguide", form_craftingguide) default.ui.register_page("core_craftingguide", form_craftingguide)

View File

@ -3,7 +3,7 @@
-- --
-- Pickaxes -- Pickaxes
core.register_craft( minetest.register_craft(
{ {
output = "default:pick_wood", output = "default:pick_wood",
recipe = { recipe = {
@ -13,7 +13,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:pick_stone", output = "default:pick_stone",
recipe = { recipe = {
@ -23,7 +23,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:pick_steel", output = "default:pick_steel",
recipe = { recipe = {
@ -33,7 +33,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:pick_carbonsteel", output = "default:pick_carbonsteel",
recipe = { recipe = {
@ -45,7 +45,7 @@ core.register_craft(
-- Shovels -- Shovels
core.register_craft( minetest.register_craft(
{ {
output = "default:shovel_wood", output = "default:shovel_wood",
recipe = { recipe = {
@ -55,7 +55,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
@ -67,7 +67,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:shovel_steel", output = "default:shovel_steel",
recipe = { recipe = {
@ -77,7 +77,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:shovel_carbonsteel", output = "default:shovel_carbonsteel",
recipe = { recipe = {
@ -89,7 +89,7 @@ core.register_craft(
-- Axes -- Axes
core.register_craft( minetest.register_craft(
{ {
output = "default:axe_wood", output = "default:axe_wood",
recipe = { recipe = {
@ -99,7 +99,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:axe_stone", output = "default:axe_stone",
recipe = { recipe = {
@ -109,7 +109,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:axe_steel", output = "default:axe_steel",
recipe = { recipe = {
@ -119,7 +119,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:axe_carbonsteel", output = "default:axe_carbonsteel",
recipe = { recipe = {
@ -131,7 +131,7 @@ core.register_craft(
-- Spears -- Spears
core.register_craft( minetest.register_craft(
{ {
output = "default:spear_wood", output = "default:spear_wood",
recipe = { recipe = {
@ -141,7 +141,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:spear_stone", output = "default:spear_stone",
recipe = { recipe = {
@ -151,7 +151,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:spear_steel", output = "default:spear_steel",
recipe = { recipe = {
@ -161,7 +161,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:spear_carbonsteel", output = "default:spear_carbonsteel",
recipe = { recipe = {
@ -171,7 +171,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:shears", output = "default:shears",
recipe = { recipe = {
@ -182,7 +182,7 @@ core.register_craft(
-- Broadsword -- Broadsword
core.register_craft( minetest.register_craft(
{ {
output = "default:broadsword", output = "default:broadsword",
recipe = { recipe = {
@ -195,14 +195,14 @@ core.register_craft(
-- Nodes/Items -- Nodes/Items
core.register_craft( minetest.register_craft(
{ {
output = "default:dust_carbonsteel", output = "default:dust_carbonsteel",
type = "shapeless", type = "shapeless",
recipe = {"default:lump_coal", "default:lump_iron", "default:lump_iron"} recipe = {"default:lump_coal", "default:lump_iron", "default:lump_iron"}
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:rope", output = "default:rope",
recipe = { recipe = {
@ -212,7 +212,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:fiber", output = "default:fiber",
type = "shapeless", type = "shapeless",
@ -221,7 +221,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:fiber 3", output = "default:fiber 3",
type = "shapeless", type = "shapeless",
@ -230,7 +230,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:gravel", output = "default:gravel",
recipe = { recipe = {
@ -238,7 +238,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:bucket", output = "default:bucket",
recipe = { recipe = {
@ -248,7 +248,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:brick", output = "default:brick",
recipe = { recipe = {
@ -257,7 +257,7 @@ core.register_craft(
{"group:soil", "default:gravel", "group:soil"}, {"group:soil", "default:gravel", "group:soil"},
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:block_steel", output = "default:block_steel",
recipe = { recipe = {
@ -267,7 +267,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:block_coal", output = "default:block_coal",
recipe = { recipe = {
@ -277,7 +277,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:dirt_path 8", output = "default:dirt_path 8",
recipe = { recipe = {
@ -287,7 +287,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:path_slab 3", output = "default:path_slab 3",
recipe = { recipe = {
@ -295,7 +295,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:heated_dirt_path", output = "default:heated_dirt_path",
recipe = { recipe = {
@ -304,7 +304,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:planks 4", output = "default:planks 4",
recipe = { recipe = {
@ -312,7 +312,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:planks_oak 4", output = "default:planks_oak 4",
recipe = { recipe = {
@ -320,7 +320,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:planks_birch 4", output = "default:planks_birch 4",
recipe = { recipe = {
@ -328,7 +328,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:frame", output = "default:frame",
recipe = { recipe = {
@ -338,7 +338,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:reinforced_frame", output = "default:reinforced_frame",
recipe = { recipe = {
@ -348,7 +348,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:stick 4", output = "default:stick 4",
recipe = { recipe = {
@ -356,7 +356,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:fence 4", output = "default:fence 4",
recipe = { recipe = {
@ -366,7 +366,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:fence_oak 4", output = "default:fence_oak 4",
recipe = { recipe = {
@ -376,7 +376,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:fence_birch 4", output = "default:fence_birch 4",
recipe = { recipe = {
@ -386,7 +386,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:sign 2", output = "default:sign 2",
recipe = { recipe = {
@ -396,7 +396,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:reinforced_cobble", output = "default:reinforced_cobble",
recipe = { recipe = {
@ -406,7 +406,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:torch 2", output = "default:torch 2",
recipe = { recipe = {
@ -416,7 +416,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:torch_weak 2", output = "default:torch_weak 2",
recipe = { recipe = {
@ -425,14 +425,14 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:flint 2", output = "default:flint 2",
type = "shapeless", type = "shapeless",
recipe = {"default:gravel"}, recipe = {"default:gravel"},
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:flint_and_steel", output = "default:flint_and_steel",
recipe = { recipe = {
@ -441,7 +441,7 @@ core.register_craft(
}, },
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:chest", output = "default:chest",
recipe = { recipe = {
@ -451,7 +451,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:chest_locked", output = "default:chest_locked",
recipe = { recipe = {
@ -461,7 +461,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:furnace", output = "default:furnace",
recipe = { recipe = {
@ -471,7 +471,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:sandstone 2", output = "default:sandstone 2",
recipe = { recipe = {
@ -480,21 +480,21 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:sandstone 2", output = "default:sandstone 2",
type = "shapeless", type = "shapeless",
recipe = {"default:compressed_sandstone"}, recipe = {"default:compressed_sandstone"},
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:compressed_sandstone", output = "default:compressed_sandstone",
type = "shapeless", type = "shapeless",
recipe = {"default:sandstone", "default:sandstone"}, recipe = {"default:sandstone", "default:sandstone"},
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:paper", output = "default:paper",
recipe = { recipe = {
@ -502,7 +502,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:book", output = "default:book",
recipe = { recipe = {
@ -512,7 +512,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:bookshelf", output = "default:bookshelf",
recipe = { recipe = {
@ -522,7 +522,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:ladder 2", output = "default:ladder 2",
recipe = { recipe = {
@ -532,7 +532,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "default:fertilizer 3", output = "default:fertilizer 3",
recipe = { recipe = {
@ -545,7 +545,7 @@ core.register_craft(
-- --
-- Tool repair -- Tool repair
-- --
core.register_craft( minetest.register_craft(
{ {
type = "toolrepair", type = "toolrepair",
additional_wear = -0.1, additional_wear = -0.1,
@ -555,7 +555,7 @@ core.register_craft(
-- Cooking -- Cooking
-- --
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:torch_weak", output = "default:torch_weak",
@ -563,7 +563,7 @@ core.register_craft(
cooktime = 1, cooktime = 1,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:torch", output = "default:torch",
@ -571,7 +571,7 @@ core.register_craft(
cooktime = 4, cooktime = 4,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:glass", output = "default:glass",
@ -579,7 +579,7 @@ core.register_craft(
cooktime = 3, cooktime = 3,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:lump_coal", output = "default:lump_coal",
@ -587,7 +587,7 @@ core.register_craft(
cooktime = 4, cooktime = 4,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:lump_coal", output = "default:lump_coal",
@ -595,7 +595,7 @@ core.register_craft(
cooktime = 5, cooktime = 5,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:lump_coal", output = "default:lump_coal",
@ -603,7 +603,7 @@ core.register_craft(
cooktime = 5, cooktime = 5,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:stone", output = "default:stone",
@ -611,7 +611,7 @@ core.register_craft(
cooktime = 6, cooktime = 6,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:ingot_steel", output = "default:ingot_steel",
@ -619,7 +619,7 @@ core.register_craft(
cooktime = 3, cooktime = 3,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:ingot_carbonsteel", output = "default:ingot_carbonsteel",
@ -627,7 +627,7 @@ core.register_craft(
cooktime = 5, cooktime = 5,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "default:lump_sugar", output = "default:lump_sugar",
@ -639,182 +639,182 @@ core.register_craft(
-- Fuels -- Fuels
-- --
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "group:leaves", recipe = "group:leaves",
burntime = 1, burntime = 1,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:dry_grass", recipe = "default:dry_grass",
burntime = 1, burntime = 1,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:fern", recipe = "default:fern",
burntime = 2, burntime = 2,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:papyrus", recipe = "default:papyrus",
burntime = 2, burntime = 2,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:apple", recipe = "default:apple",
burntime = 3, burntime = 3,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:ladder", recipe = "default:ladder",
burntime = 5, burntime = 5,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:rope", recipe = "default:rope",
burntime = 5, burntime = 5,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "group:planks", recipe = "group:planks",
burntime = 5, burntime = 5,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:torch", recipe = "default:torch",
burntime = 5, burntime = 5,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "group:sapling", recipe = "group:sapling",
burntime = 7, burntime = 7,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:fertilizer", recipe = "default:fertilizer",
burntime = 8, burntime = 8,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "group:planks", recipe = "group:planks",
burntime = 9, burntime = 9,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:sign", recipe = "default:sign",
burntime = 10, burntime = 10,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:cactus", recipe = "default:cactus",
burntime = 10, burntime = 10,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:fence", recipe = "default:fence",
burntime = 10, burntime = 10,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:fence_oak", recipe = "default:fence_oak",
burntime = 11, burntime = 11,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:fence_birch", recipe = "default:fence_birch",
burntime = 11, burntime = 11,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:planks_oak", recipe = "default:planks_oak",
burntime = 12, burntime = 12,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:planks_birch", recipe = "default:planks_birch",
burntime = 12, burntime = 12,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:frame", recipe = "default:frame",
burntime = 12, burntime = 12,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:reinforced_frame", recipe = "default:reinforced_frame",
burntime = 17, burntime = 17,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "group:tree", recipe = "group:tree",
burntime = 20, burntime = 20,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:chest", recipe = "default:chest",
burntime = 24, burntime = 24,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:bookshelf", recipe = "default:bookshelf",
burntime = 30, burntime = 30,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:lump_coal", recipe = "default:lump_coal",
burntime = 30, burntime = 30,
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "default:block_coal", recipe = "default:block_coal",

View File

@ -2,14 +2,14 @@
-- Crafting items -- Crafting items
-- --
core.register_craftitem( minetest.register_craftitem(
"default:fiber", "default:fiber",
{ {
description = "Fiber", description = "Fiber",
inventory_image = "default_fiber.png", inventory_image = "default_fiber.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:stick", "default:stick",
{ {
description = "Stick", description = "Stick",
@ -17,14 +17,14 @@ core.register_craftitem(
groups = {stick = 1} groups = {stick = 1}
}) })
core.register_craftitem( minetest.register_craftitem(
"default:paper", "default:paper",
{ {
description = "Paper", description = "Paper",
inventory_image = "default_paper.png", inventory_image = "default_paper.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:book", "default:book",
{ {
description = "Book", description = "Book",
@ -33,64 +33,64 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"default:lump_coal", "default:lump_coal",
{ {
description = "Coal Lump", description = "Coal Lump",
inventory_image = "default_lump_coal.png", inventory_image = "default_lump_coal.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:lump_iron", "default:lump_iron",
{ {
description = "Iron Lump", description = "Iron Lump",
inventory_image = "default_lump_iron.png", inventory_image = "default_lump_iron.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:dust_carbonsteel", "default:dust_carbonsteel",
{ {
description = "Carbon Steel Dust", description = "Carbon Steel Dust",
inventory_image = "default_dust_carbonsteel.png", inventory_image = "default_dust_carbonsteel.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:ingot_steel", "default:ingot_steel",
{ {
description = "Steel Ingot", description = "Steel Ingot",
inventory_image = "default_ingot_steel.png", inventory_image = "default_ingot_steel.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:ingot_carbonsteel", "default:ingot_carbonsteel",
{ {
description = "Carbon Steel Ingot", description = "Carbon Steel Ingot",
inventory_image = "default_ingot_carbonsteel.png", inventory_image = "default_ingot_carbonsteel.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:lump_sugar", "default:lump_sugar",
{ {
description = "Sugar Lump", description = "Sugar Lump",
inventory_image = "default_lump_sugar.png", inventory_image = "default_lump_sugar.png",
on_use = core.item_eat({hp = 1, sat = 10}) on_use = minetest.item_eat({hp = 1, sat = 10})
}) })
core.register_craftitem( minetest.register_craftitem(
"default:pearl", "default:pearl",
{ {
description = "Pearl", description = "Pearl",
inventory_image = "default_pearl.png", inventory_image = "default_pearl.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:flint", "default:flint",
{ {
description = "Flint Shard", description = "Flint Shard",
inventory_image = "default_flint.png", inventory_image = "default_flint.png",
}) })
core.register_craftitem( minetest.register_craftitem(
"default:bucket_water", "default:bucket_water",
{ {
description = "Water Bucket", description = "Water Bucket",
@ -101,8 +101,8 @@ core.register_craftitem(
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local pos_protected = core.get_pointed_thing_position(pointed_thing, true) local pos_protected = minetest.get_pointed_thing_position(pointed_thing, true)
if core.is_protected(pos_protected, user) then return end if minetest.is_protected(pos_protected, user) then return end
itemstack:take_item() itemstack:take_item()
@ -113,20 +113,20 @@ core.register_craftitem(
else else
local pos = user:getpos() local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5) pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, "default:bucket") minetest.add_item(pos, "default:bucket")
end end
local pos = pointed_thing.above local pos = pointed_thing.above
if core.registered_nodes[core.get_node(pointed_thing.under).name].buildable_to then if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under pos=pointed_thing.under
end end
core.add_node(pos, {name = "default:water_source"}) minetest.add_node(pos, {name = "default:water_source"})
return itemstack return itemstack
end end
}) })
core.register_craftitem( minetest.register_craftitem(
"default:bucket_river_water", "default:bucket_river_water",
{ {
description = "River Water Bucket", description = "River Water Bucket",
@ -137,8 +137,8 @@ core.register_craftitem(
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local pos_protected = core.get_pointed_thing_position(pointed_thing, true) local pos_protected = minetest.get_pointed_thing_position(pointed_thing, true)
if core.is_protected(pos_protected, user) then return end if minetest.is_protected(pos_protected, user) then return end
itemstack:take_item() itemstack:take_item()
@ -149,20 +149,20 @@ core.register_craftitem(
else else
local pos = user:getpos() local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5) pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, "default:bucket") minetest.add_item(pos, "default:bucket")
end end
local pos = pointed_thing.above local pos = pointed_thing.above
if core.registered_nodes[core.get_node(pointed_thing.under).name].buildable_to then if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under pos=pointed_thing.under
end end
core.add_node(pos, {name = "default:river_water_source"}) minetest.add_node(pos, {name = "default:river_water_source"})
return itemstack return itemstack
end end
}) })
core.register_craftitem( minetest.register_craftitem(
"default:bucket_swamp_water", "default:bucket_swamp_water",
{ {
description = "Swamp Water Bucket", description = "Swamp Water Bucket",
@ -173,8 +173,8 @@ core.register_craftitem(
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local pos_protected = core.get_pointed_thing_position(pointed_thing, true) local pos_protected = minetest.get_pointed_thing_position(pointed_thing, true)
if core.is_protected(pos_protected, user) then return end if minetest.is_protected(pos_protected, user) then return end
itemstack:take_item() itemstack:take_item()
@ -185,20 +185,20 @@ core.register_craftitem(
else else
local pos = user:getpos() local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5) pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, "default:bucket") minetest.add_item(pos, "default:bucket")
end end
local pos = pointed_thing.above local pos = pointed_thing.above
if core.registered_nodes[core.get_node(pointed_thing.under).name].buildable_to then if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under pos=pointed_thing.under
end end
core.add_node(pos, {name = "default:swamp_water_source"}) minetest.add_node(pos, {name = "default:swamp_water_source"})
return itemstack return itemstack
end end
}) })
core.register_craftitem( minetest.register_craftitem(
"default:bucket", "default:bucket",
{ {
description = "Empty Bucket", description = "Empty Bucket",
@ -209,7 +209,7 @@ core.register_craftitem(
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local nodename=core.get_node(pointed_thing.under).name local nodename=minetest.get_node(pointed_thing.under).name
if nodename == "default:water_source" then if nodename == "default:water_source" then
itemstack:take_item() itemstack:take_item()
@ -221,10 +221,10 @@ core.register_craftitem(
else else
local pos = user:getpos() local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5) pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, "default:bucket_water") minetest.add_item(pos, "default:bucket_water")
end end
core.remove_node(pointed_thing.under) minetest.remove_node(pointed_thing.under)
elseif nodename == "default:river_water_source" then elseif nodename == "default:river_water_source" then
itemstack:take_item() itemstack:take_item()
@ -235,10 +235,10 @@ core.register_craftitem(
else else
local pos = user:getpos() local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5) pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, "default:bucket_river_water") minetest.add_item(pos, "default:bucket_river_water")
end end
core.remove_node(pointed_thing.under) minetest.remove_node(pointed_thing.under)
elseif nodename == "default:swamp_water_source" then elseif nodename == "default:swamp_water_source" then
itemstack:take_item() itemstack:take_item()
@ -249,10 +249,10 @@ core.register_craftitem(
else else
local pos = user:getpos() local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5) pos.y = math.floor(pos.y + 0.5)
core.add_item(pos, "default:bucket_swamp_water") minetest.add_item(pos, "default:bucket_swamp_water")
end end
core.remove_node(pointed_thing.under) minetest.remove_node(pointed_thing.under)
end end
return itemstack return itemstack
@ -261,7 +261,7 @@ core.register_craftitem(
}) })
core.register_craftitem( minetest.register_craftitem(
"default:fertilizer", "default:fertilizer",
{ {
description = "Fertilizer", description = "Fertilizer",
@ -270,15 +270,15 @@ core.register_craftitem(
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
local pos = pointed_thing.above local pos = pointed_thing.above
local underdef = core.registered_nodes[core.get_node(pointed_thing.under).name] local underdef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
if underdef.groups then if underdef.groups then
if underdef.groups.plantable_soil then if underdef.groups.plantable_soil then
core.remove_node(pos) minetest.remove_node(pos)
core.set_node(pointed_thing.under, {name = "default:fertilized_dirt"}) minetest.set_node(pointed_thing.under, {name = "default:fertilized_dirt"})
elseif underdef.groups.plantable_sandy then elseif underdef.groups.plantable_sandy then
core.remove_node(pos) minetest.remove_node(pos)
core.set_node(pointed_thing.under, {name = "default:fertilized_sand"}) minetest.set_node(pointed_thing.under, {name = "default:fertilized_sand"})
end end
end end

View File

@ -26,7 +26,7 @@ function default.ui.get_hotbar_itemslot_bg(x, y, w, h)
end end
function default.ui.image_button(x, y, w, h, name, image) function default.ui.image_button(x, y, w, h, name, image)
local image = core.formspec_escape(image) local image = minetest.formspec_escape(image)
return "image_button["..x..","..y..";"..w..","..h..";"..image..";"..name..";;;false;"..image.."]" return "image_button["..x..","..y..";"..w..","..h..";"..image..";"..name..";;;false;"..image.."]"
end end
@ -64,17 +64,17 @@ function default.ui.tab(x, y, name, icon, tooltip)
local shifted_icon = "[combine:16x16:0,0=ui_tab_active.png:0,1="..icon local shifted_icon = "[combine:16x16:0,0=ui_tab_active.png:0,1="..icon
local form = "" local form = ""
form = form .. "image_button["..x..","..y..";1,1;ui_tab_inactive.png^"..icon..";"..name..";;true;false;"..core.formspec_escape(shifted_icon).."]" form = form .. "image_button["..x..","..y..";1,1;ui_tab_inactive.png^"..icon..";"..name..";;true;false;"..minetest.formspec_escape(shifted_icon).."]"
form = form .. "tooltip["..name..";"..tooltip.."]" form = form .. "tooltip["..name..";"..tooltip.."]"
return form return form
end end
local function get_itemdef_field(itemname, fieldname) local function get_itemdef_field(itemname, fieldname)
if not core.registered_items[itemname] then if not minetest.registered_items[itemname] then
return nil return nil
end end
return core.registered_items[itemname][fieldname] return minetest.registered_items[itemname][fieldname]
end end
function default.ui.fake_itemstack(x, y, itemstack, name) function default.ui.fake_itemstack(x, y, itemstack, name)
@ -84,8 +84,8 @@ function default.ui.fake_itemstack(x, y, itemstack, name)
local itemamt = itemstack:get_count() local itemamt = itemstack:get_count()
local itemdesc = "" local itemdesc = ""
if core.registered_items[itemname] and core.registered_items[itemname].description ~= nil then if minetest.registered_items[itemname] and minetest.registered_items[itemname].description ~= nil then
itemdesc = core.registered_items[itemname].description itemdesc = minetest.registered_items[itemname].description
end end
if itemamt <= 1 then itemamt = "" end if itemamt <= 1 then itemamt = "" end
@ -94,7 +94,7 @@ function default.ui.fake_itemstack(x, y, itemstack, name)
if itemname ~= "" then if itemname ~= "" then
-- result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]" -- result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]"
result = result .. "image_button["..x..","..y..";1,1;ui_null.png;"..name..";;false;false;ui_null.png]" result = result .. "image_button["..x..","..y..";1,1;ui_null.png;"..name..";;false;false;ui_null.png]"
result = result .. "item_image["..x..","..y..";1,1;"..core.formspec_escape(itemname).."]" result = result .. "item_image["..x..","..y..";1,1;"..minetest.formspec_escape(itemname).."]"
result = result .. "label["..(x+0.6)..","..(y+0.5)..";"..itemamt.."]" result = result .. "label["..(x+0.6)..","..(y+0.5)..";"..itemamt.."]"
result = result .. "tooltip["..name..";"..itemdesc.."]" result = result .. "tooltip["..name..";"..itemdesc.."]"
end end
@ -106,15 +106,15 @@ function default.ui.fake_simple_itemstack(x, y, itemname, name)
local name = name or "fake_simple_itemstack" local name = name or "fake_simple_itemstack"
local itemdesc = "" local itemdesc = ""
if core.registered_items[itemname] and core.registered_items[itemname].description ~= nil then if minetest.registered_items[itemname] and minetest.registered_items[itemname].description ~= nil then
itemdesc = core.registered_items[itemname].description itemdesc = minetest.registered_items[itemname].description
end end
local result = "" local result = ""
if itemname ~= "" then if itemname ~= "" then
-- result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]" -- result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]"
result = result .. "image_button["..x..","..y..";1,1;ui_null.png;"..name..";;false;false;ui_null.png]" result = result .. "image_button["..x..","..y..";1,1;ui_null.png;"..name..";;false;false;ui_null.png]"
result = result .. "item_image["..x..","..y..";1,1;"..core.formspec_escape(itemname).."]" result = result .. "item_image["..x..","..y..";1,1;"..minetest.formspec_escape(itemname).."]"
result = result .. "tooltip["..name..";"..itemdesc.."]" result = result .. "tooltip["..name..";"..itemdesc.."]"
end end
@ -126,22 +126,22 @@ function default.ui.item_group(x, y, group, name)
local itemname = "" local itemname = ""
for itemn, itemdef in pairs(core.registered_items) do for itemn, itemdef in pairs(minetest.registered_items) do
if core.get_item_group(itemn, group) ~= 0 and core.get_item_group(itemn, "not_in_craftingguide") ~= 1 then if minetest.get_item_group(itemn, group) ~= 0 and minetest.get_item_group(itemn, "not_in_craftingguide") ~= 1 then
itemname = itemn itemname = itemn
end end
end end
local itemdesc = "" local itemdesc = ""
if core.registered_items[itemname] and core.registered_items[itemname].description ~= nil then if minetest.registered_items[itemname] and minetest.registered_items[itemname].description ~= nil then
itemdesc = core.registered_items[itemname].description itemdesc = minetest.registered_items[itemname].description
end end
local result = "" local result = ""
if itemname ~= "" then if itemname ~= "" then
-- result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]" -- result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]"
result = result .. "image_button["..x..","..y..";1,1;ui_null.png;"..name..";G;false;false;ui_null.png]" result = result .. "image_button["..x..","..y..";1,1;ui_null.png;"..name..";G;false;false;ui_null.png]"
result = result .. "item_image["..x..","..y..";1,1;"..core.formspec_escape(itemname).."]" result = result .. "item_image["..x..","..y..";1,1;"..minetest.formspec_escape(itemname).."]"
result = result .. "tooltip["..name..";Group: "..group.."]" result = result .. "tooltip["..name..";Group: "..group.."]"
end end
@ -171,16 +171,16 @@ form_core = form_core .. "size[8.5,9]"
form_core = form_core .. default.ui.core.colors form_core = form_core .. default.ui.core.colors
form_core = form_core .. default.ui.core.bg form_core = form_core .. default.ui.core.bg
form_core = form_core .. default.ui.tab(-0.9, 0.5, "tab_crafting", "ui_icon_crafting.png", "Crafting") form_core = form_core .. default.ui.tab(-0.9, 0.5, "tab_crafting", "ui_icon_crafting.png", "Crafting")
if core.get_modpath("craftingguide") ~= nil then if minetest.get_modpath("craftingguide") ~= nil then
form_core = form_core .. default.ui.tab(-0.9, 1.28, "tab_craftingguide", "ui_icon_craftingguide.png", "Crafting Guide") form_core = form_core .. default.ui.tab(-0.9, 1.28, "tab_craftingguide", "ui_icon_craftingguide.png", "Crafting Guide")
end end
if core.get_modpath("armor") ~= nil then if minetest.get_modpath("armor") ~= nil then
form_core = form_core .. default.ui.tab(-0.9, 2.06, "tab_armor", "ui_icon_armor.png", "Armor") form_core = form_core .. default.ui.tab(-0.9, 2.06, "tab_armor", "ui_icon_armor.png", "Armor")
end end
if core.get_modpath("achievements") ~= nil then if minetest.get_modpath("achievements") ~= nil then
form_core = form_core .. default.ui.tab(-0.9, 2.84, "tab_achievements", "ui_icon_achievements.png", "Achievements") form_core = form_core .. default.ui.tab(-0.9, 2.84, "tab_achievements", "ui_icon_achievements.png", "Achievements")
end end
if core.get_modpath("player_skins") ~= nil then if minetest.get_modpath("player_skins") ~= nil then
form_core = form_core .. default.ui.tab(-0.9, 3.62, "tab_player_skins", "ui_icon_player_skins.png", "Player Skins") form_core = form_core .. default.ui.tab(-0.9, 3.62, "tab_player_skins", "ui_icon_player_skins.png", "Player Skins")
end end
form_core = form_core .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]" form_core = form_core .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]"
@ -237,29 +237,29 @@ function default.ui.receive_fields(player, form_name, fields)
-- print("Received formspec fields from '"..name.."': "..dump(fields)) -- print("Received formspec fields from '"..name.."': "..dump(fields))
if fields.tab_crafting then if fields.tab_crafting then
core.show_formspec(name, "core_crafting", default.ui.get_page("core_crafting")) minetest.show_formspec(name, "core_crafting", default.ui.get_page("core_crafting"))
elseif core.get_modpath("craftingguide") ~= nil and fields.tab_craftingguide then elseif minetest.get_modpath("craftingguide") ~= nil and fields.tab_craftingguide then
core.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name)) minetest.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
elseif core.get_modpath("armor") ~= nil and fields.tab_armor then elseif minetest.get_modpath("armor") ~= nil and fields.tab_armor then
core.show_formspec(name, "core_armor", default.ui.get_page("core_armor")) minetest.show_formspec(name, "core_armor", default.ui.get_page("core_armor"))
elseif core.get_modpath("achievements") ~= nil and fields.tab_achievements then elseif minetest.get_modpath("achievements") ~= nil and fields.tab_achievements then
core.show_formspec(name, "core_achievements", achievements.get_formspec(name)) minetest.show_formspec(name, "core_achievements", achievements.get_formspec(name))
elseif core.get_modpath("player_skins") ~= nil and fields.tab_player_skins then elseif minetest.get_modpath("player_skins") ~= nil and fields.tab_player_skins then
core.show_formspec(name, "core_player_skins", player_skins.get_formspec(name)) minetest.show_formspec(name, "core_player_skins", player_skins.get_formspec(name))
end end
end end
core.register_on_player_receive_fields( minetest.register_on_player_receive_fields(
function(player, form_name, fields) function(player, form_name, fields)
default.ui.receive_fields(player, form_name, fields) default.ui.receive_fields(player, form_name, fields)
end) end)
core.register_on_joinplayer( minetest.register_on_joinplayer(
function(player) function(player)
local function welcome() local function welcome()
core.chat_send_player(player:get_player_name(), core.colorize("#0f0", "Welcome to Pixture! Type /help for a list of commands.")) minetest.chat_send_player(player:get_player_name(), core.colorize("#0f0", "Welcome to Pixture! Type /help for a list of commands."))
end end
core.after(1.0, welcome) minetest.after(1.0, welcome)
player:set_inventory_formspec(default.ui.get_page("core_crafting")) player:set_inventory_formspec(default.ui.get_page("core_crafting"))
end) end)

View File

@ -5,11 +5,11 @@
-- Chest naming via signs -- Chest naming via signs
function default.write_name(pos, text) function default.write_name(pos, text)
-- check above, if allowed -- check above, if allowed
if core.setting_getbool("signs_allow_name_above") then if minetest.setting_getbool("signs_allow_name_above") then
local above = {x = pos.x, y = pos.y + 1, z = pos.z} local above = {x = pos.x, y = pos.y + 1, z = pos.z}
local abovedef = nil local abovedef = nil
if core.registered_nodes[core.get_node(above).name] then if minetest.registered_nodes[minetest.get_node(above).name] then
abovedef = core.registered_nodes[core.get_node(above).name] abovedef = minetest.registered_nodes[minetest.get_node(above).name]
end end
if abovedef and abovedef.write_name ~= nil then if abovedef and abovedef.write_name ~= nil then
abovedef.write_name(above, text) abovedef.write_name(above, text)
@ -19,8 +19,8 @@ function default.write_name(pos, text)
-- then below -- then below
local below = {x = pos.x, y = pos.y - 1, z = pos.z} local below = {x = pos.x, y = pos.y - 1, z = pos.z}
local belowdef = nil local belowdef = nil
if core.registered_nodes[core.get_node(below).name] then if minetest.registered_nodes[minetest.get_node(below).name] then
belowdef = core.registered_nodes[core.get_node(below).name] belowdef = minetest.registered_nodes[minetest.get_node(below).name]
end end
if belowdef and belowdef.write_name ~= nil then if belowdef and belowdef.write_name ~= nil then
belowdef.write_name(below, text) belowdef.write_name(below, text)
@ -32,28 +32,28 @@ end
function default.grow_tree(pos, variety) function default.grow_tree(pos, variety)
local function grow() local function grow()
if variety == "apple" then if variety == "apple" then
core.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, core.get_modpath("default").."/schematics/default_tree.mts", "0", {}, false) minetest.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, minetest.get_modpath("default").."/schematics/default_tree.mts", "0", {}, false)
elseif variety == "oak" then elseif variety == "oak" then
core.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, core.get_modpath("default").."/schematics/default_tree.mts", "0", {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"}, false) minetest.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, minetest.get_modpath("default").."/schematics/default_tree.mts", "0", {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"}, false)
elseif variety == "birch" then elseif variety == "birch" then
core.place_schematic({x = pos.x-1, y = pos.y-1, z = pos.z-1}, core.get_modpath("default").."/schematics/default_squaretree.mts", "0", {["default:leaves"] = "default:leaves_birch", ["default:tree"] = "default:tree_birch", ["default:apple"] = "air"}, false) minetest.place_schematic({x = pos.x-1, y = pos.y-1, z = pos.z-1}, minetest.get_modpath("default").."/schematics/default_squaretree.mts", "0", {["default:leaves"] = "default:leaves_birch", ["default:tree"] = "default:tree_birch", ["default:apple"] = "air"}, false)
end end
end end
core.remove_node(pos) minetest.remove_node(pos)
core.after(0, grow) minetest.after(0, grow)
default.log(variety.." tree sapling grows at "..core.pos_to_string(pos), "info") default.log(variety.." tree sapling grows at "..minetest.pos_to_string(pos), "info")
end end
core.register_abm( -- apple trees or default trees minetest.register_abm( -- apple trees or default trees
{ {
nodenames = {"default:sapling"}, nodenames = {"default:sapling"},
interval = 10, interval = 10,
chance = 40, chance = 40,
action = function(pos, node) action = function(pos, node)
local is_soil = core.registered_nodes[core.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
if is_soil == nil or is_soil == 0 then return end if is_soil == nil or is_soil == 0 then return end
@ -61,25 +61,25 @@ core.register_abm( -- apple trees or default trees
end end
}) })
core.register_abm( -- oak trees minetest.register_abm( -- oak trees
{ {
nodenames = {"default:sapling_oak"}, nodenames = {"default:sapling_oak"},
interval = 10, interval = 10,
chance = 60, chance = 60,
action = function(pos, node) action = function(pos, node)
local is_soil = core.registered_nodes[core.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
if is_soil == nil or is_soil == 0 then return end if is_soil == nil or is_soil == 0 then return end
default.grow_tree(pos, "oak") default.grow_tree(pos, "oak")
end end
}) })
core.register_abm( -- birch trees minetest.register_abm( -- birch trees
{ {
nodenames = {"default:sapling_birch"}, nodenames = {"default:sapling_birch"},
interval = 10, interval = 10,
chance = 50, chance = 50,
action = function(pos, node) action = function(pos, node)
local is_soil = core.registered_nodes[core.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
if is_soil == nil or is_soil == 0 then return end if is_soil == nil or is_soil == 0 then return end
default.grow_tree(pos, "birch") default.grow_tree(pos, "birch")
end end
@ -90,18 +90,18 @@ core.register_abm( -- birch trees
function default.dig_up(pos, node, digger) function default.dig_up(pos, node, digger)
-- if digger == nil then return end -- if digger == nil then return end
local np = {x = pos.x, y = pos.y + 1, z = pos.z} local np = {x = pos.x, y = pos.y + 1, z = pos.z}
local nn = core.get_node(np) local nn = minetest.get_node(np)
if nn.name == node.name then if nn.name == node.name then
core.node_dig(np, nn, digger) minetest.node_dig(np, nn, digger)
end end
end end
function default.dig_down(pos, node, digger) function default.dig_down(pos, node, digger)
-- if digger == nil then return end -- if digger == nil then return end
local np = {x = pos.x, y = pos.y - 1, z = pos.z} local np = {x = pos.x, y = pos.y - 1, z = pos.z}
local nn = core.get_node(np) local nn = minetest.get_node(np)
if nn.name == node.name then if nn.name == node.name then
core.node_dig(np, nn, digger) minetest.node_dig(np, nn, digger)
end end
end end
@ -112,19 +112,19 @@ default.leafdecay_enable_cache = true
-- Spread the load of finding trunks -- Spread the load of finding trunks
default.leafdecay_trunk_find_allow_accumulator = 0 default.leafdecay_trunk_find_allow_accumulator = 0
core.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
local finds_per_second = 5000 local finds_per_second = 5000
default.leafdecay_trunk_find_allow_accumulator = default.leafdecay_trunk_find_allow_accumulator =
math.floor(dtime * finds_per_second) math.floor(dtime * finds_per_second)
end) end)
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing) default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
local node = core.get_node(pos) local node = minetest.get_node(pos)
node.param2 = 1 node.param2 = 1
core.set_node(pos, node) minetest.set_node(pos, node)
end end
core.register_abm( -- leaf decay minetest.register_abm( -- leaf decay
{ {
nodenames = {"group:leafdecay"}, nodenames = {"group:leafdecay"},
neighbors = {"air", "group:liquid"}, neighbors = {"air", "group:liquid"},
@ -135,23 +135,23 @@ core.register_abm( -- leaf decay
action = function(p0, node, _, _) action = function(p0, node, _, _)
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")") --print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
local do_preserve = false local do_preserve = false
local d = core.registered_nodes[node.name].groups.leafdecay local d = minetest.registered_nodes[node.name].groups.leafdecay
if not d or d == 0 then if not d or d == 0 then
--print("not groups.leafdecay") --print("not groups.leafdecay")
return return
end end
local n0 = core.get_node(p0) local n0 = minetest.get_node(p0)
if n0.param2 ~= 0 then if n0.param2 ~= 0 then
--print("param2 ~= 0") --print("param2 ~= 0")
return return
end end
local p0_hash = nil local p0_hash = nil
if default.leafdecay_enable_cache then if default.leafdecay_enable_cache then
p0_hash = core.hash_node_position(p0) p0_hash = minetest.hash_node_position(p0)
local trunkp = default.leafdecay_trunk_cache[p0_hash] local trunkp = default.leafdecay_trunk_cache[p0_hash]
if trunkp then if trunkp then
local n = core.get_node(trunkp) local n = minetest.get_node(trunkp)
local reg = core.registered_nodes[n.name] local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing work at the border of the active area -- Assume ignore is a trunk, to make the thing work at the border of the active area
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
--print("cached trunk still exists") --print("cached trunk still exists")
@ -168,7 +168,7 @@ core.register_abm( -- leaf decay
default.leafdecay_trunk_find_allow_accumulator = default.leafdecay_trunk_find_allow_accumulator =
default.leafdecay_trunk_find_allow_accumulator - 1 default.leafdecay_trunk_find_allow_accumulator - 1
-- Assume ignore is a trunk, to make the thing work at the border of the active area -- Assume ignore is a trunk, to make the thing work at the border of the active area
local p1 = core.find_node_near(p0, d, {"ignore", "group:tree"}) local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
if p1 then if p1 then
do_preserve = true do_preserve = true
if default.leafdecay_enable_cache then if default.leafdecay_enable_cache then
@ -179,55 +179,55 @@ core.register_abm( -- leaf decay
end end
if not do_preserve then if not do_preserve then
-- Drop stuff other than the node itself -- Drop stuff other than the node itself
local itemstacks = core.get_node_drops(n0.name) local itemstacks = minetest.get_node_drops(n0.name)
for _, itemname in ipairs(itemstacks) do for _, itemname in ipairs(itemstacks) do
if core.get_item_group(n0.name, "leafdecay_drop") ~= 0 or itemname ~= n0.name then if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or itemname ~= n0.name then
local p_drop = { local p_drop = {
x = p0.x - 0.5 + math.random(), x = p0.x - 0.5 + math.random(),
y = p0.y - 0.5 + math.random(), y = p0.y - 0.5 + math.random(),
z = p0.z - 0.5 + math.random(), z = p0.z - 0.5 + math.random(),
} }
core.add_item(p_drop, itemname) minetest.add_item(p_drop, itemname)
end end
end end
-- Remove node -- Remove node
core.remove_node(p0) minetest.remove_node(p0)
nodeupdate(p0) nodeupdate(p0)
end end
end end
}) })
core.register_abm( -- dirt and grass footsteps becomes dirt with grass if uncovered minetest.register_abm( -- dirt and grass footsteps becomes dirt with grass if uncovered
{ {
nodenames = {"default:dirt", "default:dirt_with_grass_footsteps"}, nodenames = {"default:dirt", "default:dirt_with_grass_footsteps"},
interval = 2, interval = 2,
chance = 40, chance = 40,
action = function(pos, node) action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z} local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = core.get_node(above).name local name = minetest.get_node(above).name
local nodedef = core.registered_nodes[name] local nodedef = minetest.registered_nodes[name]
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (core.get_node_light(above) or 0) >= 8 then if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (minetest.get_node_light(above) or 0) >= 8 then
core.set_node(pos, {name = "default:dirt_with_grass"}) minetest.set_node(pos, {name = "default:dirt_with_grass"})
end end
end end
}) })
core.register_abm( -- dirt with grass becomes dirt if covered minetest.register_abm( -- dirt with grass becomes dirt if covered
{ {
nodenames = {"default:dirt_with_grass"}, nodenames = {"default:dirt_with_grass"},
interval = 2, interval = 2,
chance = 10, chance = 10,
action = function(pos, node) action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z} local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = core.get_node(above).name local name = minetest.get_node(above).name
local nodedef = core.registered_nodes[name] local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none") then if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none") then
core.set_node(pos, {name = "default:dirt"}) minetest.set_node(pos, {name = "default:dirt"})
end end
end end
}) })
core.register_abm( -- grass expands minetest.register_abm( -- grass expands
{ {
nodenames = {"default:grass"}, nodenames = {"default:grass"},
interval = 20, interval = 20,
@ -238,16 +238,16 @@ core.register_abm( -- grass expands
local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz} local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz}
local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz} local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
local edgenode = core.get_node(edgepos) local edgenode = minetest.get_node(edgepos)
local downnode = core.get_node(downpos) local downnode = minetest.get_node(downpos)
if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then
core.set_node(edgepos, {name = "default:grass"}) minetest.set_node(edgepos, {name = "default:grass"})
end end
end end
}) })
core.register_abm( -- clams grow minetest.register_abm( -- clams grow
{ {
nodenames = {"default:clam"}, nodenames = {"default:clam"},
interval = 20, interval = 20,
@ -258,16 +258,16 @@ core.register_abm( -- clams grow
local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz} local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz}
local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz} local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
local edgenode = core.get_node(edgepos) local edgenode = minetest.get_node(edgepos)
local downnode = core.get_node(downpos) local downnode = minetest.get_node(downpos)
if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then
core.set_node(edgepos, {name = "default:clam"}) minetest.set_node(edgepos, {name = "default:clam"})
end end
end end
}) })
core.register_abm( -- cactus grows minetest.register_abm( -- cactus grows
{ {
nodenames = {"default:cactus"}, nodenames = {"default:cactus"},
neighbors = {"group:sand"}, neighbors = {"group:sand"},
@ -275,24 +275,24 @@ core.register_abm( -- cactus grows
chance = 10, chance = 10,
action = function(pos, node) action = function(pos, node)
pos.y = pos.y-1 pos.y = pos.y-1
local name = core.get_node(pos).name local name = minetest.get_node(pos).name
if core.get_item_group(name, "sand") ~= 0 then if minetest.get_item_group(name, "sand") ~= 0 then
pos.y = pos.y+1 pos.y = pos.y+1
local height = 0 local height = 0
while core.get_node(pos).name == "default:cactus" and height < 3 do while minetest.get_node(pos).name == "default:cactus" and height < 3 do
height = height+1 height = height+1
pos.y = pos.y+1 pos.y = pos.y+1
end end
if height < 3 then if height < 3 then
if core.get_node(pos).name == "air" then if minetest.get_node(pos).name == "air" then
core.set_node(pos, {name="default:cactus"}) minetest.set_node(pos, {name="default:cactus"})
end end
end end
end end
end, end,
}) })
core.register_abm( -- papyrus grows minetest.register_abm( -- papyrus grows
{ {
nodenames = {"default:papyrus"}, nodenames = {"default:papyrus"},
neighbors = {"group:plantable_sandy", "group:plantable_soil"}, neighbors = {"group:plantable_sandy", "group:plantable_soil"},
@ -300,26 +300,26 @@ core.register_abm( -- papyrus grows
chance = 10, chance = 10,
action = function(pos, node) action = function(pos, node)
pos.y = pos.y-1 pos.y = pos.y-1
local name = core.get_node(pos).name local name = minetest.get_node(pos).name
if core.find_node_near(pos, 3, {"group:water"}) == nil then if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return return
end end
pos.y = pos.y+1 pos.y = pos.y+1
local height = 0 local height = 0
while core.get_node(pos).name == "default:papyrus" and height < 3 do while minetest.get_node(pos).name == "default:papyrus" and height < 3 do
height = height+1 height = height+1
pos.y = pos.y+1 pos.y = pos.y+1
end end
if height < 3 then if height < 3 then
if core.get_node(pos).name == "air" then if minetest.get_node(pos).name == "air" then
core.set_node(pos, {name="default:papyrus"}) minetest.set_node(pos, {name="default:papyrus"})
end end
end end
end, end,
}) })
core.register_abm( -- papyrus grows minetest.register_abm( -- papyrus grows
{ {
nodenames = {"default:thistle"}, nodenames = {"default:thistle"},
neighbors = {"group:plantable_soil"}, neighbors = {"group:plantable_soil"},
@ -327,26 +327,26 @@ core.register_abm( -- papyrus grows
chance = 30, chance = 30,
action = function(pos, node) action = function(pos, node)
local height = 0 local height = 0
while core.get_node(pos).name == "default:thistle" and height < 3 do while minetest.get_node(pos).name == "default:thistle" and height < 3 do
height = height+1 height = height+1
pos.y = pos.y+1 pos.y = pos.y+1
end end
if height < 3 then if height < 3 then
if core.get_node(pos).name == "air" then if minetest.get_node(pos).name == "air" then
core.set_node(pos, {name="default:thistle"}) minetest.set_node(pos, {name="default:thistle"})
end end
end end
end, end,
}) })
--[[ TORCH FLAME IS VERY, VERY SLOW, THERE ARE NOW ANIMATIONS INSTEAD --[[ TORCH FLAME IS VERY, VERY SLOW, THERE ARE NOW ANIMATIONS INSTEAD
core.register_abm( -- torch flame minetest.register_abm( -- torch flame
{ {
nodenames = {"default:torch", "default:torch_weak"}, nodenames = {"default:torch", "default:torch_weak"},
interval = 5, interval = 5,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
core.add_particlespawner( minetest.add_particlespawner(
{ {
amount = 10, amount = 10,
time = 5, time = 5,
@ -366,13 +366,13 @@ core.register_abm( -- torch flame
}) })
--]] --]]
core.register_abm( -- weak torchs burn out and die after ~3 minutes minetest.register_abm( -- weak torchs burn out and die after ~3 minutes
{ {
nodenames = {"default:torch_weak"}, nodenames = {"default:torch_weak"},
interval = 3, interval = 3,
chance = 60, chance = 60,
action = function(pos, node) action = function(pos, node)
core.set_node(pos, {name = "default:torch_dead", param = node.param, param2 = node.param2}) minetest.set_node(pos, {name = "default:torch_dead", param = node.param, param2 = node.param2})
end end
}) })

View File

@ -50,7 +50,7 @@ form_furnace = form_furnace .. "image[3.25,1.75;1,1;ui_arrow_bg.png^[transformR2
default.ui.register_page("default_furnace_inactive", form_furnace) default.ui.register_page("default_furnace_inactive", form_furnace)
core.register_node( minetest.register_node(
"default:furnace", "default:furnace",
{ {
description = "Furnace", description = "Furnace",
@ -61,7 +61,7 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("default_furnace_inactive")) meta:set_string("formspec", default.ui.get_page("default_furnace_inactive"))
meta:set_string("infotext", "Furnace") meta:set_string("infotext", "Furnace")
@ -71,7 +71,7 @@ core.register_node(
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = core.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then if not inv:is_empty("fuel") then
return false return false
@ -84,7 +84,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:furnace_active", "default:furnace_active",
{ {
description = "Furnace", description = "Furnace",
@ -97,7 +97,7 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("default_furnace_inactive")) meta:set_string("formspec", default.ui.get_page("default_furnace_inactive"))
meta:set_string("infotext", "Furnace"); meta:set_string("infotext", "Furnace");
@ -107,7 +107,7 @@ core.register_node(
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = core.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then if not inv:is_empty("fuel") then
return false return false
@ -121,15 +121,15 @@ core.register_node(
}) })
function swap_node(pos, name) function swap_node(pos, name)
local node = core.get_node(pos) local node = minetest.get_node(pos)
if node.name == name then if node.name == name then
return return
end end
node.name = name node.name = name
core.swap_node(pos, node) minetest.swap_node(pos, node)
end end
core.register_abm( minetest.register_abm(
{ {
nodenames = {"default:furnace", "default:furnace_active"}, nodenames = {"default:furnace", "default:furnace_active"},
interval = 1.0, interval = 1.0,
@ -138,7 +138,7 @@ core.register_abm(
-- --
-- Initialize metadata -- Initialize metadata
-- --
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local fuel_time = meta:get_float("fuel_time") or 0 local fuel_time = meta:get_float("fuel_time") or 0
local src_time = meta:get_float("src_time") or 0 local src_time = meta:get_float("src_time") or 0
local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
@ -166,7 +166,7 @@ core.register_abm(
-- --
-- Check if we have cookable content -- Check if we have cookable content
local cooked, aftercooked = core.get_craft_result({method = "cooking", width = 1, items = srclist}) local cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
local cookable = true local cookable = true
if cooked.time == 0 then if cooked.time == 0 then
@ -194,7 +194,7 @@ core.register_abm(
-- Furnace ran out of fuel -- Furnace ran out of fuel
if cookable then if cookable then
-- We need to get new fuel -- We need to get new fuel
local fuel, afterfuel = core.get_craft_result({method = "fuel", width = 1, items = fuellist}) local fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
if fuel.time == 0 then if fuel.time == 0 then
-- No valid fuel in fuel list -- No valid fuel in fuel list

View File

@ -69,7 +69,7 @@ function default.hud.initialize_builtin_statbars(player)
player:hud_set_flags(flg) player:hud_set_flags(flg)
end end
if core.is_yes(core.setting_get("enable_damage")) then if minetest.is_yes(minetest.setting_get("enable_damage")) then
if default.hud.ids[name].id_healthbar == nil then if default.hud.ids[name].id_healthbar == nil then
health_bar_definition.number = player:get_hp() health_bar_definition.number = player:get_hp()
default.hud.ids[name].id_healthbar_bg = player:hud_add(health_bar_bg) default.hud.ids[name].id_healthbar_bg = player:hud_add(health_bar_bg)
@ -83,7 +83,7 @@ function default.hud.initialize_builtin_statbars(player)
end end
if (player:get_breath() < 11) then if (player:get_breath() < 11) then
if core.is_yes(core.setting_get("enable_damage")) then if minetest.is_yes(minetest.setting_get("enable_damage")) then
if default.hud.ids[name].id_breathbar == nil then if default.hud.ids[name].id_breathbar == nil then
default.hud.ids[name].id_breathbar_bg = player:hud_add(breath_bar_bg) default.hud.ids[name].id_breathbar_bg = player:hud_add(breath_bar_bg)
@ -161,7 +161,7 @@ function default.hud.replace_builtin(name, definition)
health_bar_definition = definition health_bar_definition = definition
for name,ids in pairs(default.hud.ids) do for name,ids in pairs(default.hud.ids) do
local player = core.get_player_by_name(name) local player = minetest.get_player_by_name(name)
if player and default.hud.ids[name].id_healthbar then if player and default.hud.ids[name].id_healthbar then
player:hud_remove(default.hud.ids[name].id_healthbar) player:hud_remove(default.hud.ids[name].id_healthbar)
default.hud.initialize_builtin_statbars(player) default.hud.initialize_builtin_statbars(player)
@ -174,7 +174,7 @@ function default.hud.replace_builtin(name, definition)
breath_bar_definition = definition breath_bar_definition = definition
for name,ids in pairs(default.hud.ids) do for name,ids in pairs(default.hud.ids) do
local player = core.get_player_by_name(name) local player = minetest.get_player_by_name(name)
if player and default.hud.ids[name].id_breathbar then if player and default.hud.ids[name].id_breathbar then
player:hud_remove(default.hud.ids[name].id_breathbar) player:hud_remove(default.hud.ids[name].id_breathbar)
default.hud.initialize_builtin_statbars(player) default.hud.initialize_builtin_statbars(player)
@ -186,9 +186,9 @@ function default.hud.replace_builtin(name, definition)
return false return false
end end
core.register_on_joinplayer(default.hud.initialize_builtin_statbars) minetest.register_on_joinplayer(default.hud.initialize_builtin_statbars)
core.register_on_leaveplayer(default.hud.cleanup_builtin_statbars) minetest.register_on_leaveplayer(default.hud.cleanup_builtin_statbars)
core.register_playerevent(default.hud.player_event_handler) minetest.register_playerevent(default.hud.player_event_handler)
default.log("hud", "loaded") default.log("hud", "loaded")

View File

@ -17,31 +17,31 @@ default.WATER_VISC = 1
default.LIGHT_MAX = 14 default.LIGHT_MAX = 14
function default.log(text, type) function default.log(text, type)
core.log("action", "Pixture ["..type.."] "..text) minetest.log("action", "Pixture ["..type.."] "..text)
end end
function default.dumpvec(v) function default.dumpvec(v)
return v.x..":"..v.y..":"..v.z return v.x..":"..v.y..":"..v.z
end end
core.nodedef_default.stack_max = 60 minetest.nodedef_default.stack_max = 60
core.craftitemdef_default.stack_max = 60 minetest.craftitemdef_default.stack_max = 60
function core.nodedef_default.on_receive_fields(pos, form_name, fields, player) function minetest.nodedef_default.on_receive_fields(pos, form_name, fields, player)
default.ui.receive_fields(player, form_name, fields) default.ui.receive_fields(player, form_name, fields)
end end
dofile(core.get_modpath("default").."/formspec.lua") dofile(minetest.get_modpath("default").."/formspec.lua")
dofile(core.get_modpath("default").."/functions.lua") dofile(minetest.get_modpath("default").."/functions.lua")
dofile(core.get_modpath("default").."/sounds.lua") dofile(minetest.get_modpath("default").."/sounds.lua")
dofile(core.get_modpath("default").."/nodes.lua") dofile(minetest.get_modpath("default").."/nodes.lua")
dofile(core.get_modpath("default").."/craftitems.lua") dofile(minetest.get_modpath("default").."/craftitems.lua")
dofile(core.get_modpath("default").."/crafting.lua") dofile(minetest.get_modpath("default").."/crafting.lua")
dofile(core.get_modpath("default").."/tools.lua") dofile(minetest.get_modpath("default").."/tools.lua")
dofile(core.get_modpath("default").."/furnace.lua") dofile(minetest.get_modpath("default").."/furnace.lua")
dofile(core.get_modpath("default").."/mapgen.lua") dofile(minetest.get_modpath("default").."/mapgen.lua")
dofile(core.get_modpath("default").."/hud.lua") dofile(minetest.get_modpath("default").."/hud.lua")
dofile(core.get_modpath("default").."/player.lua") dofile(minetest.get_modpath("default").."/player.lua")
dofile(core.get_modpath("default").."/model.lua") dofile(minetest.get_modpath("default").."/model.lua")
default.log("mod:default", "loaded") default.log("mod:default", "loaded")

View File

@ -4,36 +4,36 @@
-- Aliases for map generator outputs(Might not be needed with v7, but JIC) -- Aliases for map generator outputs(Might not be needed with v7, but JIC)
-- --
core.register_alias("mapgen_stone", "default:stone") minetest.register_alias("mapgen_stone", "default:stone")
core.register_alias("mapgen_tree", "default:tree") minetest.register_alias("mapgen_tree", "default:tree")
core.register_alias("mapgen_leaves", "default:leaves") minetest.register_alias("mapgen_leaves", "default:leaves")
core.register_alias("mapgen_apple", "default:apple") minetest.register_alias("mapgen_apple", "default:apple")
core.register_alias("mapgen_water_source", "default:water_source") minetest.register_alias("mapgen_water_source", "default:water_source")
core.register_alias("mapgen_river_water_source", "default:river_water_source") minetest.register_alias("mapgen_river_water_source", "default:river_water_source")
core.register_alias("mapgen_dirt", "default:dirt") minetest.register_alias("mapgen_dirt", "default:dirt")
core.register_alias("mapgen_sand", "default:sand") minetest.register_alias("mapgen_sand", "default:sand")
core.register_alias("mapgen_desert_sand", "default:sand") minetest.register_alias("mapgen_desert_sand", "default:sand")
core.register_alias("mapgen_desert_stone", "default:sandstone") minetest.register_alias("mapgen_desert_stone", "default:sandstone")
core.register_alias("mapgen_gravel", "default:gravel") minetest.register_alias("mapgen_gravel", "default:gravel")
core.register_alias("mapgen_cobble", "default:cobble") minetest.register_alias("mapgen_cobble", "default:cobble")
core.register_alias("mapgen_mossycobble", "default:reinforced_cobble") minetest.register_alias("mapgen_mossycobble", "default:reinforced_cobble")
core.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass") minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
core.register_alias("mapgen_junglegrass", "default:grass") minetest.register_alias("mapgen_junglegrass", "default:grass")
core.register_alias("mapgen_stone_with_coal", "default:stone_with_coal") minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
core.register_alias("mapgen_stone_with_iron", "default:stone_with_iron") minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
core.register_alias("mapgen_mese", "default:block_steel") minetest.register_alias("mapgen_mese", "default:block_steel")
core.register_alias("mapgen_stair_cobble", "default:reinforced_frame") minetest.register_alias("mapgen_stair_cobble", "default:reinforced_frame")
core.register_alias("mapgen_lava_source", "default:water_source") minetest.register_alias("mapgen_lava_source", "default:water_source")
-- --
-- Biome setup -- Biome setup
-- --
core.clear_registered_biomes() minetest.clear_registered_biomes()
-- Aboveground biomes -- Aboveground biomes
core.register_biome( minetest.register_biome(
{ {
name = "Marsh", name = "Marsh",
@ -50,7 +50,7 @@ core.register_biome(
humidity_point = 55, humidity_point = 55,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Swamp", name = "Swamp",
@ -67,7 +67,7 @@ core.register_biome(
humidity_point = 42, humidity_point = 42,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Deep Forest", name = "Deep Forest",
@ -84,7 +84,7 @@ core.register_biome(
humidity_point = 40, humidity_point = 40,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Forest", name = "Forest",
@ -101,7 +101,7 @@ core.register_biome(
humidity_point = 40, humidity_point = 40,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Grove", name = "Grove",
@ -118,7 +118,7 @@ core.register_biome(
humidity_point = 38, humidity_point = 38,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Wilderness", name = "Wilderness",
@ -135,7 +135,7 @@ core.register_biome(
humidity_point = 35, humidity_point = 35,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Grassland", name = "Grassland",
@ -152,7 +152,7 @@ core.register_biome(
humidity_point = 33, humidity_point = 33,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Orchard", name = "Orchard",
@ -169,7 +169,7 @@ core.register_biome(
humidity_point = 33, humidity_point = 33,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Chaparral", name = "Chaparral",
@ -186,7 +186,7 @@ core.register_biome(
humidity_point = 30, humidity_point = 30,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Savanna", name = "Savanna",
@ -203,7 +203,7 @@ core.register_biome(
humidity_point = 25, humidity_point = 25,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Desert", name = "Desert",
@ -220,7 +220,7 @@ core.register_biome(
humidity_point = 20, humidity_point = 20,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Wasteland", name = "Wasteland",
@ -239,7 +239,7 @@ core.register_biome(
-- Oceans -- Oceans
core.register_biome( minetest.register_biome(
{ {
name = "Grassland Ocean", name = "Grassland Ocean",
@ -256,7 +256,7 @@ core.register_biome(
humidity_point = 35, humidity_point = 35,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Gravel Beach", name = "Gravel Beach",
@ -273,7 +273,7 @@ core.register_biome(
humidity_point = 31, humidity_point = 31,
}) })
core.register_biome( minetest.register_biome(
{ {
name = "Savanna Ocean", name = "Savanna Ocean",
@ -296,7 +296,7 @@ core.register_biome(
-- Trees -- Trees
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -305,12 +305,12 @@ core.register_decoration(
biomes = {"Forest"}, biomes = {"Forest"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
replacements = {["default:leaves"] = "default:leaves_birch", ["default:tree"] = "default:tree_birch", ["default:apple"] = "air"}, replacements = {["default:leaves"] = "default:leaves_birch", ["default:tree"] = "default:tree_birch", ["default:apple"] = "air"},
schematic = core.get_modpath("default").."/schematics/default_squaretree.mts", schematic = minetest.get_modpath("default").."/schematics/default_squaretree.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -318,12 +318,12 @@ core.register_decoration(
fill_ratio = 0.007, fill_ratio = 0.007,
biomes = {"Orchard"}, biomes = {"Orchard"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_tree.mts", schematic = minetest.get_modpath("default").."/schematics/default_tree.mts",
y_min = 10, y_min = 10,
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -332,12 +332,12 @@ core.register_decoration(
biomes = {"Forest", "Deep Forest"}, biomes = {"Forest", "Deep Forest"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
replacements = {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"}, replacements = {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"},
schematic = core.get_modpath("default").."/schematics/default_tree.mts", schematic = minetest.get_modpath("default").."/schematics/default_tree.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -345,12 +345,12 @@ core.register_decoration(
fill_ratio = 0.008, fill_ratio = 0.008,
biomes = {"Forest"}, biomes = {"Forest"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_megatree.mts", schematic = minetest.get_modpath("default").."/schematics/default_megatree.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -358,12 +358,12 @@ core.register_decoration(
fill_ratio = 0.023, fill_ratio = 0.023,
biomes = {"Deep Forest"}, biomes = {"Deep Forest"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_gigatree.mts", schematic = minetest.get_modpath("default").."/schematics/default_gigatree.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -372,12 +372,12 @@ core.register_decoration(
biomes = {"Wilderness"}, biomes = {"Wilderness"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
replacements = {["default:apple"] = "air"}, replacements = {["default:apple"] = "air"},
schematic = core.get_modpath("default").."/schematics/default_tree.mts", schematic = minetest.get_modpath("default").."/schematics/default_tree.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -386,12 +386,12 @@ core.register_decoration(
biomes = {"Wilderness"}, biomes = {"Wilderness"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
replacements = {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"}, replacements = {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"},
schematic = core.get_modpath("default").."/schematics/default_tree.mts", schematic = minetest.get_modpath("default").."/schematics/default_tree.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -399,14 +399,14 @@ core.register_decoration(
fill_ratio = 0.004, fill_ratio = 0.004,
biomes = {"Grove"}, biomes = {"Grove"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_talltree.mts", schematic = minetest.get_modpath("default").."/schematics/default_talltree.mts",
y_min = 0, y_min = 0,
y_max = 32000, y_max = 32000,
}) })
-- Papyrus -- Papyrus
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = {"default:sand", "default:dirt", "default:dirt_with_grass"}, place_on = {"default:sand", "default:dirt", "default:dirt_with_grass"},
@ -423,7 +423,7 @@ core.register_decoration(
-- Flowers -- Flowers
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -437,7 +437,7 @@ core.register_decoration(
-- Grasses -- Grasses
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -449,7 +449,7 @@ core.register_decoration(
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_swamp_grass", place_on = "default:dirt_with_swamp_grass",
@ -461,7 +461,7 @@ core.register_decoration(
y_max = 40, y_max = 40,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_dry_grass", place_on = "default:dirt_with_dry_grass",
@ -473,7 +473,7 @@ core.register_decoration(
y_max = 500, y_max = 500,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -485,7 +485,7 @@ core.register_decoration(
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -497,7 +497,7 @@ core.register_decoration(
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -509,7 +509,7 @@ core.register_decoration(
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -521,7 +521,7 @@ core.register_decoration(
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -535,7 +535,7 @@ core.register_decoration(
-- Thistle -- Thistle
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -550,7 +550,7 @@ core.register_decoration(
-- Ferns -- Ferns
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -564,8 +564,8 @@ core.register_decoration(
-- Farming -- Farming
if core.get_modpath("farming") ~= nil then if minetest.get_modpath("farming") ~= nil then
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -577,7 +577,7 @@ if core.get_modpath("farming") ~= nil then
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",
@ -589,7 +589,7 @@ if core.get_modpath("farming") ~= nil then
y_max = 32000, y_max = 32000,
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:sand", place_on = "default:sand",
@ -604,7 +604,7 @@ end
-- Cactus -- Cactus
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:sand"}, place_on = {"default:sand"},
@ -612,7 +612,7 @@ core.register_decoration(
fill_ratio = 0.004, fill_ratio = 0.004,
biomes = {"Desert"}, biomes = {"Desert"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_cactus.mts", schematic = minetest.get_modpath("default").."/schematics/default_cactus.mts",
y_min = 10, y_min = 10,
y_max = 500, y_max = 500,
rotation = "random", rotation = "random",
@ -620,7 +620,7 @@ core.register_decoration(
-- Shrubs -- Shrubs
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_dry_grass"}, place_on = {"default:dirt_with_dry_grass"},
@ -629,13 +629,13 @@ core.register_decoration(
biomes = {"Savanna", "Chaparral"}, biomes = {"Savanna", "Chaparral"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
replacements = {["default:leaves"] = "default:dry_leaves"}, replacements = {["default:leaves"] = "default:dry_leaves"},
schematic = core.get_modpath("default").."/schematics/default_shrub.mts", schematic = minetest.get_modpath("default").."/schematics/default_shrub.mts",
y_min = 3, y_min = 3,
y_max = 32000, y_max = 32000,
rotation = "0", rotation = "0",
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_dry_grass"}, place_on = {"default:dirt_with_dry_grass"},
@ -644,13 +644,13 @@ core.register_decoration(
biomes = {"Chaparral"}, biomes = {"Chaparral"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
replacements = {["default:leaves"] = "default:dry_leaves"}, replacements = {["default:leaves"] = "default:dry_leaves"},
schematic = core.get_modpath("default").."/schematics/default_bush.mts", schematic = minetest.get_modpath("default").."/schematics/default_bush.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
rotation = "0", rotation = "0",
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dirt_with_grass"}, place_on = {"default:dirt_with_grass"},
@ -658,7 +658,7 @@ core.register_decoration(
fill_ratio = 0.004, fill_ratio = 0.004,
biomes = {"Wilderness", "Grove"}, biomes = {"Wilderness", "Grove"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_bush.mts", schematic = minetest.get_modpath("default").."/schematics/default_bush.mts",
y_min = 3, y_min = 3,
y_max = 32000, y_max = 32000,
rotation = "0", rotation = "0",
@ -666,7 +666,7 @@ core.register_decoration(
-- Rocks -- Rocks
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dry_dirt"}, place_on = {"default:dry_dirt"},
@ -674,13 +674,13 @@ core.register_decoration(
fill_ratio = 0.006, fill_ratio = 0.006,
biomes = {"Wasteland"}, biomes = {"Wasteland"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_small_rock.mts", schematic = minetest.get_modpath("default").."/schematics/default_small_rock.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
rotation = "random", rotation = "random",
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "schematic", deco_type = "schematic",
place_on = {"default:dry_dirt"}, place_on = {"default:dry_dirt"},
@ -688,7 +688,7 @@ core.register_decoration(
fill_ratio = 0.004, fill_ratio = 0.004,
biomes = {"Wasteland"}, biomes = {"Wasteland"},
flags = "place_center_x, place_center_z", flags = "place_center_x, place_center_z",
schematic = core.get_modpath("default").."/schematics/default_large_rock.mts", schematic = minetest.get_modpath("default").."/schematics/default_large_rock.mts",
y_min = -32000, y_min = -32000,
y_max = 32000, y_max = 32000,
rotation = "random", rotation = "random",
@ -696,7 +696,7 @@ core.register_decoration(
-- Clams -- Clams
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = {"default:sand", "default:gravel"}, place_on = {"default:sand", "default:gravel"},
@ -715,7 +715,7 @@ core.register_decoration(
-- Coal -- Coal
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "default:stone_with_coal", ore = "default:stone_with_coal",
@ -727,7 +727,7 @@ core.register_ore(
y_max = 32, y_max = 32,
}) })
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "default:stone_with_coal", ore = "default:stone_with_coal",
@ -739,7 +739,7 @@ core.register_ore(
y_max = -32, y_max = -32,
}) })
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "default:stone_with_coal", ore = "default:stone_with_coal",
@ -753,7 +753,7 @@ core.register_ore(
-- Iron -- Iron
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "default:stone_with_iron", ore = "default:stone_with_iron",
@ -765,7 +765,7 @@ core.register_ore(
y_max = 0, y_max = 0,
}) })
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "default:stone_with_iron", ore = "default:stone_with_iron",
@ -779,7 +779,7 @@ core.register_ore(
-- Steel blocks -- Steel blocks
core.register_ore( minetest.register_ore(
{ {
ore_type = "blob", ore_type = "blob",
ore = "default:block_steel", ore = "default:block_steel",
@ -793,7 +793,7 @@ core.register_ore(
-- Water -- Water
core.register_ore( -- Springs minetest.register_ore( -- Springs
{ {
ore_type = "blob", ore_type = "blob",
ore = "default:water_source", ore = "default:water_source",
@ -806,7 +806,7 @@ core.register_ore( -- Springs
y_max = 31000, y_max = 31000,
}) })
core.register_ore( -- Pools minetest.register_ore( -- Pools
{ {
ore_type = "blob", ore_type = "blob",
ore = "default:water_source", ore = "default:water_source",
@ -819,7 +819,7 @@ core.register_ore( -- Pools
y_max = 40, y_max = 40,
}) })
core.register_ore( -- Swamp minetest.register_ore( -- Swamp
{ {
ore_type = "blob", ore_type = "blob",
ore = "default:swamp_water_source", ore = "default:swamp_water_source",
@ -832,7 +832,7 @@ core.register_ore( -- Swamp
y_max = 31000, y_max = 31000,
}) })
core.register_ore( -- Marsh minetest.register_ore( -- Marsh
{ {
ore_type = "blob", ore_type = "blob",
ore = "default:swamp_water_source", ore = "default:swamp_water_source",

View File

@ -107,14 +107,14 @@ function default.player_set_animation(player, anim_name, speed)
end end
-- Update appearance when the player joins -- Update appearance when the player joins
core.register_on_joinplayer( minetest.register_on_joinplayer(
function(player) function(player)
default.player_attached[player:get_player_name()] = false default.player_attached[player:get_player_name()] = false
default.player_set_model(player, "character.b3d") default.player_set_model(player, "character.b3d")
player:set_local_animation({x = 0, y = 79}, {x = 168, y = 187}, {x = 189, y = 198}, {x = 200, y = 219}, player_animation_speed) player:set_local_animation({x = 0, y = 79}, {x = 168, y = 187}, {x = 189, y = 198}, {x = 200, y = 219}, player_animation_speed)
end) end)
core.register_on_leaveplayer( minetest.register_on_leaveplayer(
function(player) function(player)
local name = player:get_player_name() local name = player:get_player_name()
player_model[name] = nil player_model[name] = nil
@ -127,9 +127,9 @@ local player_set_animation = default.player_set_animation
local player_attached = default.player_attached local player_attached = default.player_attached
-- Check each player and apply animations -- Check each player and apply animations
core.register_globalstep( minetest.register_globalstep(
function(dtime) function(dtime)
for _, player in pairs(core.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local model_name = player_model[name] local model_name = player_model[name]
local model = model_name and models[model_name] local model = model_name and models[model_name]

View File

@ -2,7 +2,7 @@
-- Node definitions -- Node definitions
--wate --wate
core.register_node( minetest.register_node(
"default:stone", "default:stone",
{ {
description = "Stone", description = "Stone",
@ -12,7 +12,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:cobble", "default:cobble",
{ {
description = "Cobble", description = "Cobble",
@ -22,7 +22,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:reinforced_cobble", "default:reinforced_cobble",
{ {
description = "Reinforced Cobble", description = "Reinforced Cobble",
@ -31,7 +31,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:stone_with_coal", "default:stone_with_coal",
{ {
description = "Stone with Coal", description = "Stone with Coal",
@ -41,7 +41,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:stone_with_iron", "default:stone_with_iron",
{ {
description = "Stone with Iron", description = "Stone with Iron",
@ -51,7 +51,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:block_steel", "default:block_steel",
{ {
description = "Steel Block", description = "Steel Block",
@ -60,7 +60,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:block_coal", "default:block_coal",
{ {
description = "Coal Block", description = "Coal Block",
@ -69,7 +69,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:dirt", "default:dirt",
{ {
description = "Dirt", description = "Dirt",
@ -79,7 +79,7 @@ core.register_node(
sounds = default.node_sound_dirt_defaults(), sounds = default.node_sound_dirt_defaults(),
}) })
core.register_node( minetest.register_node(
"default:dry_dirt", "default:dry_dirt",
{ {
description = "Dry Dirt", description = "Dry Dirt",
@ -89,7 +89,7 @@ core.register_node(
sounds = default.node_sound_dirt_defaults(), sounds = default.node_sound_dirt_defaults(),
}) })
core.register_node( minetest.register_node(
"default:swamp_dirt", "default:swamp_dirt",
{ {
description = "Swamp Dirt", description = "Swamp Dirt",
@ -99,7 +99,7 @@ core.register_node(
sounds = default.node_sound_dirt_defaults(), sounds = default.node_sound_dirt_defaults(),
}) })
core.register_node( minetest.register_node(
"default:fertilized_dirt", "default:fertilized_dirt",
{ {
description = "Fertilized Dirt", description = "Fertilized Dirt",
@ -116,7 +116,7 @@ core.register_node(
sounds = default.node_sound_dirt_defaults(), sounds = default.node_sound_dirt_defaults(),
}) })
core.register_node( minetest.register_node(
"default:dirt_with_dry_grass", "default:dirt_with_dry_grass",
{ {
description = "Dirt with Dry Grass", description = "Dirt with Dry Grass",
@ -137,7 +137,7 @@ core.register_node(
}), }),
}) })
core.register_node( minetest.register_node(
"default:dirt_with_swamp_grass", "default:dirt_with_swamp_grass",
{ {
description = "Dirt with Swamp Grass", description = "Dirt with Swamp Grass",
@ -158,7 +158,7 @@ core.register_node(
}), }),
}) })
core.register_node( minetest.register_node(
"default:dirt_with_grass", "default:dirt_with_grass",
{ {
description = "Dirt with Grass", description = "Dirt with Grass",
@ -180,7 +180,7 @@ core.register_node(
}), }),
}) })
core.register_node( minetest.register_node(
"default:dirt_with_grass_footsteps", "default:dirt_with_grass_footsteps",
{ {
description = "Dirt with Grass Footsteps", description = "Dirt with Grass Footsteps",
@ -202,7 +202,7 @@ core.register_node(
}), }),
}) })
core.register_node( minetest.register_node(
"default:dirt_path", "default:dirt_path",
{ {
description = "Dirt Path", description = "Dirt Path",
@ -218,7 +218,7 @@ core.register_node(
sounds = default.node_sound_dirt_defaults(), sounds = default.node_sound_dirt_defaults(),
}) })
core.register_node( minetest.register_node(
"default:path_slab", "default:path_slab",
{ {
description = "Dirt Path Slab", description = "Dirt Path Slab",
@ -234,7 +234,7 @@ core.register_node(
sounds = default.node_sound_dirt_defaults(), sounds = default.node_sound_dirt_defaults(),
}) })
core.register_node( minetest.register_node(
"default:heated_dirt_path", "default:heated_dirt_path",
{ {
description = "Heated Dirt Path", description = "Heated Dirt Path",
@ -251,7 +251,7 @@ core.register_node(
sounds = default.node_sound_dirt_defaults(), sounds = default.node_sound_dirt_defaults(),
}) })
core.register_node( minetest.register_node(
"default:brick", "default:brick",
{ {
description = "Brick", description = "Brick",
@ -261,7 +261,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:sand", "default:sand",
{ {
description = "Sand", description = "Sand",
@ -270,7 +270,7 @@ core.register_node(
sounds = default.node_sound_sand_defaults(), sounds = default.node_sound_sand_defaults(),
}) })
core.register_node( minetest.register_node(
"default:fertilized_sand", "default:fertilized_sand",
{ {
description = "Fertilized Sand", description = "Fertilized Sand",
@ -289,7 +289,7 @@ core.register_node(
sounds = default.node_sound_sand_defaults(), sounds = default.node_sound_sand_defaults(),
}) })
core.register_node( minetest.register_node(
"default:sandstone", "default:sandstone",
{ {
description = "Sandstone", description = "Sandstone",
@ -299,7 +299,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:compressed_sandstone", "default:compressed_sandstone",
{ {
description = "Compressed Sandstone", description = "Compressed Sandstone",
@ -309,7 +309,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"default:gravel", "default:gravel",
{ {
description = "Gravel", description = "Gravel",
@ -321,7 +321,7 @@ core.register_node(
}), }),
}) })
core.register_node( minetest.register_node(
"default:sapling_oak", "default:sapling_oak",
{ {
description = "Oak Sapling", description = "Oak Sapling",
@ -340,7 +340,7 @@ core.register_node(
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:tree_oak", "default:tree_oak",
{ {
description = "Oak Tree", description = "Oak Tree",
@ -349,7 +349,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:leaves_oak", "default:leaves_oak",
{ {
description = "Oak Leaves", description = "Oak Leaves",
@ -374,7 +374,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( -- looks just like default oak leaves, except they decay much farther minetest.register_node( -- looks just like default oak leaves, except they decay much farther
"default:leaves_oak_huge", "default:leaves_oak_huge",
{ {
description = "Oak Leaves(Huge)", description = "Oak Leaves(Huge)",
@ -400,7 +400,7 @@ core.register_node( -- looks just like default oak leaves, except they decay muc
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:sapling_birch", "default:sapling_birch",
{ {
description = "Birch Sapling", description = "Birch Sapling",
@ -420,7 +420,7 @@ core.register_node(
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:tree_birch", "default:tree_birch",
{ {
description = "Birch Tree", description = "Birch Tree",
@ -429,7 +429,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:leaves_birch", "default:leaves_birch",
{ {
description = "Birch Leaves", description = "Birch Leaves",
@ -454,7 +454,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:sapling", "default:sapling",
{ {
description = "Sapling", description = "Sapling",
@ -474,7 +474,7 @@ core.register_node(
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:tree", "default:tree",
{ {
description = "Tree", description = "Tree",
@ -483,7 +483,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:leaves", "default:leaves",
{ {
description = "Leaves", description = "Leaves",
@ -508,7 +508,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:dry_leaves", "default:dry_leaves",
{ {
description = "Dry Leaves", description = "Dry Leaves",
@ -533,7 +533,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:cactus", "default:cactus",
{ {
description = "Cactus", description = "Cactus",
@ -560,10 +560,10 @@ core.register_node(
after_dig_node = function(pos, node, metadata, digger) after_dig_node = function(pos, node, metadata, digger)
default.dig_up(pos, node, digger) default.dig_up(pos, node, digger)
end, end,
on_use = core.item_eat({hp = 2, sat = 5}), on_use = minetest.item_eat({hp = 2, sat = 5}),
}) })
core.register_node( minetest.register_node(
"default:rope", "default:rope",
{ {
description = "Rope", description = "Rope",
@ -587,7 +587,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:papyrus", "default:papyrus",
{ {
description = "Papyrus", description = "Papyrus",
@ -619,7 +619,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:papyrus", "default:papyrus",
{ {
description = "Papyrus", description = "Papyrus",
@ -651,7 +651,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:bookshelf", "default:bookshelf",
{ {
description = "Bookshelf", description = "Bookshelf",
@ -661,19 +661,19 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("core_bookshelf")) meta:set_string("formspec", default.ui.get_page("core_bookshelf"))
meta:set_string("infotext", "Bookshelf") meta:set_string("infotext", "Bookshelf")
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("main", 4*2) inv:set_size("main", 4*2)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = core.get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("main") return inv:is_empty("main")
end, end,
write_name = function(pos, text) write_name = function(pos, text)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if text ~= "" then if text ~= "" then
meta:set_string("infotext", text) meta:set_string("infotext", text)
@ -683,7 +683,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:glass", "default:glass",
{ {
description = "Glass", description = "Glass",
@ -696,7 +696,7 @@ core.register_node(
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
}) })
core.register_node( minetest.register_node(
"default:fence", "default:fence",
{ {
description = "Wooden Fence", description = "Wooden Fence",
@ -717,7 +717,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:fence_oak", "default:fence_oak",
{ {
description = "Oak Fence", description = "Oak Fence",
@ -738,7 +738,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:fence_birch", "default:fence_birch",
{ {
description = "Birch Fence", description = "Birch Fence",
@ -759,7 +759,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:ladder", "default:ladder",
{ {
description = "Ladder", description = "Ladder",
@ -791,7 +791,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:planks", "default:planks",
{ {
description = "Planks", description = "Planks",
@ -801,7 +801,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:planks_oak", "default:planks_oak",
{ {
description = "Oak Planks", description = "Oak Planks",
@ -811,7 +811,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:planks_birch", "default:planks_birch",
{ {
description = "Birch Planks", description = "Birch Planks",
@ -821,7 +821,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:frame", "default:frame",
{ {
description = "Frame", description = "Frame",
@ -831,7 +831,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:reinforced_frame", "default:reinforced_frame",
{ {
description = "Reinforced Frame", description = "Reinforced Frame",
@ -841,11 +841,11 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_node( minetest.register_node(
"default:water_flowing", "default:water_flowing",
{ {
description = "Water (flowing)", description = "Water (flowing)",
inventory_image = core.inventorycube("default_water.png"), inventory_image = minetest.inventorycube("default_water.png"),
drawtype = "flowingliquid", drawtype = "flowingliquid",
tiles ={"default_water.png"}, tiles ={"default_water.png"},
special_tiles = { special_tiles = {
@ -877,11 +877,11 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
}) })
core.register_node( minetest.register_node(
"default:water_source", "default:water_source",
{ {
description = "Water", description = "Water",
inventory_image = core.inventorycube("default_water.png"), inventory_image = minetest.inventorycube("default_water.png"),
drawtype = "liquid", drawtype = "liquid",
tiles ={"default_water.png"}, tiles ={"default_water.png"},
special_tiles = { special_tiles = {
@ -907,11 +907,11 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
}) })
core.register_node( minetest.register_node(
"default:river_water_flowing", "default:river_water_flowing",
{ {
description = "River Water (flowing)", description = "River Water (flowing)",
inventory_image = core.inventorycube("default_water.png"), inventory_image = minetest.inventorycube("default_water.png"),
drawtype = "flowingliquid", drawtype = "flowingliquid",
tiles ={"default_water.png"}, tiles ={"default_water.png"},
special_tiles = { special_tiles = {
@ -945,11 +945,11 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
}) })
core.register_node( minetest.register_node(
"default:river_water_source", "default:river_water_source",
{ {
description = "River Water", description = "River Water",
inventory_image = core.inventorycube("default_water.png"), inventory_image = minetest.inventorycube("default_water.png"),
drawtype = "liquid", drawtype = "liquid",
tiles ={"default_water.png"}, tiles ={"default_water.png"},
special_tiles = { special_tiles = {
@ -977,11 +977,11 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
}) })
core.register_node( minetest.register_node(
"default:swamp_water_flowing", "default:swamp_water_flowing",
{ {
description = "Swamp Water (flowing)", description = "Swamp Water (flowing)",
inventory_image = core.inventorycube("default_swamp_water.png"), inventory_image = minetest.inventorycube("default_swamp_water.png"),
drawtype = "flowingliquid", drawtype = "flowingliquid",
tiles ={"default_swamp_water.png"}, tiles ={"default_swamp_water.png"},
special_tiles = { special_tiles = {
@ -1015,11 +1015,11 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
}) })
core.register_node( minetest.register_node(
"default:swamp_water_source", "default:swamp_water_source",
{ {
description = "Swamp Water", description = "Swamp Water",
inventory_image = core.inventorycube("default_swamp.png"), inventory_image = minetest.inventorycube("default_swamp.png"),
drawtype = "liquid", drawtype = "liquid",
tiles ={"default_swamp_water.png"}, tiles ={"default_swamp_water.png"},
special_tiles = { special_tiles = {
@ -1047,7 +1047,7 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
}) })
core.register_node( minetest.register_node(
"default:torch_dead", "default:torch_dead",
{ {
description = "Dead Torch", description = "Dead Torch",
@ -1098,7 +1098,7 @@ core.register_node(
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:torch_weak", "default:torch_weak",
{ {
description = "Weak Torch", description = "Weak Torch",
@ -1150,7 +1150,7 @@ core.register_node(
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:torch", "default:torch",
{ {
description = "Torch", description = "Torch",
@ -1202,7 +1202,7 @@ core.register_node(
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:sign", "default:sign",
{ {
description = "Sign", description = "Sign",
@ -1224,19 +1224,19 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
on_construct = function(pos) on_construct = function(pos)
--local n = core.get_node(pos) --local n = minetest.get_node(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("core_field")) meta:set_string("formspec", default.ui.get_page("core_field"))
meta:set_string("infotext", '""') meta:set_string("infotext", '""')
meta:set_string("text", "") meta:set_string("text", "")
end, end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..core.pos_to_string(pos).." got "..dump(fields)) --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
if fields.text == nil then return end if fields.text == nil then return end
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
core.log("action", (sender:get_player_name() or "").. minetest.log("action", (sender:get_player_name() or "")..
" wrote \""..fields.text.."\" to sign at ".. " wrote \""..fields.text.."\" to sign at "..
core.pos_to_string(pos)) minetest.pos_to_string(pos))
meta:set_string("text", fields.text) meta:set_string("text", fields.text)
meta:set_string("infotext", '"'..fields.text..'"') meta:set_string("infotext", '"'..fields.text..'"')
@ -1247,7 +1247,7 @@ core.register_node(
end end
}) })
core.register_node( minetest.register_node(
"default:fern", "default:fern",
{ {
description = "Fern", description = "Fern",
@ -1268,7 +1268,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:flower", "default:flower",
{ {
description = "Flower", description = "Flower",
@ -1288,7 +1288,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:swamp_grass", "default:swamp_grass",
{ {
description = "Swamp Grass Clump", description = "Swamp Grass Clump",
@ -1309,7 +1309,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:dry_grass", "default:dry_grass",
{ {
description = "Dry Grass Clump", description = "Dry Grass Clump",
@ -1330,7 +1330,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:grass", "default:grass",
{ {
description = "Grass Clump", description = "Grass Clump",
@ -1351,7 +1351,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:tall_grass", "default:tall_grass",
{ {
description = "Tall Grass Clump", description = "Tall Grass Clump",
@ -1373,7 +1373,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_node( minetest.register_node(
"default:thistle", "default:thistle",
{ {
description = "Thistle", description = "Thistle",
@ -1395,7 +1395,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"default:apple", "default:apple",
{ {
description = "Apple", description = "Apple",
@ -1415,11 +1415,11 @@ core.register_node(
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
groups = {fleshy = 3, dig_immediate = 2, leafdecay = 3, leafdecay_drop = 1, attached_node = 1}, groups = {fleshy = 3, dig_immediate = 2, leafdecay = 3, leafdecay_drop = 1, attached_node = 1},
on_use = core.item_eat({hp = 2, sat = 10}), on_use = minetest.item_eat({hp = 2, sat = 10}),
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:clam", "default:clam",
{ {
description = "Clam", description = "Clam",
@ -1445,11 +1445,11 @@ core.register_node(
} }
}, },
groups = {fleshy = 3, oddly_breakable_by_hand = 2, choppy = 3, attached_node = 1}, groups = {fleshy = 3, oddly_breakable_by_hand = 2, choppy = 3, attached_node = 1},
on_use = core.item_eat({hp = 4, sat = 40}), on_use = minetest.item_eat({hp = 4, sat = 40}),
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
core.register_node( minetest.register_node(
"default:chest", "default:chest",
{ {
description = "Chest", description = "Chest",
@ -1460,7 +1460,7 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("default_chest")) meta:set_string("formspec", default.ui.get_page("default_chest"))
meta:set_string("infotext", "Chest") meta:set_string("infotext", "Chest")
@ -1468,12 +1468,12 @@ core.register_node(
inv:set_size("main", 8*4) inv:set_size("main", 8*4)
end, end,
can_dig = function(pos, player) can_dig = function(pos, player)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("main") return inv:is_empty("main")
end, end,
write_name = function(pos, text) write_name = function(pos, text)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if text ~= "" then if text ~= "" then
meta:set_string("infotext", text) meta:set_string("infotext", text)

View File

@ -8,7 +8,7 @@ local particlespawners = {}
local function step(dtime) local function step(dtime)
local player_positions = {} local player_positions = {}
for _, player in ipairs(core.get_connected_players()) do for _, player in ipairs(minetest.get_connected_players()) do
local player_pos=player:getpos() local player_pos=player:getpos()
local head_pos = player_pos local head_pos = player_pos
local name=player:get_player_name() local name=player:get_player_name()
@ -16,14 +16,14 @@ local function step(dtime)
if player_pos.x < -30000 or player_pos.x > 30000 if player_pos.x < -30000 or player_pos.x > 30000
or player_pos.y < -30000 or player_pos.y > 30000 or player_pos.y < -30000 or player_pos.y > 30000
or player_pos.z < -30000 or player_pos.z > 30000 then or player_pos.z < -30000 or player_pos.z > 30000 then
core.chat_send_player(name, core.colorize("#f00", "Don't go past 30000m in any direction!")) minetest.chat_send_player(name, core.colorize("#f00", "Don't go past 30000m in any direction!"))
player:setpos(player_lastpos[name]) player:setpos(player_lastpos[name])
end end
player_lastpos[name] = player:getpos() player_lastpos[name] = player:getpos()
if player:get_hp() < player_health[name] then if player:get_hp() < player_health[name] then
core.sound_play( minetest.sound_play(
"default_hurt", "default_hurt",
{ {
pos = player_pos, pos = player_pos,
@ -44,8 +44,8 @@ local function step(dtime)
player_lastsound[name] = player_lastsound[name] + dtime player_lastsound[name] = player_lastsound[name] + dtime
if core.get_item_group(core.get_node(head_pos).name, 'water') > 0 then if minetest.get_item_group(minetest.get_node(head_pos).name, 'water') > 0 then
particlespawners[name] = core.add_particlespawner( particlespawners[name] = minetest.add_particlespawner(
{ {
amount = 2, amount = 2,
time = 0.1, time = 0.1,
@ -62,12 +62,12 @@ local function step(dtime)
texture = "bubble.png" texture = "bubble.png"
}) })
core.after(0.15, function() core.delete_particlespawner(particlespawners[name]) end) minetest.after(0.15, function() minetest.delete_particlespawner(particlespawners[name]) end)
end end
if core.get_item_group(core.get_node(player_pos).name, 'water') > 0 then if minetest.get_item_group(minetest.get_node(player_pos).name, 'water') > 0 then
if player_lastsound[name] > 3.3 then if player_lastsound[name] > 3.3 then
player_soundspec[name]=core.sound_play( player_soundspec[name]=minetest.sound_play(
"default_water", "default_water",
{ {
pos = player_pos, pos = player_pos,
@ -77,17 +77,17 @@ local function step(dtime)
end end
else else
if player_soundspec[name] ~= nil then if player_soundspec[name] ~= nil then
core.sound_stop(player_soundspec[name]) minetest.sound_stop(player_soundspec[name])
player_lastsound[name] = 100 player_lastsound[name] = 100
end end
end end
local grass_pos=core.find_node_near(player_pos, 1, {"default:dirt_with_grass"}) local grass_pos=minetest.find_node_near(player_pos, 1, {"default:dirt_with_grass"})
if grass_pos ~= nil and math.random(1, 500) == 1 then if grass_pos ~= nil and math.random(1, 500) == 1 then
if grass_pos.x == player_pos.x and grass_pos.z == player_pos.z then if grass_pos.x == player_pos.x and grass_pos.z == player_pos.z then
core.set_node(grass_pos, {name = "default:dirt_with_grass_footsteps"}) minetest.set_node(grass_pos, {name = "default:dirt_with_grass_footsteps"})
end end
end end
@ -121,8 +121,8 @@ local function on_leaveplayer(player)
player_lastpos[name] = nil player_lastpos[name] = nil
end end
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer) minetest.register_on_leaveplayer(on_leaveplayer)
core.register_globalstep(step) minetest.register_globalstep(step)
default.log("player", "loaded") default.log("player", "loaded")

View File

@ -7,7 +7,7 @@ local creative_digtime=0.5
local tool_levels=nil local tool_levels=nil
-- Creative mode/hand defs -- Creative mode/hand defs
if core.setting_getbool("creative_mode") == true then if minetest.setting_getbool("creative_mode") == true then
tool_levels = { tool_levels = {
wood = { wood = {
crumbly = { crumbly = {
@ -99,7 +99,7 @@ if core.setting_getbool("creative_mode") == true then
}, },
} }
core.register_item( minetest.register_item(
":", ":",
{ {
type = "none", type = "none",
@ -204,7 +204,7 @@ else
}, },
} }
core.register_item( minetest.register_item(
":", ":",
{ {
type = "none", type = "none",
@ -229,7 +229,7 @@ end
-- "Creative" Tool -- "Creative" Tool
core.register_tool( minetest.register_tool(
"default:creative_tool", "default:creative_tool",
{ {
inventory_image = "default_creative_tool.png", inventory_image = "default_creative_tool.png",
@ -252,7 +252,7 @@ core.register_tool(
-- Pickaxes -- Pickaxes
core.register_tool( minetest.register_tool(
"default:pick_wood", "default:pick_wood",
{ {
description = "Wooden Pickaxe", description = "Wooden Pickaxe",
@ -266,7 +266,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:pick_stone", "default:pick_stone",
{ {
description = "Stone Pickaxe", description = "Stone Pickaxe",
@ -280,7 +280,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:pick_steel", "default:pick_steel",
{ {
description = "Steel Pickaxe", description = "Steel Pickaxe",
@ -294,7 +294,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:pick_carbonsteel", "default:pick_carbonsteel",
{ {
description = "Carbon Steel Pickaxe", description = "Carbon Steel Pickaxe",
@ -310,7 +310,7 @@ core.register_tool(
-- Shovels -- Shovels
core.register_tool( minetest.register_tool(
"default:shovel_wood", "default:shovel_wood",
{ {
description = "Wooden Shovel", description = "Wooden Shovel",
@ -324,7 +324,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:shovel_stone", "default:shovel_stone",
{ {
description = "Stone Shovel", description = "Stone Shovel",
@ -338,7 +338,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:shovel_steel", "default:shovel_steel",
{ {
description = "Steel Shovel", description = "Steel Shovel",
@ -352,7 +352,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:shovel_carbonsteel", "default:shovel_carbonsteel",
{ {
description = "Carbon Steel Shovel", description = "Carbon Steel Shovel",
@ -368,7 +368,7 @@ core.register_tool(
-- Axes -- Axes
core.register_tool( minetest.register_tool(
"default:axe_wood", "default:axe_wood",
{ {
description = "Wooden Axe", description = "Wooden Axe",
@ -383,7 +383,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:axe_stone", "default:axe_stone",
{ {
description = "Stone Axe", description = "Stone Axe",
@ -398,7 +398,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:axe_steel", "default:axe_steel",
{ {
description = "Steel Axe", description = "Steel Axe",
@ -413,7 +413,7 @@ core.register_tool(
}, },
}) })
core.register_tool( minetest.register_tool(
"default:axe_carbonsteel", "default:axe_carbonsteel",
{ {
description = "Carbon Steel Axe", description = "Carbon Steel Axe",
@ -430,7 +430,7 @@ core.register_tool(
-- Spears -- Spears
core.register_tool( minetest.register_tool(
"default:spear_wood", "default:spear_wood",
{ {
description = "Wooden Spear", description = "Wooden Spear",
@ -446,7 +446,7 @@ core.register_tool(
} }
}) })
core.register_tool( minetest.register_tool(
"default:spear_stone", "default:spear_stone",
{ {
description = "Stone Spear", description = "Stone Spear",
@ -462,7 +462,7 @@ core.register_tool(
} }
}) })
core.register_tool( minetest.register_tool(
"default:spear_steel", "default:spear_steel",
{ {
description = "Steel Spear", description = "Steel Spear",
@ -478,7 +478,7 @@ core.register_tool(
} }
}) })
core.register_tool( minetest.register_tool(
"default:spear_carbonsteel", "default:spear_carbonsteel",
{ {
description = "Carbon Steel Spear", description = "Carbon Steel Spear",
@ -496,7 +496,7 @@ core.register_tool(
-- Broadsword -- Broadsword
core.register_tool( minetest.register_tool(
"default:broadsword", "default:broadsword",
{ {
description = "Broadsword", description = "Broadsword",
@ -511,14 +511,14 @@ core.register_tool(
-- Other -- Other
core.register_tool( minetest.register_tool(
"default:shears", "default:shears",
{ {
description = "Steel Shears (Right-click to shear animals)", description = "Steel Shears (Right-click to shear animals)",
inventory_image = "default_shears.png", inventory_image = "default_shears.png",
}) })
core.register_tool( minetest.register_tool(
"default:flint_and_steel", "default:flint_and_steel",
{ {
description = "Flint and Steel", description = "Flint and Steel",
@ -528,17 +528,17 @@ core.register_tool(
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local pos = pointed_thing.under local pos = pointed_thing.under
local node = core.get_node(pos) local node = minetest.get_node(pos)
local nodename = node.name local nodename = node.name
if nodename == "default:torch_weak" then if nodename == "default:torch_weak" then
core.set_node(pos, {name = "default:torch", param = node.param, param2 = node.param2}) minetest.set_node(pos, {name = "default:torch", param = node.param, param2 = node.param2})
itemstack:add_wear(800) itemstack:add_wear(800)
elseif nodename == "default:torch_dead" then elseif nodename == "default:torch_dead" then
core.set_node(pos, {name = "default:torch_weak", param = node.param, param2 = node.param2}) minetest.set_node(pos, {name = "default:torch_weak", param = node.param, param2 = node.param2})
itemstack:add_wear(800) itemstack:add_wear(800)
elseif nodename == "tnt:tnt" then elseif nodename == "tnt:tnt" then
local y = core.registered_nodes["tnt:tnt"] local y = minetest.registered_nodes["tnt:tnt"]
if y ~= nil then if y ~= nil then
y.on_punch(pos, node, user) y.on_punch(pos, node, user)

View File

@ -32,7 +32,7 @@ function door.register_door(name, def)
end end
core.register_craftitem( minetest.register_craftitem(
name, { name, {
description = def.description, description = def.description,
inventory_image = def.inventory_image, inventory_image = def.inventory_image,
@ -45,24 +45,24 @@ function door.register_door(name, def)
end end
local ptu = pointed_thing.under local ptu = pointed_thing.under
local nu = core.get_node(ptu) local nu = minetest.get_node(ptu)
if core.registered_nodes[nu.name].on_rightclick then if minetest.registered_nodes[nu.name].on_rightclick then
return core.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack) return minetest.registered_nodes[nu.name].on_rightclick(ptu, nu, placer, itemstack)
end end
local pt = pointed_thing.above local pt = pointed_thing.above
local pt2 = {x=pt.x, y=pt.y, z=pt.z} local pt2 = {x=pt.x, y=pt.y, z=pt.z}
pt2.y = pt2.y+1 pt2.y = pt2.y+1
if if
not core.registered_nodes[core.get_node(pt).name].buildable_to or not minetest.registered_nodes[minetest.get_node(pt).name].buildable_to or
not core.registered_nodes[core.get_node(pt2).name].buildable_to or not minetest.registered_nodes[minetest.get_node(pt2).name].buildable_to or
not placer or not placer or
not placer:is_player() not placer:is_player()
then then
return itemstack return itemstack
end end
local p2 = core.dir_to_facedir(placer:get_look_dir()) local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pt3 = {x=pt.x, y=pt.y, z=pt.z} local pt3 = {x=pt.x, y=pt.y, z=pt.z}
if p2 == 0 then if p2 == 0 then
pt3.x = pt3.x-1 pt3.x = pt3.x-1
@ -73,14 +73,14 @@ function door.register_door(name, def)
elseif p2 == 3 then elseif p2 == 3 then
pt3.z = pt3.z-1 pt3.z = pt3.z-1
end end
if core.get_item_group(core.get_node(pt3).name, "door") == 0 then if minetest.get_item_group(minetest.get_node(pt3).name, "door") == 0 then
core.set_node(pt, {name=name.."_b_1", param2=p2}) minetest.set_node(pt, {name=name.."_b_1", param2=p2})
core.set_node(pt2, {name=name.."_t_1", param2=p2}) minetest.set_node(pt2, {name=name.."_t_1", param2=p2})
else else
core.set_node(pt, {name=name.."_b_2", param2=p2}) minetest.set_node(pt, {name=name.."_b_2", param2=p2})
core.set_node(pt2, {name=name.."_t_2", param2=p2}) minetest.set_node(pt2, {name=name.."_t_2", param2=p2})
core.get_meta(pt):set_int("right", 1) minetest.get_meta(pt):set_int("right", 1)
core.get_meta(pt2):set_int("right", 1) minetest.get_meta(pt2):set_int("right", 1)
end end
itemstack:take_item() itemstack:take_item()
@ -93,24 +93,24 @@ function door.register_door(name, def)
local tb = def.tiles_bottom local tb = def.tiles_bottom
local function after_dig_node(pos, name, digger) local function after_dig_node(pos, name, digger)
local node = core.get_node(pos) local node = minetest.get_node(pos)
if node.name == name then if node.name == name then
core.node_dig(pos, node, digger) minetest.node_dig(pos, node, digger)
end end
end end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir pos.y = pos.y+dir
if not core.get_node(pos).name == check_name then if not minetest.get_node(pos).name == check_name then
return return
end end
local p2 = core.get_node(pos).param2 local p2 = minetest.get_node(pos).param2
p2 = params[p2+1] p2 = params[p2+1]
core.swap_node(pos, {name=replace_dir, param2=p2}) minetest.swap_node(pos, {name=replace_dir, param2=p2})
pos.y = pos.y-dir pos.y = pos.y-dir
core.swap_node(pos, {name=replace, param2=p2}) minetest.swap_node(pos, {name=replace, param2=p2})
local snd_1 = def.sound_close_door local snd_1 = def.sound_close_door
local snd_2 = def.sound_open_door local snd_2 = def.sound_open_door
@ -119,10 +119,10 @@ function door.register_door(name, def)
snd_2 = def.sound_close_door snd_2 = def.sound_close_door
end end
if core.get_meta(pos):get_int("right") ~= 0 then if minetest.get_meta(pos):get_int("right") ~= 0 then
core.sound_play(snd_1, {pos = pos, gain = 0.8, max_hear_distance = 10}) minetest.sound_play(snd_1, {pos = pos, gain = 0.8, max_hear_distance = 10})
else else
core.sound_play(snd_2, {pos = pos, gain = 0.8, max_hear_distance = 10}) minetest.sound_play(snd_2, {pos = pos, gain = 0.8, max_hear_distance = 10})
end end
end end
@ -130,11 +130,11 @@ function door.register_door(name, def)
if not def.only_placer_can_open then if not def.only_placer_can_open then
return true return true
end end
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local pn = player:get_player_name() local pn = player:get_player_name()
end end
core.register_node( minetest.register_node(
name.."_b_1", name.."_b_1",
{ {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"}, tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"},
@ -168,7 +168,7 @@ function door.register_door(name, def)
sunlight_propagates = def.sunlight sunlight_propagates = def.sunlight
}) })
core.register_node( minetest.register_node(
name.."_t_1", name.."_t_1",
{ {
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1], tt[1].."^[transformfx"}, tiles = {tt[2], tt[2], tt[2], tt[2], tt[1], tt[1].."^[transformfx"},
@ -202,7 +202,7 @@ function door.register_door(name, def)
sunlight_propagates = def.sunlight, sunlight_propagates = def.sunlight,
}) })
core.register_node( minetest.register_node(
name.."_b_2", name.."_b_2",
{ {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1].."^[transformfx", tb[1]}, tiles = {tb[2], tb[2], tb[2], tb[2], tb[1].."^[transformfx", tb[1]},
@ -236,7 +236,7 @@ function door.register_door(name, def)
sunlight_propagates = def.sunlight sunlight_propagates = def.sunlight
}) })
core.register_node( minetest.register_node(
name.."_t_2", name.."_t_2",
{ {
tiles = {tt[2], tt[2], tt[2], tt[2], tt[1].."^[transformfx", tt[1]}, tiles = {tt[2], tt[2], tt[2], tt[2], tt[1].."^[transformfx", tt[1]},
@ -284,7 +284,7 @@ door.register_door(
sunlight = false, sunlight = false,
}) })
core.register_craft( minetest.register_craft(
{ {
output = "door:door_wood", output = "door:door_wood",
recipe = { recipe = {
@ -306,7 +306,7 @@ door.register_door(
sunlight = false, sunlight = false,
}) })
core.register_craft( minetest.register_craft(
{ {
output = "door:door_stone", output = "door:door_stone",
recipe = { recipe = {

View File

@ -3,7 +3,7 @@
-- By Kaadmy, for Pixture -- By Kaadmy, for Pixture
-- --
local enable_drop = core.setting_getbool("drop_items_on_die") or false local enable_drop = minetest.setting_getbool("drop_items_on_die") or false
local function on_die(player) local function on_die(player)
local pos = player:getpos() local pos = player:getpos()
@ -19,7 +19,7 @@ local function on_die(player)
z = pos.z + math.random(-0.3, 0.3) z = pos.z + math.random(-0.3, 0.3)
} }
local drop = core.add_item(rpos, item) local drop = minetest.add_item(rpos, item)
if drop ~= nil then if drop ~= nil then
local x = math.random(1, 5) local x = math.random(1, 5)
@ -39,7 +39,7 @@ local function on_die(player)
end end
if enable_drop then if enable_drop then
core.register_on_dieplayer(on_die) minetest.register_on_dieplayer(on_die)
end end
default.log("mod:drop_items_on_die", "loaded") default.log("mod:drop_items_on_die", "loaded")

View File

@ -1,33 +1,33 @@
core.register_craftitem( minetest.register_craftitem(
"farming:cotton", "farming:cotton",
{ {
description = "Cotton", description = "Cotton",
inventory_image = "farming_cotton.png" inventory_image = "farming_cotton.png"
}) })
core.register_craftitem( minetest.register_craftitem(
"farming:wheat", "farming:wheat",
{ {
description = "Wheat", description = "Wheat",
inventory_image = "farming_wheat.png" inventory_image = "farming_wheat.png"
}) })
core.register_craftitem( minetest.register_craftitem(
"farming:flour", "farming:flour",
{ {
description = "Flour", description = "Flour",
inventory_image = "farming_flour.png" inventory_image = "farming_flour.png"
}) })
core.register_craftitem( minetest.register_craftitem(
"farming:bread", "farming:bread",
{ {
description = "Bread", description = "Bread",
inventory_image = "farming_bread.png", inventory_image = "farming_bread.png",
on_use = core.item_eat({hp = 4, sat = 40}) on_use = minetest.item_eat({hp = 4, sat = 40})
}) })
core.register_craft( minetest.register_craft(
{ {
output = "farming:flour", output = "farming:flour",
recipe = { recipe = {
@ -36,7 +36,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
output = "farming:cotton_bale 2", output = "farming:cotton_bale 2",
recipe = { recipe = {
@ -45,7 +45,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "farming:bread", output = "farming:bread",

View File

@ -6,26 +6,26 @@
farming = {} farming = {}
function farming.grow_plant(pos, name, plant) function farming.grow_plant(pos, name, plant)
local my_node = core.get_node(pos) local my_node = minetest.get_node(pos)
if core.find_node_near(pos, plant.growing_distance, plant.grows_near) == nil then return end if minetest.find_node_near(pos, plant.growing_distance, plant.grows_near) == nil then return end
local light = core.get_node_light(pos) local light = minetest.get_node_light(pos)
if light ~= nil and (light < plant.light_min or light > plant.light_max) then return end if light ~= nil and (light < plant.light_min or light > plant.light_max) then return end
local on_node = core.get_node({x = pos.x, y = pos.y-1, z = pos.z}) local on_node = minetest.get_node({x = pos.x, y = pos.y-1, z = pos.z})
local on_nodedef = core.registered_nodes[on_node.name] local on_nodedef = minetest.registered_nodes[on_node.name]
for _, can_grow_on in ipairs(plant.grows_on) do for _, can_grow_on in ipairs(plant.grows_on) do
local group = string.match(can_grow_on, "group:(.*)") local group = string.match(can_grow_on, "group:(.*)")
if (group ~= nil and on_nodedef.groups[group]) or (on_node.name == can_grow_on) then if (group ~= nil and on_nodedef.groups[group]) or (on_node.name == can_grow_on) then
if my_node.name == "farming:"..name.."_1" then if my_node.name == "farming:"..name.."_1" then
core.set_node(pos, {name = "farming:"..name.."_2"}) minetest.set_node(pos, {name = "farming:"..name.."_2"})
elseif my_node.name == "farming:"..name.."_2" then elseif my_node.name == "farming:"..name.."_2" then
core.set_node(pos, {name = "farming:"..name.."_3"}) minetest.set_node(pos, {name = "farming:"..name.."_3"})
elseif my_node.name == "farming:"..name.."_3" then elseif my_node.name == "farming:"..name.."_3" then
core.set_node(pos, {name = "farming:"..name.."_4"}) minetest.set_node(pos, {name = "farming:"..name.."_4"})
end end
break break
@ -39,7 +39,7 @@ function farming.register_plant(name, plant)
-- --
-- format: "farming:[plant name]_[stage from 1-4]" -- format: "farming:[plant name]_[stage from 1-4]"
core.register_abm( minetest.register_abm(
{ {
nodenames = { nodenames = {
"farming:"..name.."_1", "farming:"..name.."_1",
@ -52,7 +52,7 @@ function farming.register_plant(name, plant)
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
farming.grow_plant(pos, name, plant) farming.grow_plant(pos, name, plant)
local underdef = core.registered_nodes[core.get_node({x = pos.x, y = pos.y-1, z = pos.z}).name] local underdef = minetest.registered_nodes[minetest.get_node({x = pos.x, y = pos.y-1, z = pos.z}).name]
if underdef.groups and underdef.groups.plantable_fertilizer then if underdef.groups and underdef.groups.plantable_fertilizer then
print("Fertilizer!") print("Fertilizer!")
@ -66,8 +66,8 @@ function farming.register_plant(name, plant)
}) })
end end
dofile(core.get_modpath("farming").."/nodes.lua") dofile(minetest.get_modpath("farming").."/nodes.lua")
dofile(core.get_modpath("farming").."/plants.lua") dofile(minetest.get_modpath("farming").."/plants.lua")
dofile(core.get_modpath("farming").."/craft.lua") dofile(minetest.get_modpath("farming").."/craft.lua")
default.log("mod:farming", "loaded") default.log("mod:farming", "loaded")

View File

@ -1,4 +1,4 @@
core.register_node( minetest.register_node(
"farming:wheat_1", "farming:wheat_1",
{ {
description = "Wheat Seed", description = "Wheat Seed",
@ -24,7 +24,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:wheat_2", "farming:wheat_2",
{ {
description = "Wheat", description = "Wheat",
@ -48,7 +48,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:wheat_3", "farming:wheat_3",
{ {
description = "Wheat", description = "Wheat",
@ -72,7 +72,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:wheat_4", "farming:wheat_4",
{ {
description = "Wheat", description = "Wheat",
@ -99,7 +99,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:cotton_1", "farming:cotton_1",
{ {
description = "Cotton Seed", description = "Cotton Seed",
@ -125,7 +125,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:cotton_2", "farming:cotton_2",
{ {
description = "Cotton", description = "Cotton",
@ -149,7 +149,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:cotton_3", "farming:cotton_3",
{ {
description = "Cotton", description = "Cotton",
@ -173,7 +173,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:cotton_4", "farming:cotton_4",
{ {
description = "Cotton", description = "Cotton",
@ -200,7 +200,7 @@ core.register_node(
local name = player:get_wielded_item():get_name() local name = player:get_wielded_item():get_name()
if name == "default:shears" then if name == "default:shears" then
core.set_node(pos, {name = "farming:cotton_3"}) minetest.set_node(pos, {name = "farming:cotton_3"})
for i = 1, 2 do for i = 1, 2 do
if math.random(1, 2) == 1 then if math.random(1, 2) == 1 then
@ -218,7 +218,7 @@ core.register_node(
z = pos.z + math.random(-0.3, 0.3) z = pos.z + math.random(-0.3, 0.3)
} }
local drop = core.add_item(rpos, item) local drop = minetest.add_item(rpos, item)
if drop ~= nil then if drop ~= nil then
local x = math.random(1, 5) local x = math.random(1, 5)
@ -238,7 +238,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults() sounds=default.node_sound_leaves_defaults()
}) })
core.register_node( minetest.register_node(
"farming:cotton_bale", "farming:cotton_bale",
{ {
description = "Cotton Bale", description = "Cotton Bale",
@ -248,7 +248,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })
core.register_alias("farming:cotton_seed", "farming:cotton_1") minetest.register_alias("farming:cotton_seed", "farming:cotton_1")
core.register_alias("farming:wheat_seed", "farming:wheat_1") minetest.register_alias("farming:wheat_seed", "farming:wheat_1")
default.log("nodes", "loaded") default.log("nodes", "loaded")

View File

@ -3,7 +3,7 @@
-- By Kaadmy, for Pixture -- By Kaadmy, for Pixture
-- --
local giveme = core.setting_getbool("give_initial_stuff") local giveme = minetest.setting_getbool("give_initial_stuff")
local function give_initial_stuff(player) local function give_initial_stuff(player)
if giveme then if giveme then
@ -14,6 +14,6 @@ local function give_initial_stuff(player)
end end
end end
core.register_on_newplayer(give_initial_stuff) minetest.register_on_newplayer(give_initial_stuff)
default.log("mod:give_initial_stuff", "loaded") default.log("mod:give_initial_stuff", "loaded")

View File

@ -5,12 +5,12 @@
gold = {} gold = {}
gold.pr = PseudoRandom(core.get_mapgen_params().seed+8732) gold.pr = PseudoRandom(minetest.get_mapgen_params().seed+8732)
gold.trades = {} gold.trades = {}
gold.trade_names = {} gold.trade_names = {}
if core.get_modpath("mobs") ~= nil then if minetest.get_modpath("mobs") ~= nil then
gold.trades["farmer"] = { gold.trades["farmer"] = {
-- plants -- plants
{"gold:gold", "", "farming:wheat_1 6"}, {"gold:gold", "", "farming:wheat_1 6"},
@ -95,7 +95,7 @@ if core.get_modpath("mobs") ~= nil then
} }
-- trading currency -- trading currency
if core.get_modpath("jewels") ~= nil then -- jewels/gold if minetest.get_modpath("jewels") ~= nil then -- jewels/gold
--farmer --farmer
table.insert(gold.trades["farmer"], {"gold:gold 16", "", "jewels:jewel"}) table.insert(gold.trades["farmer"], {"gold:gold 16", "", "jewels:jewel"})
table.insert(gold.trades["farmer"], {"gold:gold 22", "", "jewels:jewel 2"}) table.insert(gold.trades["farmer"], {"gold:gold 22", "", "jewels:jewel 2"})
@ -177,7 +177,7 @@ function gold.trade(trade, trade_type, player)
inv:set_stack("gold_trade_wanted", 1, trade[1]) inv:set_stack("gold_trade_wanted", 1, trade[1])
inv:set_stack("gold_trade_wanted", 2, trade[2]) inv:set_stack("gold_trade_wanted", 2, trade[2])
local meta = core.deserialize(item:get_metadata()) local meta = minetest.deserialize(item:get_metadata())
if not meta then meta = {} end if not meta then meta = {} end
meta.trade = trade meta.trade = trade
@ -188,23 +188,23 @@ function gold.trade(trade, trade_type, player)
local trade_wanted2 = inv:get_stack("gold_trade_wanted", 2) local trade_wanted2 = inv:get_stack("gold_trade_wanted", 2)
local form = default.ui.get_page("gold_trading_book") local form = default.ui.get_page("gold_trading_book")
form = form .. "label[0.25,0.25;"..core.formspec_escape(trade_name).."]" form = form .. "label[0.25,0.25;"..minetest.formspec_escape(trade_name).."]"
form = form .. default.ui.fake_itemstack(1.25, 1.25, trade_wanted1, "trade_wanted1") form = form .. default.ui.fake_itemstack(1.25, 1.25, trade_wanted1, "trade_wanted1")
form = form .. default.ui.fake_itemstack(1.25, 2.25, trade_wanted2, "trade_wanted2") form = form .. default.ui.fake_itemstack(1.25, 2.25, trade_wanted2, "trade_wanted2")
form = form .. default.ui.fake_itemstack(3.75, 1.25, ItemStack(trade[3]), "vistrade_result") form = form .. default.ui.fake_itemstack(3.75, 1.25, ItemStack(trade[3]), "vistrade_result")
core.show_formspec(name, "gold:trading_book", form) minetest.show_formspec(name, "gold:trading_book", form)
meta.trade_type = trade_type meta.trade_type = trade_type
item:set_metadata(core.serialize(meta)) item:set_metadata(minetest.serialize(meta))
player:set_wielded_item(item) player:set_wielded_item(item)
return true return true
end end
core.register_on_player_receive_fields( minetest.register_on_player_receive_fields(
function(player, form_name, fields) function(player, form_name, fields)
if form_name ~= "gold:trading_book" or fields.cancel then return end if form_name ~= "gold:trading_book" or fields.cancel then return end
@ -221,7 +221,7 @@ core.register_on_player_receive_fields(
local matches = trade_wanted1 == trade_in1 and trade_wanted2 == trade_in2 local matches = trade_wanted1 == trade_in1 and trade_wanted2 == trade_in2
local meta = core.deserialize(item:get_metadata()) local meta = minetest.deserialize(item:get_metadata())
local trade = {"gold:gold", "gold:gold", "default:stick"} local trade = {"gold:gold", "gold:gold", "default:stick"}
local trade_type = "" local trade_type = ""
@ -241,7 +241,7 @@ core.register_on_player_receive_fields(
end end
end) end)
core.register_craftitem( minetest.register_craftitem(
"gold:trading_book", "gold:trading_book",
{ {
description = "Trading Book", description = "Trading Book",
@ -249,7 +249,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"gold:gold", "gold:gold",
{ {
description = "Gold", description = "Gold",
@ -257,16 +257,16 @@ core.register_craftitem(
stack_max = 120 stack_max = 120
}) })
core.register_craft( minetest.register_craft(
{ {
output = "gold:trading_book", output = "gold:trading_book",
type = "shapeless", type = "shapeless",
recipe = {"default:book", "gold:gold"} recipe = {"default:book", "gold:gold"}
}) })
core.register_alias("gold", "gold:gold") minetest.register_alias("gold", "gold:gold")
core.register_node( minetest.register_node(
"gold:ore", "gold:ore",
{ {
description = "Gold Ore", description = "Gold Ore",
@ -277,7 +277,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "gold:ore", ore = "gold:ore",

View File

@ -27,7 +27,7 @@ goodies.types["FURNACE_DST"] = {
} }
-- chunk types for villages -- chunk types for villages
if core.get_modpath("village") ~= nil then if minetest.get_modpath("village") ~= nil then
goodies.types["forge"] = { goodies.types["forge"] = {
["default:ingot_steel"] = 10, ["default:ingot_steel"] = 10,
["default:lump_coal"] = 4, ["default:lump_coal"] = 4,
@ -55,13 +55,13 @@ if core.get_modpath("village") ~= nil then
} }
-- jewels and gold -- jewels and gold
if core.get_modpath("jewels") ~= nil then if minetest.get_modpath("jewels") ~= nil then
goodies.types["house"]["jewels:bench"] = 24 -- jeweling benches goodies.types["house"]["jewels:bench"] = 24 -- jeweling benches
goodies.types["house"]["jewels:jewel"] = 34 goodies.types["house"]["jewels:jewel"] = 34
goodies.types["tavern"]["jewels:jewel"] = 32 goodies.types["tavern"]["jewels:jewel"] = 32
goodies.types["forge"]["jewels:jewel"] = 30 goodies.types["forge"]["jewels:jewel"] = 30
end end
if core.get_modpath("gold") ~= nil then if minetest.get_modpath("gold") ~= nil then
goodies.types["house"]["gold:gold"] = 12 goodies.types["house"]["gold:gold"] = 12
goodies.types["tavern"]["gold:gold"] = 10 goodies.types["tavern"]["gold:gold"] = 10
goodies.types["forge"]["gold:gold"] = 8 goodies.types["forge"]["gold:gold"] = 8
@ -74,11 +74,11 @@ function goodies.fill(pos, ctype, pr, listname, keepchance)
if goodies.types[ctype] == nil then return end if goodies.types[ctype] == nil then return end
if pr:next(1, keepchance) ~= 1 then if pr:next(1, keepchance) ~= 1 then
core.remove_node(pos) minetest.remove_node(pos)
return return
end end
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local size = inv:get_size(listname) local size = inv:get_size(listname)

View File

@ -5,12 +5,12 @@
headbars = {} headbars = {}
local enable_damage = core.setting_getbool("enable_damage") local enable_damage = minetest.setting_getbool("enable_damage")
local enable_headbars = core.setting_getbool("headbars_enable") local enable_headbars = minetest.setting_getbool("headbars_enable")
if enable_headbars == nil then enable_headbars = true end if enable_headbars == nil then enable_headbars = true end
local headbars_scale = tonumber(core.setting_get("headbars_scale")) or 1.0 local headbars_scale = tonumber(minetest.setting_get("headbars_scale")) or 1.0
function headbars.get_sprite(icon, background, max, amt) function headbars.get_sprite(icon, background, max, amt)
local img = "[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:0,0=ui_null.png" local img = "[combine:" .. (max * 8) .. "x16:0,0=ui_null.png:0,0=ui_null.png"
@ -37,7 +37,7 @@ function headbars.get_sprite(icon, background, max, amt)
return img return img
end end
core.register_entity( minetest.register_entity(
"headbars:hpbar", "headbars:hpbar",
{ {
visual = "sprite", visual = "sprite",
@ -50,7 +50,7 @@ core.register_entity(
on_step = function(self, dtime) on_step = function(self, dtime)
local ent = self.wielder local ent = self.wielder
if ent == nil or (core.get_player_by_name(ent:get_player_name(0)) == nil) then if ent == nil or (minetest.get_player_by_name(ent:get_player_name(0)) == nil) then
self.object:remove() self.object:remove()
return return
end end
@ -66,7 +66,7 @@ function headbars.attach_hpbar(to)
if not enable_headbars then return end if not enable_headbars then return end
local pos = to:getpos() local pos = to:getpos()
local bar = core.add_entity(pos, "headbars:hpbar") local bar = minetest.add_entity(pos, "headbars:hpbar")
if bar == nil then return end if bar == nil then return end
@ -78,5 +78,5 @@ function headbars.attach_hpbar(to)
bar.wielder = to bar.wielder = to
end end
core.register_on_joinplayer(headbars.attach_hpbar) minetest.register_on_joinplayer(headbars.attach_hpbar)
default.log("mod:headbars", "loaded") default.log("mod:headbars", "loaded")

View File

@ -15,8 +15,8 @@ local particlespawners = {}
local player_step = {} local player_step = {}
local player_health_step = {} local player_health_step = {}
local player_bar = {} local player_bar = {}
local base_interval = tonumber(core.setting_get("hunger_step")) or 3.0 -- seconds per hunger update, 2.0 is slightly fast local base_interval = tonumber(minetest.setting_get("hunger_step")) or 3.0 -- seconds per hunger update, 2.0 is slightly fast
local file = core.get_worldpath() .. "/hunger" local file = minetest.get_worldpath() .. "/hunger"
function hunger.save_hunger() function hunger.save_hunger()
local output = io.open(file, "w") local output = io.open(file, "w")
@ -44,7 +44,7 @@ local function load_hunger()
hunger.hunger[name] = hnger hunger.hunger[name] = hnger
hunger.saturation[name] = sat hunger.saturation[name] = sat
-- core.log("action", name.." has "..hnger.." hunger and is saturated to "..sat.."%") -- minetest.log("action", name.." has "..hnger.." hunger and is saturated to "..sat.."%")
until input:read(0) == nil until input:read(0) == nil
io.close(input) io.close(input)
else else
@ -73,7 +73,7 @@ function hunger.update_bar(player)
end end
end end
if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable") then if minetest.setting_getbool("enable_damage") and minetest.setting_getbool("hunger_enable") then
player_effects.register_effect( player_effects.register_effect(
"hunger_eating", "hunger_eating",
{ {
@ -86,21 +86,21 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
}) })
-- Prevent players from starving while afk (<--joke) -- Prevent players from starving while afk (<--joke)
core.register_on_dignode( minetest.register_on_dignode(
function(pos, oldnode, player) function(pos, oldnode, player)
if not player then return end if not player then return end
local name = player:get_player_name() local name = player:get_player_name()
hunger.active[name] = hunger.active[name]+ 2 hunger.active[name] = hunger.active[name]+ 2
end) end)
core.register_on_placenode( minetest.register_on_placenode(
function(pos, node, player) function(pos, node, player)
if not player then return end if not player then return end
local name = player:get_player_name() local name = player:get_player_name()
hunger.active[name] = hunger.active[name]+ 2 hunger.active[name] = hunger.active[name]+ 2
end) end)
core.register_on_joinplayer( minetest.register_on_joinplayer(
function(player) function(player)
local name = player:get_player_name() local name = player:get_player_name()
if not hunger.hunger[name] then hunger.hunger[name] = 20 end if not hunger.hunger[name] then hunger.hunger[name] = 20 end
@ -118,13 +118,13 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
hunger.update_bar(player) hunger.update_bar(player)
end) end)
core.register_on_leaveplayer( minetest.register_on_leaveplayer(
function(player) function(player)
local name = player:get_player_name() local name = player:get_player_name()
player_bar[name] = nil player_bar[name] = nil
end) end)
core.register_on_respawnplayer( minetest.register_on_respawnplayer(
function(player) function(player)
local name = player:get_player_name() local name = player:get_player_name()
hunger.hunger[name] = 20 hunger.hunger[name] = 20
@ -132,7 +132,7 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
hunger.save_hunger() hunger.save_hunger()
end) end)
core.register_on_item_eat( minetest.register_on_item_eat(
function(hpdata, replace_with_item, itemstack, player, pointed_thing) function(hpdata, replace_with_item, itemstack, player, pointed_thing)
if not player then return end if not player then return end
if not hpdata then return end if not hpdata then return end
@ -161,9 +161,9 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
local headpos = player:getpos() local headpos = player:getpos()
headpos.y = headpos.y + 1 headpos.y = headpos.y + 1
core.sound_play("hunger_eat", {pos = headpos, max_hear_distance = 8}) minetest.sound_play("hunger_eat", {pos = headpos, max_hear_distance = 8})
particlespawners[name] = core.add_particlespawner( particlespawners[name] = minetest.add_particlespawner(
{ {
amount = 10, amount = 10,
time = 0.1, time = 0.1,
@ -180,7 +180,7 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
texture = "magicpuff.png" texture = "magicpuff.png"
}) })
core.after(0.15, function() core.delete_particlespawner(particlespawners[name]) end) minetest.after(0.15, function() minetest.delete_particlespawner(particlespawners[name]) end)
player_effects.apply_effect(player, "hunger_eating") player_effects.apply_effect(player, "hunger_eating")
@ -194,9 +194,9 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
-- Main function -- Main function
local timer = 0 local timer = 0
core.register_globalstep( minetest.register_globalstep(
function(dtime) function(dtime)
for _,player in ipairs(core.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local controls = player:get_player_control() local controls = player:get_player_control()
local moving = 0 local moving = 0
@ -227,7 +227,7 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
if timer < base_interval then return end if timer < base_interval then return end
timer = 0 timer = 0
for _,player in ipairs(core.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local hp = player:get_hp() local hp = player:get_hp()
@ -254,7 +254,7 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
hunger.hunger[name] = 0 hunger.hunger[name] = 0
local pos_sound = player:getpos() local pos_sound = player:getpos()
core.chat_send_player(name, "You are hungry.") minetest.chat_send_player(name, "You are hungry.")
end end
end end
end end
@ -274,11 +274,11 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
hunger.save_hunger() hunger.save_hunger()
end) end)
else else
core.register_on_item_eat( minetest.register_on_item_eat(
function(hpdata, replace_with_item, itemstack, player, pointed_thing) function(hpdata, replace_with_item, itemstack, player, pointed_thing)
local headpos = player:getpos() local headpos = player:getpos()
headpos.y = headpos.y + 1 headpos.y = headpos.y + 1
core.sound_play("hunger_eat", {pos = headpos, max_hear_distance = 8}) minetest.sound_play("hunger_eat", {pos = headpos, max_hear_distance = 8})
itemstack:take_item(1) itemstack:take_item(1)

View File

@ -8,14 +8,14 @@ local function valid(object)
return object:get_luaentity().timer ~= nil and object:get_luaentity().timer > 1 return object:get_luaentity().timer ~= nil and object:get_luaentity().timer > 1
end end
core.register_globalstep( minetest.register_globalstep(
function(dtime) function(dtime)
for _,player in ipairs(core.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
if player:get_hp() > 0 or not core.setting_getbool("enable_damage") then if player:get_hp() > 0 or not minetest.setting_getbool("enable_damage") then
local pos = player:getpos() local pos = player:getpos()
local inv = player:get_inventory() local inv = player:get_inventory()
for _,object in ipairs(core.get_objects_inside_radius(pos, 1.35)) do for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1.35)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and valid(object) then if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and valid(object) then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
local pos1 = pos local pos1 = pos
@ -42,7 +42,7 @@ core.register_globalstep(
if inv:room_for_item("main", ItemStack(lua.itemstring)) then if inv:room_for_item("main", ItemStack(lua.itemstring)) then
inv:add_item("main", ItemStack(lua.itemstring)) inv:add_item("main", ItemStack(lua.itemstring))
if lua.itemstring ~= "" then if lua.itemstring ~= "" then
core.sound_play("item_drop_pickup", {pos = pos, gain = 0.3, max_hear_distance = 16}) minetest.sound_play("item_drop_pickup", {pos = pos, gain = 0.3, max_hear_distance = 16})
end end
lua.itemstring = "" lua.itemstring = ""
object:remove() object:remove()
@ -62,7 +62,7 @@ core.register_globalstep(
end end
end) end)
function core.handle_node_drops(pos, drops, digger) function minetest.handle_node_drops(pos, drops, digger)
for _,item in ipairs(drops) do for _,item in ipairs(drops) do
local count, name local count, name
if type(item) == "string" then if type(item) == "string" then
@ -73,7 +73,7 @@ function core.handle_node_drops(pos, drops, digger)
name = item:get_name() name = item:get_name()
end end
for i=1,count do for i=1,count do
local obj = core.add_item(pos, name) local obj = minetest.add_item(pos, name)
if obj ~= nil then if obj ~= nil then
local x = math.random(1, 5) local x = math.random(1, 5)
if math.random(1,2) == 1 then if math.random(1,2) == 1 then
@ -86,8 +86,8 @@ function core.handle_node_drops(pos, drops, digger)
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z}) obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
-- FIXME this doesnt work for deactiveted objects -- FIXME this doesnt work for deactiveted objects
if core.setting_get("remove_items") and tonumber(core.setting_get("remove_items")) then if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
core.after(tonumber(core.setting_get("remove_items")), function(obj) minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
obj:remove() obj:remove()
end, obj) end, obj)
end end

View File

@ -33,7 +33,7 @@ function jewels.register_jewel(toolname, new_toolname, def)
end end
table.insert(jewels.registered_jewels[toolname], data) table.insert(jewels.registered_jewels[toolname], data)
local tooldef = core.deserialize(core.serialize(core.registered_tools[toolname])) local tooldef = minetest.deserialize(minetest.serialize(minetest.registered_tools[toolname]))
local new_tool_invimage = "" local new_tool_invimage = ""
if tooldef.inventory_image then if tooldef.inventory_image then
@ -101,7 +101,7 @@ function jewels.register_jewel(toolname, new_toolname, def)
new_tooldef.description = desc new_tooldef.description = desc
core.register_tool(new_toolname, new_tooldef) minetest.register_tool(new_toolname, new_tooldef)
end end
function jewels.can_jewel(toolname) function jewels.can_jewel(toolname)
@ -122,7 +122,7 @@ function jewels.get_jeweled(toolname)
end end
end end
core.register_craftitem( minetest.register_craftitem(
"jewels:jewel", "jewels:jewel",
{ {
description = "Jewel", description = "Jewel",
@ -130,7 +130,7 @@ core.register_craftitem(
stack_max = 10 stack_max = 10
}) })
core.register_node( minetest.register_node(
"jewels:bench", "jewels:bench",
{ {
description = "Jewelers Workbench", description = "Jewelers Workbench",
@ -141,7 +141,7 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("jewels_bench")) meta:set_string("formspec", default.ui.get_page("jewels_bench"))
meta:set_string("infotext", "Jewelers Workbench") meta:set_string("infotext", "Jewelers Workbench")
@ -149,7 +149,7 @@ core.register_node(
inv:set_size("main", 1) inv:set_size("main", 1)
end, end,
can_dig = function(pos, player) can_dig = function(pos, player)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("main") return inv:is_empty("main")
@ -158,7 +158,7 @@ core.register_node(
local itemstack = player:get_wielded_item() local itemstack = player:get_wielded_item()
if itemstack:get_name() == "jewels:jewel" then if itemstack:get_name() == "jewels:jewel" then
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local itemname = inv:get_stack("main", 1):get_name() local itemname = inv:get_stack("main", 1):get_name()
@ -177,7 +177,7 @@ core.register_node(
end, end,
}) })
core.register_craft( minetest.register_craft(
{ {
output = "jewels:bench", output = "jewels:bench",
recipe = { recipe = {
@ -201,7 +201,7 @@ form_bench = form_bench .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
form_bench = form_bench .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) form_bench = form_bench .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
default.ui.register_page("jewels_bench", form_bench) default.ui.register_page("jewels_bench", form_bench)
core.register_node( minetest.register_node(
"jewels:jewel_ore", "jewels:jewel_ore",
{ {
description = "Jewel Ore", description = "Jewel Ore",
@ -212,7 +212,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "jewels:jewel_ore", ore = "jewels:jewel_ore",
@ -224,7 +224,7 @@ core.register_ore(
y_max = 31000, y_max = 31000,
}) })
dofile(core.get_modpath("jewels").."/jewels.lua") dofile(minetest.get_modpath("jewels").."/jewels.lua")
-- Achievements -- Achievements

View File

@ -5,8 +5,8 @@
locks = {} locks = {}
local picked_time = tonumber(core.setting_get("locks_picked_time")) or 15 -- unlocked for 15 seconds local picked_time = tonumber(minetest.setting_get("locks_picked_time")) or 15 -- unlocked for 15 seconds
local all_unlocked = core.setting_getbool("locks_all_unlocked") local all_unlocked = minetest.setting_getbool("locks_all_unlocked")
function locks.is_owner(meta, player) function locks.is_owner(meta, player)
local name = player:get_player_name() local name = player:get_player_name()
@ -24,7 +24,7 @@ function locks.is_locked(meta, player)
return false return false
end end
local t = core.get_gametime() local t = minetest.get_gametime()
local lp = meta:get_float("last_lock_pick") local lp = meta:get_float("last_lock_pick")
@ -41,7 +41,7 @@ function locks.is_locked(meta, player)
return true return true
end end
core.register_tool( minetest.register_tool(
"locks:pick", "locks:pick",
{ {
description = "Lock Pick", description = "Lock Pick",
@ -55,12 +55,12 @@ core.register_tool(
if math.random(1, 5) <= 1 then if math.random(1, 5) <= 1 then
local pos = pointed_thing.under local pos = pointed_thing.under
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_float("last_lock_pick", core.get_gametime() + picked_time) meta:set_float("last_lock_pick", minetest.get_gametime() + picked_time)
local own = meta:get_string("lock_owner") local own = meta:get_string("lock_owner")
if own then if own then
core.chat_send_player( minetest.chat_send_player(
own, own,
core.colorize("#f00", player:get_player_name() .. " has broken into your locked chest!")) core.colorize("#f00", player:get_player_name() .. " has broken into your locked chest!"))
end end
@ -71,7 +71,7 @@ core.register_tool(
end, end,
}) })
core.register_craftitem( minetest.register_craftitem(
"locks:lock", "locks:lock",
{ {
description = "Lock", description = "Lock",
@ -80,7 +80,7 @@ core.register_craftitem(
wield_image = "locks_lock.png", wield_image = "locks_lock.png",
}) })
core.register_craft( minetest.register_craft(
{ {
output = "locks:pick", output = "locks:pick",
recipe = { recipe = {
@ -90,7 +90,7 @@ core.register_craft(
}, },
}) })
core.register_craft( minetest.register_craft(
{ {
output = "locks:lock", output = "locks:lock",
recipe = { recipe = {
@ -100,7 +100,7 @@ core.register_craft(
}, },
}) })
core.register_node( minetest.register_node(
"locks:chest", "locks:chest",
{ {
description = "Locked Chest", description = "Locked Chest",
@ -111,7 +111,7 @@ core.register_node(
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_float("last_lock_pick", -1) meta:set_float("last_lock_pick", -1)
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -120,17 +120,17 @@ core.register_node(
after_place_node = function(pos, player) after_place_node = function(pos, player)
local name = player:get_player_name() local name = player:get_player_name()
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Locked Chest (Owned by " .. name .. ")") meta:set_string("infotext", "Locked Chest (Owned by " .. name .. ")")
meta:set_string("lock_owner", name) meta:set_string("lock_owner", name)
end, end,
on_rightclick = function(pos, node, player) on_rightclick = function(pos, node, player)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if not locks.is_locked(meta, player) then if not locks.is_locked(meta, player) then
if locks.is_owner(meta, player) then if locks.is_owner(meta, player) then
-- also unlock when owner opens for "sharing" locked stuff -- also unlock when owner opens for "sharing" locked stuff
meta:set_float("last_lock_pick", core.get_gametime() + 5) meta:set_float("last_lock_pick", minetest.get_gametime() + 5)
end end
local np = pos.x .. "," .. pos.y .. "," .. pos.z local np = pos.x .. "," .. pos.y .. "," .. pos.z
@ -144,7 +144,7 @@ core.register_node(
form = form .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1) form = form .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
form = form .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3) form = form .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
core.show_formspec( minetest.show_formspec(
player:get_player_name(), player:get_player_name(),
"default_chest", "default_chest",
form form
@ -152,33 +152,33 @@ core.register_node(
end end
end, end,
allow_metadata_inventory_move = function(pos, from_l, from_i, to_l, to_i, cnt, player) allow_metadata_inventory_move = function(pos, from_l, from_i, to_l, to_i, cnt, player)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if locks.is_locked(meta, player) then if locks.is_locked(meta, player) then
return 0 return 0
end end
return cnt return cnt
end, end,
allow_metadata_inventory_put = function(pos, listname, index, itemstack, player) allow_metadata_inventory_put = function(pos, listname, index, itemstack, player)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if locks.is_locked(meta, player) then if locks.is_locked(meta, player) then
return 0 return 0
end end
return itemstack:get_count() return itemstack:get_count()
end, end,
allow_metadata_inventory_take = function(pos, listname, index, itemstack, player) allow_metadata_inventory_take = function(pos, listname, index, itemstack, player)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if locks.is_locked(meta, player) then if locks.is_locked(meta, player) then
return 0 return 0
end end
return itemstack:get_count() return itemstack:get_count()
end, end,
can_dig = function(pos, player) can_dig = function(pos, player)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("main") and locks.is_owner(meta, player) return inv:is_empty("main") and locks.is_owner(meta, player)
end, end,
write_name = function(pos, text) write_name = function(pos, text)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if text ~= "" then if text ~= "" then
meta:set_string("infotext", text .. " (Owned by " .. meta:get_string("lock_owner") .. ")") meta:set_string("infotext", text .. " (Owned by " .. meta:get_string("lock_owner") .. ")")
@ -189,7 +189,7 @@ core.register_node(
on_blast = function() end, on_blast = function() end,
}) })
core.register_craft( minetest.register_craft(
{ {
output = "locks:chest", output = "locks:chest",
type = "shapeless", type = "shapeless",

View File

@ -6,7 +6,7 @@
local lumien_on_radius = 2 local lumien_on_radius = 2
local lumien_off_radius = 4 local lumien_off_radius = 4
core.register_node( minetest.register_node(
"lumien:crystal_on", "lumien:crystal_on",
{ {
description = "Lumien Crystal", description = "Lumien Crystal",
@ -28,7 +28,7 @@ core.register_node(
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
}) })
core.register_node( minetest.register_node(
"lumien:crystal_off", "lumien:crystal_off",
{ {
description = "Lumien Crystal", description = "Lumien Crystal",
@ -49,7 +49,7 @@ core.register_node(
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
}) })
core.register_node( minetest.register_node(
"lumien:block", "lumien:block",
{ {
description = "Lumien Block", description = "Lumien Block",
@ -59,7 +59,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_node( minetest.register_node(
"lumien:ore", "lumien:ore",
{ {
description = "Lumien Ore", description = "Lumien Ore",
@ -69,14 +69,14 @@ core.register_node(
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
core.register_craft( minetest.register_craft(
{ {
output = "lumien:crystal_off 9", output = "lumien:crystal_off 9",
recipe = {"lumien:block"}, recipe = {"lumien:block"},
type = "shapeless", type = "shapeless",
}) })
core.register_craft( minetest.register_craft(
{ {
output = "lumien:block", output = "lumien:block",
recipe = { recipe = {
@ -86,7 +86,7 @@ core.register_craft(
}, },
}) })
core.register_ore( minetest.register_ore(
{ {
ore_type = "scatter", ore_type = "scatter",
ore = "lumien:ore", ore = "lumien:ore",
@ -98,7 +98,7 @@ core.register_ore(
y_max = -64, y_max = -64,
}) })
core.register_abm( minetest.register_abm(
{ {
nodenames = {"lumien:crystal_on"}, nodenames = {"lumien:crystal_on"},
interval = 1, interval = 1,
@ -115,14 +115,14 @@ core.register_abm(
) )
local ok = true local ok = true
for _,object in ipairs(core.get_objects_inside_radius(pos, lumien_off_radius)) do for _,object in ipairs(minetest.get_objects_inside_radius(pos, lumien_off_radius)) do
if object:is_player() then if object:is_player() then
ok = false ok = false
end end
end end
if ok then if ok then
core.set_node( minetest.set_node(
pos, pos,
{ {
name = "lumien:crystal_off", name = "lumien:crystal_off",
@ -134,7 +134,7 @@ core.register_abm(
}) })
local function step(dtime) local function step(dtime)
for _, player in ipairs(core.get_connected_players()) do for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:getpos() local pos = player:getpos()
util.nodefunc( util.nodefunc(
@ -142,9 +142,9 @@ local function step(dtime)
{x = pos.x+lumien_on_radius, y = pos.y+lumien_on_radius, z = pos.z+lumien_on_radius}, {x = pos.x+lumien_on_radius, y = pos.y+lumien_on_radius, z = pos.z+lumien_on_radius},
"lumien:crystal_off", "lumien:crystal_off",
function(pos) function(pos)
local node = core.get_node(pos) local node = minetest.get_node(pos)
core.set_node( minetest.set_node(
pos, pos,
{ {
name = "lumien:crystal_on", name = "lumien:crystal_on",
@ -157,7 +157,7 @@ local function step(dtime)
end end
end end
core.register_globalstep(step) minetest.register_globalstep(step)
-- Achievements -- Achievements

View File

@ -3,25 +3,25 @@ mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
-- Initial settings check -- Initial settings check
local damage_enabled = core.setting_getbool("enable_damage") or false local damage_enabled = minetest.setting_getbool("enable_damage") or false
local peaceful_only = core.setting_getbool("only_peaceful_mobs") or false local peaceful_only = minetest.setting_getbool("only_peaceful_mobs") or false
local enable_blood = core.setting_getbool("mobs_enable_blood") or false local enable_blood = minetest.setting_getbool("mobs_enable_blood") or false
mobs.protected = tonumber(core.setting_get("mobs_spawn_protected")) or 0 mobs.protected = tonumber(minetest.setting_get("mobs_spawn_protected")) or 0
mobs.remove = core.setting_getbool("remove_far_mobs") or false mobs.remove = minetest.setting_getbool("remove_far_mobs") or false
local function is_too_near_spawn(pos) local function is_too_near_spawn(pos)
if core.is_singleplayer() or not core.setting_getbool("mobs_safe_spawn") then if minetest.is_singleplayer() or not minetest.setting_getbool("mobs_safe_spawn") then
return false return false
end end
local sp = core.setting_get_pos("static_spawnpoint") or {x = 0, y = 0, z = 0} local sp = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 0, z = 0}
local rad = core.setting_get("static_spawn_radius") or 256 local rad = minetest.setting_get("static_spawn_radius") or 256
return (vector.distance(pos, sp) < rad) return (vector.distance(pos, sp) < rad)
end end
function mobs:register_mob(name, def) function mobs:register_mob(name, def)
core.register_entity( minetest.register_entity(
name, name,
{ {
stepheight = def.stepheight or 0.6, stepheight = def.stepheight or 0.6,
@ -120,7 +120,7 @@ function mobs:register_mob(name, def)
-- make sound when fed so many times -- make sound when fed so many times
if self.sounds.random then if self.sounds.random then
core.sound_play( minetest.sound_play(
self.sounds.random, self.sounds.random,
{ {
object = self.object, object = self.object,
@ -135,7 +135,7 @@ function mobs:register_mob(name, def)
if self.state ~= "attack" then if self.state ~= "attack" then
if math.random(0,100) < 90 if math.random(0,100) < 90
and self.sounds.war_cry then and self.sounds.war_cry then
core.sound_play( minetest.sound_play(
self.sounds.war_cry, self.sounds.war_cry,
{ {
object = self.object, object = self.object,
@ -251,7 +251,7 @@ function mobs:register_mob(name, def)
self.lifetimer = self.lifetimer - dtime self.lifetimer = self.lifetimer - dtime
if self.lifetimer <= 0 if self.lifetimer <= 0
and self.state ~= "attack" then and self.state ~= "attack" then
core.log("action","lifetimer expired, removed "..self.name) minetest.log("action","lifetimer expired, removed "..self.name)
effect(self.object:getpos(), 15, "tnt_smoke.png") effect(self.object:getpos(), 15, "tnt_smoke.png")
self.object:remove() self.object:remove()
return return
@ -264,13 +264,13 @@ function mobs:register_mob(name, def)
and math.random(1, self.replace_rate) == 1 then and math.random(1, self.replace_rate) == 1 then
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = pos.y + self.replace_offset pos.y = pos.y + self.replace_offset
-- print ("replace node = ".. core.get_node(pos).name, pos.y) -- print ("replace node = ".. minetest.get_node(pos).name, pos.y)
if self.replace_what and self.object:getvelocity().y == 0 and #core.find_nodes_in_area(pos, pos, self.replace_what) > 0 then if self.replace_what and self.object:getvelocity().y == 0 and #minetest.find_nodes_in_area(pos, pos, self.replace_what) > 0 then
--and self.state == "stand" then --and self.state == "stand" then
if self.on_replace ~= nil then if self.on_replace ~= nil then
self.on_replace(self, pos) self.on_replace(self, pos)
else else
core.set_node(pos, {name = self.replace_with}) minetest.set_node(pos, {name = self.replace_with})
end end
end end
end end
@ -280,9 +280,9 @@ function mobs:register_mob(name, def)
if not self.fly then if not self.fly then
-- floating in water (or falling) -- floating in water (or falling)
local pos = self.object:getpos() local pos = self.object:getpos()
local nod = core.get_node_or_nil(pos) local nod = minetest.get_node_or_nil(pos)
if nod then nod = nod.name else nod = "default:dirt" end if nod then nod = nod.name else nod = "default:dirt" end
local nodef = core.registered_nodes[nod] local nodef = minetest.registered_nodes[nod]
local v = self.object:getvelocity() local v = self.object:getvelocity()
if v.y > 0.1 then if v.y > 0.1 then
@ -343,7 +343,7 @@ function mobs:register_mob(name, def)
if self.sounds.random if self.sounds.random
and math.random(1, 100) <= 1 then and math.random(1, 100) <= 1 then
core.sound_play( minetest.sound_play(
self.sounds.random, self.sounds.random,
{ {
object = self.object, object = self.object,
@ -354,23 +354,23 @@ function mobs:register_mob(name, def)
local do_env_damage = function(self) local do_env_damage = function(self)
local pos = self.object:getpos() local pos = self.object:getpos()
local tod = core.get_timeofday() local tod = minetest.get_timeofday()
-- daylight above ground -- daylight above ground
if self.light_damage ~= 0 if self.light_damage ~= 0
and pos.y > 0 and pos.y > 0
and tod > 0.2 and tod > 0.2
and tod < 0.8 and tod < 0.8
and (core.get_node_light(pos) or 0) > 12 then and (minetest.get_node_light(pos) or 0) > 12 then
self.object:set_hp(self.object:get_hp() - self.light_damage) self.object:set_hp(self.object:get_hp() - self.light_damage)
effect(pos, 5, "tnt_smoke.png") effect(pos, 5, "tnt_smoke.png")
if check_for_death(self) then return end if check_for_death(self) then return end
end end
pos.y = pos.y + self.collisionbox[2] -- foot level pos.y = pos.y + self.collisionbox[2] -- foot level
local nod = core.get_node_or_nil(pos) local nod = minetest.get_node_or_nil(pos)
if not nod then return end ; -- print ("standing in "..nod.name) if not nod then return end ; -- print ("standing in "..nod.name)
local nodef = core.registered_nodes[nod.name] local nodef = minetest.registered_nodes[nod.name]
pos.y = pos.y + 1 pos.y = pos.y + 1
-- water -- water
@ -400,16 +400,16 @@ function mobs:register_mob(name, def)
if self.jumptimer < 3 then if self.jumptimer < 3 then
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = (pos.y + self.collisionbox[2]) - 0.2 pos.y = (pos.y + self.collisionbox[2]) - 0.2
local nod = core.get_node(pos) local nod = minetest.get_node(pos)
--print ("standing on:", nod.name, pos.y) --print ("standing on:", nod.name, pos.y)
if not nod if not nod
or not core.registered_nodes[nod.name] or not minetest.registered_nodes[nod.name]
or core.registered_nodes[nod.name].walkable == false then or minetest.registered_nodes[nod.name].walkable == false then
return return
end end
if self.direction then if self.direction then
pos.y = pos.y + 0.5 pos.y = pos.y + 0.5
local nod = core.get_node_or_nil( local nod = minetest.get_node_or_nil(
{ {
x = pos.x + self.direction.x, x = pos.x + self.direction.x,
y = pos.y, y = pos.y,
@ -419,7 +419,7 @@ function mobs:register_mob(name, def)
if nod and nod.name and if nod and nod.name and
(nod.name ~= "air" (nod.name ~= "air"
or self.walk_chance == 0) then or self.walk_chance == 0) then
local def = core.registered_items[nod.name] local def = minetest.registered_items[nod.name]
if (def if (def
and def.walkable and def.walkable
and not nod.name:find("fence")) and not nod.name:find("fence"))
@ -430,7 +430,7 @@ function mobs:register_mob(name, def)
v.z = v.z * 2.2 v.z = v.z * 2.2
self.object:setvelocity(v) self.object:setvelocity(v)
if self.sounds.jump then if self.sounds.jump then
core.sound_play( minetest.sound_play(
self.sounds.jump, self.sounds.jump,
{ {
object = self.object, object = self.object,
@ -468,7 +468,7 @@ function mobs:register_mob(name, def)
local min_dist = self.view_range + 1 local min_dist = self.view_range + 1
local min_player = nil local min_player = nil
for _,oir in ipairs(core.get_objects_inside_radius(s, self.view_range)) do for _,oir in ipairs(minetest.get_objects_inside_radius(s, self.view_range)) do
if oir:is_player() then if oir:is_player() then
player = oir player = oir
@ -492,7 +492,7 @@ function mobs:register_mob(name, def)
if dist < self.view_range then if dist < self.view_range then
-- and self.in_fov(self,p) then -- and self.in_fov(self,p) then
-- choose closest player to attack -- choose closest player to attack
if core.line_of_sight(sp, p, 2) == true if minetest.line_of_sight(sp, p, 2) == true
and dist < min_dist then and dist < min_dist then
min_dist = dist min_dist = dist
min_player = player min_player = player
@ -515,7 +515,7 @@ function mobs:register_mob(name, def)
and self.state ~= "attack" then and self.state ~= "attack" then
local s = self.object:getpos() local s = self.object:getpos()
local obj = nil local obj = nil
for _, oir in pairs(core.get_objects_inside_radius(s,self.view_range)) do for _, oir in pairs(minetest.get_objects_inside_radius(s,self.view_range)) do
obj = oir:get_luaentity() obj = oir:get_luaentity()
if obj if obj
and obj.type == "monster" then and obj.type == "monster" then
@ -565,7 +565,7 @@ function mobs:register_mob(name, def)
and self.hornytimer <= 40 then and self.hornytimer <= 40 then
local pos = self.object:getpos() local pos = self.object:getpos()
effect({x = pos.x, y = pos.y + 0.5, z = pos.z}, 4, "heart.png") effect({x = pos.x, y = pos.y + 0.5, z = pos.z}, 4, "heart.png")
local ents = core.get_objects_inside_radius(pos, self.view_range) local ents = minetest.get_objects_inside_radius(pos, self.view_range)
local num = 0 local num = 0
local ent = nil local ent = nil
for i,obj in ipairs(ents) do for i,obj in ipairs(ents) do
@ -598,10 +598,10 @@ function mobs:register_mob(name, def)
if num > 1 then if num > 1 then
self.hornytimer = 41 self.hornytimer = 41
ent.hornytimer = 41 ent.hornytimer = 41
core.after( minetest.after(
7, 7,
function(dtime) function(dtime)
local mob = core.add_entity(pos, self.name) local mob = minetest.add_entity(pos, self.name)
local ent2 = mob:get_luaentity() local ent2 = mob:get_luaentity()
local textures = self.base_texture local textures = self.base_texture
if def.child_texture then if def.child_texture then
@ -635,7 +635,7 @@ function mobs:register_mob(name, def)
-- find player to follow -- find player to follow
if (self.follow ~= "" or self.order == "follow") and not self.following and self.state ~= "attack" then if (self.follow ~= "" or self.order == "follow") and not self.following and self.state ~= "attack" then
local s, p, dist local s, p, dist
for _,player in pairs(core.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
s = self.object:getpos() s = self.object:getpos()
p = player:getpos() p = player:getpos()
dist = ((p.x - s.x) ^ 2 + (p.y - s.y) ^ 2 + (p.z - s.z) ^ 2) ^ 0.5 dist = ((p.x - s.x) ^ 2 + (p.y - s.y) ^ 2 + (p.z - s.z) ^ 2) ^ 0.5
@ -727,7 +727,7 @@ function mobs:register_mob(name, def)
local s = self.object:getpos() local s = self.object:getpos()
if self.type == "npc" then if self.type == "npc" then
local o = core.get_objects_inside_radius(self.object:getpos(), 3) local o = minetest.get_objects_inside_radius(self.object:getpos(), 3)
local yaw = 0 local yaw = 0
for _,o in ipairs(o) do for _,o in ipairs(o) do
@ -776,7 +776,7 @@ function mobs:register_mob(name, def)
elseif self.state == "walk" then elseif self.state == "walk" then
local s = self.object:getpos() local s = self.object:getpos()
local lp = core.find_node_near(s, 1, {"group:water"}) local lp = minetest.find_node_near(s, 1, {"group:water"})
-- water swimmers cannot move out of water -- water swimmers cannot move out of water
if self.fly and self.fly_in == "default:water_source" and not lp then if self.fly and self.fly_in == "default:water_source" and not lp then
@ -882,10 +882,10 @@ function mobs:register_mob(name, def)
if self.timer > 3 then if self.timer > 3 then
local pos = vector.round(self.object:getpos()) local pos = vector.round(self.object:getpos())
entity_physics(pos, 3) -- hurt player/mobs caught in blast area entity_physics(pos, 3) -- hurt player/mobs caught in blast area
if core.find_node_near(pos, 1, {"group:water"}) or core.is_protected(pos, "") then if minetest.find_node_near(pos, 1, {"group:water"}) or minetest.is_protected(pos, "") then
self.object:remove() self.object:remove()
if self.sounds.explode ~= "" then if self.sounds.explode ~= "" then
core.sound_play(self.sounds.explode, { minetest.sound_play(self.sounds.explode, {
pos = pos, pos = pos,
gain = 1.0, gain = 1.0,
max_hear_distance = 16 max_hear_distance = 16
@ -917,7 +917,7 @@ function mobs:register_mob(name, def)
if self.fly if self.fly
and dist > 2 then and dist > 2 then
local nod = core.get_node_or_nil(s) local nod = minetest.get_node_or_nil(s)
local p1 = s local p1 = s
local me_y = math.floor(p1.y) local me_y = math.floor(p1.y)
local p2 = p local p2 = p
@ -995,9 +995,9 @@ function mobs:register_mob(name, def)
local s2 = s local s2 = s
p2.y = p2.y + 1.5 p2.y = p2.y + 1.5
s2.y = s2.y + 1.5 s2.y = s2.y + 1.5
if core.line_of_sight(p2, s2) == true then if minetest.line_of_sight(p2, s2) == true then
if self.sounds.attack then if self.sounds.attack then
core.sound_play( minetest.sound_play(
self.sounds.attack, self.sounds.attack,
{ {
object = self.object, object = self.object,
@ -1054,7 +1054,7 @@ function mobs:register_mob(name, def)
self:set_animation("punch") self:set_animation("punch")
if self.sounds.attack then if self.sounds.attack then
core.sound_play( minetest.sound_play(
self.sounds.attack, self.sounds.attack,
{ {
object = self.object, object = self.object,
@ -1064,7 +1064,7 @@ function mobs:register_mob(name, def)
local p = self.object:getpos() local p = self.object:getpos()
p.y = p.y + (self.collisionbox[2] + self.collisionbox[5]) / 2 p.y = p.y + (self.collisionbox[2] + self.collisionbox[5]) / 2
local obj = core.add_entity(p, self.arrow) local obj = minetest.add_entity(p, self.arrow)
local amount = (vec.x ^ 2 + vec.y ^ 2 + vec.z ^ 2) ^ 0.5 local amount = (vec.x ^ 2 + vec.y ^ 2 + vec.z ^ 2) ^ 0.5
local v = obj:get_luaentity().velocity local v = obj:get_luaentity().velocity
vec.y = vec.y + self.shoot_offset -- this makes shoot aim accurate vec.y = vec.y + self.shoot_offset -- this makes shoot aim accurate
@ -1085,7 +1085,7 @@ function mobs:register_mob(name, def)
-- load entity variables -- load entity variables
if staticdata then if staticdata then
local tmp = core.deserialize(staticdata) local tmp = minetest.deserialize(staticdata)
if tmp then if tmp then
for _,stat in pairs(tmp) do for _,stat in pairs(tmp) do
self[_] = stat self[_] = stat
@ -1183,7 +1183,7 @@ function mobs:register_mob(name, def)
end end
end end
-- print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n') -- print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
return core.serialize(tmp) return minetest.serialize(tmp)
end, end,
on_punch = function(self, hitter, tflp, tool_capabilities, dir) on_punch = function(self, hitter, tflp, tool_capabilities, dir)
@ -1198,12 +1198,12 @@ function mobs:register_mob(name, def)
-- weapon sounds -- weapon sounds
if weapon:get_definition().sounds ~= nil then if weapon:get_definition().sounds ~= nil then
local s = math.random(0, #weapon:get_definition().sounds) local s = math.random(0, #weapon:get_definition().sounds)
core.sound_play(weapon:get_definition().sounds[s], { minetest.sound_play(weapon:get_definition().sounds[s], {
object=hitter, object=hitter,
max_hear_distance = 8 max_hear_distance = 8
}) })
else else
core.sound_play("default_punch", { minetest.sound_play("default_punch", {
object = hitter, object = hitter,
max_hear_distance = 5 max_hear_distance = 5
}) })
@ -1248,7 +1248,7 @@ function mobs:register_mob(name, def)
end end
-- alert others to the attack -- alert others to the attack
local obj = nil local obj = nil
for _, oir in pairs(core.get_objects_inside_radius(hitter:getpos(), 5)) do for _, oir in pairs(minetest.get_objects_inside_radius(hitter:getpos(), 5)) do
obj = oir:get_luaentity() obj = oir:get_luaentity()
if obj then if obj then
if obj.group_attack == true if obj.group_attack == true
@ -1266,7 +1266,7 @@ mobs.spawning_mobs = {}
function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, chance, active_object_count, min_height, max_height) function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval, chance, active_object_count, min_height, max_height)
mobs.spawning_mobs[name] = true mobs.spawning_mobs[name] = true
core.register_abm( minetest.register_abm(
{ {
nodenames = nodes, nodenames = nodes,
neighbors = neighbors, neighbors = neighbors,
@ -1284,12 +1284,12 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
-- mobs cannot spawn inside protected areas if enabled -- mobs cannot spawn inside protected areas if enabled
if mobs.protected == 1 if mobs.protected == 1
and core.is_protected(pos, "") then and minetest.is_protected(pos, "") then
return return
end end
-- check if light and height levels are ok to spawn -- check if light and height levels are ok to spawn
local light = core.get_node_light(pos) local light = minetest.get_node_light(pos)
if not light if not light
or light > max_light or light > max_light
or light < min_light or light < min_light
@ -1299,32 +1299,32 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
end end
-- are we spawning inside a solid node? -- are we spawning inside a solid node?
local nod = core.get_node_or_nil(pos) local nod = minetest.get_node_or_nil(pos)
if not nod if not nod
or not nod.name or not nod.name
or not core.registered_nodes[nod.name] or not minetest.registered_nodes[nod.name]
or core.registered_nodes[nod.name].walkable == true then or minetest.registered_nodes[nod.name].walkable == true then
return return
end end
pos.y = pos.y + 1 pos.y = pos.y + 1
nod = core.get_node_or_nil(pos) nod = minetest.get_node_or_nil(pos)
if not nod if not nod
or not nod.name or not nod.name
or not core.registered_nodes[nod.name] or not minetest.registered_nodes[nod.name]
or core.registered_nodes[nod.name].walkable == true then or minetest.registered_nodes[nod.name].walkable == true then
return return
end end
if core.setting_getbool("display_mob_spawn") then if minetest.setting_getbool("display_mob_spawn") then
core.chat_send_all("[mobs] Add "..name.." at "..core.pos_to_string(pos)) minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
end end
-- spawn mob half block higher -- spawn mob half block higher
pos.y = pos.y - 0.5 pos.y = pos.y - 0.5
core.add_entity(pos, name) minetest.add_entity(pos, name)
--print ("Spawned "..name.." at "..core.pos_to_string(pos).." on "..node.name.." near "..neighbors[1]) --print ("Spawned "..name.." at "..minetest.pos_to_string(pos).." on "..node.name.." near "..neighbors[1])
end end
}) })
@ -1337,7 +1337,7 @@ end
-- particle effects -- particle effects
function effect(pos, amount, texture, max_size) function effect(pos, amount, texture, max_size)
core.add_particlespawner( minetest.add_particlespawner(
{ {
amount = amount, amount = amount,
time = 0.25, time = 0.25,
@ -1367,21 +1367,21 @@ function mobs:explosion(pos, radius, fire, smoke, sound)
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp}) local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data() local data = vm:get_data()
local p = {} local p = {}
local c_air = core.get_content_id("air") local c_air = minetest.get_content_id("air")
local c_ignore = core.get_content_id("ignore") local c_ignore = minetest.get_content_id("ignore")
local c_obsidian = core.get_content_id("default:obsidian") local c_obsidian = minetest.get_content_id("default:obsidian")
local c_brick = core.get_content_id("default:obsidianbrick") local c_brick = minetest.get_content_id("default:obsidianbrick")
local c_chest = core.get_content_id("default:chest_locked") local c_chest = minetest.get_content_id("default:chest_locked")
if sound if sound
and sound ~= "" then and sound ~= "" then
core.sound_play(sound, { minetest.sound_play(sound, {
pos = pos, pos = pos,
gain = 1.0, gain = 1.0,
max_hear_distance = 16 max_hear_distance = 16
}) })
end end
-- if area protected then no blast damage -- if area protected then no blast damage
if core.is_protected(pos, "") then if minetest.is_protected(pos, "") then
return return
end end
for z = -radius, radius do for z = -radius, radius do
@ -1394,26 +1394,26 @@ function mobs:explosion(pos, radius, fire, smoke, sound)
if data[vi] ~= c_air and data[vi] ~= c_ignore if data[vi] ~= c_air and data[vi] ~= c_ignore
and data[vi] ~= c_obsidian and data[vi] ~= c_brick and data[vi] ~= c_obsidian and data[vi] ~= c_brick
and data[vi] ~= c_chest then and data[vi] ~= c_chest then
local n = core.get_node(p).name local n = minetest.get_node(p).name
if core.get_item_group(n, "unbreakable") ~= 1 then if minetest.get_item_group(n, "unbreakable") ~= 1 then
-- if chest then drop items inside -- if chest then drop items inside
if n == "default:chest" then if n == "default:chest" then
local meta = core.get_meta(p) local meta = minetest.get_meta(p)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for i = 1,32 do for i = 1,32 do
local m_stack = inv:get_stack("main", i) local m_stack = inv:get_stack("main", i)
local obj = core.add_item(pos, m_stack) local obj = minetest.add_item(pos, m_stack)
if obj then if obj then
obj:setvelocity({x = math.random(-2, 2), y = 7, z = math.random(-2, 2)}) obj:setvelocity({x = math.random(-2, 2), y = 7, z = math.random(-2, 2)})
end end
end end
end end
if fire > 0 if fire > 0
and (core.registered_nodes[n].groups.flammable and (minetest.registered_nodes[n].groups.flammable
or math.random(1, 100) <= 30) then or math.random(1, 100) <= 30) then
-- core.set_node(p, {name = "fire:basic_flame"}) fire mod is disabled -- minetest.set_node(p, {name = "fire:basic_flame"}) fire mod is disabled
else else
core.remove_node(p) minetest.remove_node(p)
end end
if smoke > 0 then if smoke > 0 then
effect(p, 2, "tnt_smoke.png", 5) effect(p, 2, "tnt_smoke.png", 5)
@ -1432,7 +1432,7 @@ function check_for_death(self)
if hp > 0 then if hp > 0 then
self.health = hp self.health = hp
if self.sounds.damage ~= nil then if self.sounds.damage ~= nil then
core.sound_play( minetest.sound_play(
self.sounds.damage, self.sounds.damage,
{ {
object = self.object, object = self.object,
@ -1446,7 +1446,7 @@ function check_for_death(self)
local obj = nil local obj = nil
for _,drop in ipairs(self.drops) do for _,drop in ipairs(self.drops) do
if math.random(1, drop.chance) == 1 then if math.random(1, drop.chance) == 1 then
obj = core.add_item(pos, ItemStack(drop.name.." "..math.random(drop.min, drop.max))) obj = minetest.add_item(pos, ItemStack(drop.name.." "..math.random(drop.min, drop.max)))
if obj then if obj then
obj:setvelocity( obj:setvelocity(
{ {
@ -1458,7 +1458,7 @@ function check_for_death(self)
end end
end end
if self.sounds.death ~= nil then if self.sounds.death ~= nil then
core.sound_play( minetest.sound_play(
self.sounds.death, self.sounds.death,
{ {
object = self.object, object = self.object,
@ -1486,7 +1486,7 @@ end
-- modified from TNT mod -- modified from TNT mod
function entity_physics(pos, radius) function entity_physics(pos, radius)
radius = radius * 2 radius = radius * 2
local objs = core.get_objects_inside_radius(pos, radius) local objs = minetest.get_objects_inside_radius(pos, radius)
local obj_pos, obj_vel, dist local obj_pos, obj_vel, dist
for _, obj in pairs(objs) do for _, obj in pairs(objs) do
obj_pos = obj:getpos() obj_pos = obj:getpos()
@ -1503,7 +1503,7 @@ end
-- register arrow for shoot attack -- register arrow for shoot attack
function mobs:register_arrow(name, def) function mobs:register_arrow(name, def)
if not name or not def then return end -- errorcheck if not name or not def then return end -- errorcheck
core.register_entity( minetest.register_entity(
name, name,
{ {
physical = false, physical = false,
@ -1523,17 +1523,17 @@ function mobs:register_arrow(name, def)
local engage = 10 - (self.velocity / 2) -- clear entity before arrow becomes active local engage = 10 - (self.velocity / 2) -- clear entity before arrow becomes active
local pos = self.object:getpos() local pos = self.object:getpos()
local node = core.get_node_or_nil(self.object:getpos()) local node = minetest.get_node_or_nil(self.object:getpos())
if node then node = node.name else node = "air" end if node then node = node.name else node = "air" end
if self.hit_node if self.hit_node
and core.registered_nodes[node] and minetest.registered_nodes[node]
and core.registered_nodes[node].walkable then and minetest.registered_nodes[node].walkable then
self.hit_node(self, pos, node) self.hit_node(self, pos, node)
if self.drop == true then if self.drop == true then
pos.y = pos.y + 1 pos.y = pos.y + 1
self.lastpos = (self.lastpos or pos) self.lastpos = (self.lastpos or pos)
core.add_item(self.lastpos, self.object:get_luaentity().name) minetest.add_item(self.lastpos, self.object:get_luaentity().name)
end end
self.object:remove() ; -- print ("hit node") self.object:remove() ; -- print ("hit node")
return return
@ -1541,7 +1541,7 @@ function mobs:register_arrow(name, def)
if (self.hit_player or self.hit_mob) if (self.hit_player or self.hit_mob)
and self.timer > engage then and self.timer > engage then
for _,player in pairs(core.get_objects_inside_radius(pos, 1.0)) do for _,player in pairs(minetest.get_objects_inside_radius(pos, 1.0)) do
if self.hit_player if self.hit_player
and player:is_player() then and player:is_player() then
self.hit_player(self, player) self.hit_player(self, player)
@ -1565,7 +1565,7 @@ end
-- Spawn Egg -- Spawn Egg
function mobs:register_egg(mob, desc, background) function mobs:register_egg(mob, desc, background)
local invimg = background local invimg = background
core.register_craftitem( minetest.register_craftitem(
mob, mob,
{ {
description = desc, description = desc,
@ -1573,9 +1573,9 @@ function mobs:register_egg(mob, desc, background)
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above local pos = pointed_thing.above
if pointed_thing.above if pointed_thing.above
and not core.is_protected(pos, placer:get_player_name()) then and not minetest.is_protected(pos, placer:get_player_name()) then
pos.y = pos.y + 0.5 pos.y = pos.y + 0.5
local mob = core.add_entity(pos, mob) local mob = minetest.add_entity(pos, mob)
local ent = mob:get_luaentity() local ent = mob:get_luaentity()
if ent.type ~= "monster" then if ent.type ~= "monster" then
-- set owner -- set owner
@ -1603,13 +1603,13 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
-- is mob tamed? -- is mob tamed?
if self.tamed == false and force_take == false then if self.tamed == false and force_take == false then
core.chat_send_player(name, "Not tamed!") minetest.chat_send_player(name, "Not tamed!")
return return
end end
-- cannot pick up if not owner -- cannot pick up if not owner
if self.owner ~= name and force_take == false then if self.owner ~= name and force_take == false then
core.chat_send_player(name, self.owner.." is owner!") minetest.chat_send_player(name, self.owner.." is owner!")
return return
end end
@ -1636,7 +1636,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
clicker:get_inventory():add_item("main", mobname) clicker:get_inventory():add_item("main", mobname)
self.object:remove() self.object:remove()
else else
core.chat_send_player(name, "Missed!") minetest.chat_send_player(name, "Missed!")
end end
end end
end end
@ -1658,7 +1658,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed)
if itemstring == self.follow then if itemstring == self.follow then
if name ~= nil then if name ~= nil then
-- take item -- take item
if not core.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end

View File

@ -55,24 +55,24 @@ mobs:register_spawn("mobs:boar", {"default:dirt_with_grass"}, 20, 10, 15000, 1,
mobs:register_egg("mobs:boar", "Boar", "mobs_boar_inventory.png") mobs:register_egg("mobs:boar", "Boar", "mobs_boar_inventory.png")
-- raw porkchop -- raw porkchop
core.register_craftitem( minetest.register_craftitem(
"mobs:pork_raw", "mobs:pork_raw",
{ {
description = "Raw Porkchop", description = "Raw Porkchop",
inventory_image = "mobs_pork_raw.png", inventory_image = "mobs_pork_raw.png",
on_use = core.item_eat({hp = 4, sat = 30}), on_use = minetest.item_eat({hp = 4, sat = 30}),
}) })
-- cooked porkchop -- cooked porkchop
core.register_craftitem( minetest.register_craftitem(
"mobs:pork", "mobs:pork",
{ {
description = "Cooked Porkchop", description = "Cooked Porkchop",
inventory_image = "mobs_pork_cooked.png", inventory_image = "mobs_pork_cooked.png",
on_use = core.item_eat({hp = 8, sat = 50}), on_use = minetest.item_eat({hp = 8, sat = 50}),
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "mobs:pork", output = "mobs:pork",

View File

@ -1,5 +1,5 @@
-- wool -- wool
core.register_node( minetest.register_node(
"mobs:wool", "mobs:wool",
{ {
description = "Wool Bundle", description = "Wool Bundle",
@ -10,24 +10,24 @@ core.register_node(
}) })
-- raw meat -- raw meat
core.register_craftitem( minetest.register_craftitem(
"mobs:meat_raw", "mobs:meat_raw",
{ {
description = "Raw Meat", description = "Raw Meat",
inventory_image = "mobs_meat_raw.png", inventory_image = "mobs_meat_raw.png",
on_use = core.item_eat({hp = 3, sat = 30}), on_use = minetest.item_eat({hp = 3, sat = 30}),
}) })
-- cooked meat -- cooked meat
core.register_craftitem( minetest.register_craftitem(
"mobs:meat", "mobs:meat",
{ {
description = "Cooked Meat", description = "Cooked Meat",
inventory_image = "mobs_meat_cooked.png", inventory_image = "mobs_meat_cooked.png",
on_use = core.item_eat({hp = 7, sat = 70}), on_use = minetest.item_eat({hp = 7, sat = 70}),
}) })
core.register_craft( minetest.register_craft(
{ {
type = "cooking", type = "cooking",
output = "mobs:meat", output = "mobs:meat",
@ -36,14 +36,14 @@ core.register_craft(
}) })
-- net (right click to capture animal) -- net (right click to capture animal)
core.register_tool( minetest.register_tool(
"mobs:net", "mobs:net",
{ {
description = "Net (Right-click to capture)", description = "Net (Right-click to capture)",
inventory_image = "mobs_net.png", inventory_image = "mobs_net.png",
}) })
core.register_craft( minetest.register_craft(
{ {
output = "mobs:net", output = "mobs:net",
recipe = { recipe = {
@ -54,14 +54,14 @@ core.register_craft(
}) })
-- lasso (right click to capture animal) -- lasso (right click to capture animal)
core.register_tool( minetest.register_tool(
"mobs:lasso", "mobs:lasso",
{ {
description = "Lasso (Right-click to capture)", description = "Lasso (Right-click to capture)",
inventory_image = "mobs_lasso.png", inventory_image = "mobs_lasso.png",
}) })
core.register_craft( minetest.register_craft(
{ {
output = "mobs:lasso", output = "mobs:lasso",
recipe = { recipe = {

View File

@ -4,7 +4,7 @@
-- Tweaked by Kaadmy, for Pixture -- Tweaked by Kaadmy, for Pixture
-- --
local path = core.get_modpath("mobs") local path = minetest.get_modpath("mobs")
-- Mob Api -- Mob Api
dofile(path.."/api.lua") dofile(path.."/api.lua")

View File

@ -75,7 +75,7 @@ for _, npc_type in pairs(npc_types) do
local hp = self.object:get_hp() local hp = self.object:get_hp()
-- return if full health -- return if full health
if hp >= self.hp_max then if hp >= self.hp_max then
core.chat_send_player(name, "Villager is no longer hungry.") minetest.chat_send_player(name, "Villager is no longer hungry.")
return return
end end
@ -84,7 +84,7 @@ for _, npc_type in pairs(npc_types) do
self.object:set_hp(hp) self.object:set_hp(hp)
-- take item -- take item
if not core.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end

View File

@ -50,7 +50,7 @@ mobs:register_mob(
replace_with = "air", replace_with = "air",
replace_offset = -1, replace_offset = -1,
on_replace = function(self, pos) on_replace = function(self, pos)
core.set_node(pos, {name = self.replace_with}) minetest.set_node(pos, {name = self.replace_with})
if mobs:feed_tame(self, self.follow, 8, true) then if mobs:feed_tame(self, self.follow, 8, true) then
if self.gotten == false then if self.gotten == false then
self.object:set_properties( self.object:set_properties(
@ -84,7 +84,7 @@ mobs:register_mob(
self.gotten = true -- shaved self.gotten = true -- shaved
local pos = self.object:getpos() local pos = self.object:getpos()
pos.y = pos.y + 0.5 pos.y = pos.y + 0.5
local obj = core.add_item(pos, ItemStack("mobs:wool")) local obj = minetest.add_item(pos, ItemStack("mobs:wool"))
if obj then if obj then
obj:setvelocity( obj:setvelocity(
{ {

View File

@ -5,36 +5,36 @@
music = {} music = {}
music.default_track = core.setting_get("music_track") or "music_catsong" music.default_track = minetest.setting_get("music_track") or "music_catsong"
music.track_length = tonumber(core.setting_get("music_track_length")) or 30.0 music.track_length = tonumber(minetest.setting_get("music_track_length")) or 30.0
music.volume = tonumber(core.setting_get("music_volume")) or 1.0 music.volume = tonumber(minetest.setting_get("music_volume")) or 1.0
music.players = {} -- music players music.players = {} -- music players
if core.setting_getbool("music_enable") then if minetest.setting_getbool("music_enable") then
function music.stop(pos) function music.stop(pos)
local dp = core.hash_node_position(pos) local dp = minetest.hash_node_position(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Music player (Off)") meta:set_string("infotext", "Music player (Off)")
meta:set_int("music_player_enabled", 0) meta:set_int("music_player_enabled", 0)
if music.players[dp] ~= nil then if music.players[dp] ~= nil then
core.sound_stop(music.players[dp]["handle"]) minetest.sound_stop(music.players[dp]["handle"])
music.players[dp] = nil music.players[dp] = nil
end end
end end
function music.start(pos) function music.start(pos)
local dp = core.hash_node_position(pos) local dp = minetest.hash_node_position(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Music player (On)") meta:set_string("infotext", "Music player (On)")
meta:set_int("music_player_enabled", 1) meta:set_int("music_player_enabled", 1)
if music.players[dp] == nil then if music.players[dp] == nil then
music.players[dp] = { music.players[dp] = {
["handle"] = core.sound_play( ["handle"] = minetest.sound_play(
music.default_track, music.default_track,
{ {
pos = pos, pos = pos,
@ -45,8 +45,8 @@ if core.setting_getbool("music_enable") then
} }
else else
music.players[dp]["timer"] = 0 music.players[dp]["timer"] = 0
core.sound_stop(music.players[dp]["handle"]) minetest.sound_stop(music.players[dp]["handle"])
music.players[dp]["handle"] = core.sound_play( music.players[dp]["handle"] = minetest.sound_play(
music.default_track, music.default_track,
{ {
pos = pos, pos = pos,
@ -56,10 +56,10 @@ if core.setting_getbool("music_enable") then
end end
function music.update(pos) function music.update(pos)
local dp = core.hash_node_position(pos) local dp = minetest.hash_node_position(pos)
if music.players[dp] ~= nil then if music.players[dp] ~= nil then
local node = core.get_node(pos) local node = minetest.get_node(pos)
if node.name ~= "music:player" then if node.name ~= "music:player" then
music.stop(pos) music.stop(pos)
@ -74,7 +74,7 @@ if core.setting_getbool("music_enable") then
end end
function music.toggle(pos) function music.toggle(pos)
local dp = core.hash_node_position(pos) local dp = minetest.hash_node_position(pos)
if music.players[dp] == nil then if music.players[dp] == nil then
music.start(pos) music.start(pos)
@ -83,7 +83,7 @@ if core.setting_getbool("music_enable") then
end end
end end
core.register_node( minetest.register_node(
"music:player", "music:player",
{ {
description = "Music player", description = "Music player",
@ -124,16 +124,16 @@ if core.setting_getbool("music_enable") then
end end
end end
core.register_globalstep(step) minetest.register_globalstep(step)
core.register_abm( minetest.register_abm(
{ {
nodenames = {"music:player"}, nodenames = {"music:player"},
chance = 1, chance = 1,
interval = 1, interval = 1,
action = function(pos, node) action = function(pos, node)
if music.players[core.hash_node_position(pos)] == nil then if music.players[minetest.hash_node_position(pos)] == nil then
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_int("music_player_enabled") == 1 then if meta:get_int("music_player_enabled") == 1 then
music.start(pos) music.start(pos)
end end
@ -141,7 +141,7 @@ if core.setting_getbool("music_enable") then
end end
}) })
else else
core.register_node( minetest.register_node(
"music:player", "music:player",
{ {
description = "Music player", description = "Music player",
@ -160,7 +160,7 @@ else
}, },
on_construct = function(pos) on_construct = function(pos)
local meta = core.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Music player(Disabled by server)") meta:set_string("infotext", "Music player(Disabled by server)")
end, end,
@ -169,7 +169,7 @@ else
}) })
end end
core.register_craft( minetest.register_craft(
{ {
output = "music:player", output = "music:player",
recipe = { recipe = {

View File

@ -3,7 +3,7 @@
local wield_image_0 = "nav_compass_inventory_0.png" local wield_image_0 = "nav_compass_inventory_0.png"
local wield_image_1 = "nav_compass_inventory_1.png" local wield_image_1 = "nav_compass_inventory_1.png"
core.register_craftitem( minetest.register_craftitem(
"nav:compass_0", "nav:compass_0",
{ {
description = "Compass(E)", description = "Compass(E)",
@ -15,7 +15,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"nav:compass_1", "nav:compass_1",
{ {
description = "Compass(NE)", description = "Compass(NE)",
@ -27,7 +27,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"nav:compass_2", "nav:compass_2",
{ {
description = "Compass(N)", description = "Compass(N)",
@ -39,7 +39,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"nav:compass_3", "nav:compass_3",
{ {
description = "Compass(NW)", description = "Compass(NW)",
@ -51,7 +51,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"nav:compass_4", "nav:compass_4",
{ {
description = "Compass(W)", description = "Compass(W)",
@ -63,7 +63,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"nav:compass_5", "nav:compass_5",
{ {
description = "Compass(SW)", description = "Compass(SW)",
@ -75,7 +75,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"nav:compass_6", "nav:compass_6",
{ {
description = "Compass(S)", description = "Compass(S)",
@ -87,7 +87,7 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_craftitem( minetest.register_craftitem(
"nav:compass_7", "nav:compass_7",
{ {
description = "Compass(SE)", description = "Compass(SE)",
@ -99,9 +99,9 @@ core.register_craftitem(
stack_max = 1, stack_max = 1,
}) })
core.register_alias("nav:compass", "nav:compass_2") minetest.register_alias("nav:compass", "nav:compass_2")
core.register_craft( minetest.register_craft(
{ {
output = "nav:compass_2", output = "nav:compass_2",
recipe = { recipe = {
@ -112,7 +112,7 @@ core.register_craft(
}) })
function step(dtime) function step(dtime)
for _, player in pairs(core.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local inv = player:get_inventory() local inv = player:get_inventory()
local yaw = player:get_look_yaw() local yaw = player:get_look_yaw()
@ -128,7 +128,7 @@ function step(dtime)
for i = 1, 8 do for i = 1, 8 do
local itemstack = inv:get_stack("main", i) local itemstack = inv:get_stack("main", i)
local item = core.registered_items[itemstack:get_name()] local item = minetest.registered_items[itemstack:get_name()]
if item ~= nil then if item ~= nil then
if item.groups.nav_compass then if item.groups.nav_compass then
@ -139,7 +139,7 @@ function step(dtime)
end end
end end
core.register_globalstep(step) minetest.register_globalstep(step)
-- Achievements -- Achievements

View File

@ -5,5 +5,5 @@
nav = {} nav = {}
dofile(core.get_modpath("nav").."/map.lua") dofile(minetest.get_modpath("nav").."/map.lua")
dofile(core.get_modpath("nav").."/compass.lua") dofile(minetest.get_modpath("nav").."/compass.lua")

View File

@ -47,7 +47,7 @@ local function get_formspec_waypoint(x, y, name, label, isinfo)
local form = "" local form = ""
form = form .. "image_button["..(x-0.72)..","..(y-0.53)..";0.5,0.5;"..img..";"..name..";;false;false;"..img.."]" form = form .. "image_button["..(x-0.72)..","..(y-0.53)..";0.5,0.5;"..img..";"..name..";;false;false;"..img.."]"
form = form .. "tooltip["..name..";"..core.formspec_escape(label).."]" form = form .. "tooltip["..name..";"..minetest.formspec_escape(label).."]"
return form return form
end end
@ -65,7 +65,7 @@ function nav.show_map(player)
form = form .. "field[-1,-1;0,0;nav_map_tracker;;]" form = form .. "field[-1,-1;0,0;nav_map_tracker;;]"
form = form .. "label[0.25,0.25;"..core.formspec_escape(name).." (x: "..math.floor(pos.x+0.5)..", y: "..math.floor(pos.y)..", z: "..math.floor(pos.z+0.5)..")]" form = form .. "label[0.25,0.25;"..minetest.formspec_escape(name).." (x: "..math.floor(pos.x+0.5)..", y: "..math.floor(pos.y)..", z: "..math.floor(pos.z+0.5)..")]"
form = form .. "image[0.5,3;6,6;nav_background.png]" form = form .. "image[0.5,3;6,6;nav_background.png]"
@ -84,9 +84,9 @@ function nav.show_map(player)
form = form .. "image[5.5,3;1,1;nav_map_compass.png]" form = form .. "image[5.5,3;1,1;nav_map_compass.png]"
form = form .. "label[6.25,6.6;"..nav.map_radius.."m]" form = form .. "label[6.25,6.6;"..nav.map_radius.."m]"
form = form .. "image[5.5,5.5;3,3;"..core.formspec_escape("nav_legend.png^[transformFX").."]" form = form .. "image[5.5,5.5;3,3;"..minetest.formspec_escape("nav_legend.png^[transformFX").."]"
core.show_formspec(name, "nav:map", form) minetest.show_formspec(name, "nav:map", form)
end end
local function recieve_fields(player, form_name, fields) local function recieve_fields(player, form_name, fields)
@ -97,11 +97,11 @@ local function recieve_fields(player, form_name, fields)
end end
end end
if core.setting_get_pos("static_spawnpoint") and (not core.is_singleplayer()) then if minetest.setting_get_pos("static_spawnpoint") and (not minetest.is_singleplayer()) then
core.after( minetest.after(
1.0, 1.0,
function() function()
nav.add_waypoint(core.setting_get_pos("static_spawnpoint"), nav.add_waypoint(minetest.setting_get_pos("static_spawnpoint"),
"spawn", "Spawn", true, "spawn") "spawn", "Spawn", true, "spawn")
end) end)
end end
@ -109,7 +109,7 @@ end
local function on_joinplayer(player) local function on_joinplayer(player)
local name = player:get_player_name() local name = player:get_player_name()
core.after( minetest.after(
1.0, 1.0,
function() function()
nav.add_waypoint(player:getpos(), "player_"..name, name, true, "player") nav.add_waypoint(player:getpos(), "player_"..name, name, true, "player")
@ -128,7 +128,7 @@ local function step(dtime)
if timer > update_time then if timer > update_time then
local players = {} local players = {}
for _, player in pairs(core.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
if player ~= nil then if player ~= nil then
local name = player:get_player_name() local name = player:get_player_name()
@ -140,7 +140,7 @@ local function step(dtime)
for wptname, wpt in pairs(nav.waypoints) do for wptname, wpt in pairs(nav.waypoints) do
if wpt.type == "player" then if wpt.type == "player" then
if players[wpt.label] ~= nil and core.get_player_by_name(wpt.label) ~= nil then if players[wpt.label] ~= nil and minetest.get_player_by_name(wpt.label) ~= nil then
nav.relocate_waypoint(wptname, players[wpt.label]:getpos()) nav.relocate_waypoint(wptname, players[wpt.label]:getpos())
end end
end end
@ -150,7 +150,7 @@ local function step(dtime)
end end
end end
core.register_craftitem( minetest.register_craftitem(
"nav:map", "nav:map",
{ {
description = "Map", description = "Map",
@ -163,7 +163,7 @@ core.register_craftitem(
end, end,
}) })
core.register_craft( minetest.register_craft(
{ {
output = "nav:map", output = "nav:map",
recipe = { recipe = {
@ -174,10 +174,10 @@ core.register_craft(
}) })
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer) minetest.register_on_leaveplayer(on_leaveplayer)
core.register_globalstep(step) minetest.register_globalstep(step)
core.register_on_player_receive_fields(recieve_fields) minetest.register_on_player_receive_fields(recieve_fields)
-- Achievements -- Achievements

View File

@ -14,7 +14,7 @@ function a(v)
return ((m * g + 0.5 * cw * rho * A * v * v) / m) return ((m * g + 0.5 * cw * rho * A * v * v) / m)
end end
core.register_craftitem( minetest.register_craftitem(
"parachute:parachute", { "parachute:parachute", {
description = "Parachute", description = "Parachute",
inventory_image = "parachute_inventory.png", inventory_image = "parachute_inventory.png",
@ -23,7 +23,7 @@ core.register_craftitem(
on_use = function(itemstack, player, pointed_thing) on_use = function(itemstack, player, pointed_thing)
local pos = player:getpos() local pos = player:getpos()
local on = core.get_node({x = pos.x, y = pos.y - 1, z = pos.z}) local on = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
if default.player_attached[player:get_player_name()] then if default.player_attached[player:get_player_name()] then
return return
@ -33,7 +33,7 @@ core.register_craftitem(
-- Spawn parachute -- Spawn parachute
pos.y = pos.y + 3 pos.y = pos.y + 3
local ent = core.add_entity(pos, "parachute:entity") local ent = minetest.add_entity(pos, "parachute:entity")
ent:setvelocity({x = 0, y = player:get_player_velocity().y, z = 0}) ent:setvelocity({x = 0, y = player:get_player_velocity().y, z = 0})
@ -48,14 +48,14 @@ core.register_craftitem(
itemstack:take_item() itemstack:take_item()
return itemstack return itemstack
else else
core.chat_send_player( minetest.chat_send_player(
player:get_player_name(), player:get_player_name(),
"Cannot open parachute on ground!") "Cannot open parachute on ground!")
end end
end end
}) })
core.register_entity( minetest.register_entity(
"parachute:entity", "parachute:entity",
{ {
visual = "mesh", visual = "mesh",
@ -66,7 +66,7 @@ core.register_entity(
attached = nil, attached = nil,
on_step = function(self, dtime) on_step = function(self, dtime)
local pos = self.object:getpos() local pos = self.object:getpos()
local under = core.get_node({x = pos.x, y = pos.y - 1, z = pos.z}) local under = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
if self.attached ~= nil then if self.attached ~= nil then
local vel = self.object:getvelocity() local vel = self.object:getvelocity()
@ -119,7 +119,7 @@ core.register_entity(
end end
}) })
core.register_craft( minetest.register_craft(
{ {
output = "parachute:parachute", output = "parachute:parachute",
recipe = { recipe = {

View File

@ -6,15 +6,15 @@
partialblocks = {} partialblocks = {}
function partialblocks.register_material(name, desc, node, can_burn) function partialblocks.register_material(name, desc, node, can_burn)
local nodedef = core.registered_nodes[node] local nodedef = minetest.registered_nodes[node]
if nodedef == nil then if nodedef == nil then
core.log("warning", "Cannot find node for partialblock: " .. node) minetest.log("warning", "Cannot find node for partialblock: " .. node)
return return
end end
-- Slab -- Slab
core.register_node( minetest.register_node(
"partialblocks:" .. name .. "_slab", "partialblocks:" .. name .. "_slab",
{ {
tiles = nodedef.tiles, tiles = nodedef.tiles,
@ -34,14 +34,14 @@ function partialblocks.register_material(name, desc, node, can_burn)
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
}) })
core.register_craft( -- Craft to minetest.register_craft( -- Craft to
{ {
output = "partialblocks:" .. name .. "_slab 3", output = "partialblocks:" .. name .. "_slab 3",
recipe = { recipe = {
{node, node, node}, {node, node, node},
}, },
}) })
core.register_craft( -- Craft back minetest.register_craft( -- Craft back
{ {
output = node, output = node,
type = "shapeless", type = "shapeless",
@ -49,7 +49,7 @@ function partialblocks.register_material(name, desc, node, can_burn)
}) })
if can_burn then if can_burn then
core.register_craft( -- Fuel minetest.register_craft( -- Fuel
{ {
type = "fuel", type = "fuel",
recipe = "partialblocks:" .. name .. "_slab", recipe = "partialblocks:" .. name .. "_slab",
@ -58,7 +58,7 @@ function partialblocks.register_material(name, desc, node, can_burn)
end end
-- Stair -- Stair
core.register_node( minetest.register_node(
"partialblocks:" .. name .. "_stair", "partialblocks:" .. name .. "_stair",
{ {
tiles = nodedef.tiles, tiles = nodedef.tiles,
@ -79,7 +79,7 @@ function partialblocks.register_material(name, desc, node, can_burn)
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
}) })
core.register_craft( -- Craft to minetest.register_craft( -- Craft to
{ {
output = "partialblocks:" .. name .. "_stair 6", output = "partialblocks:" .. name .. "_stair 6",
recipe = { recipe = {
@ -88,7 +88,7 @@ function partialblocks.register_material(name, desc, node, can_burn)
{node, node, node}, {node, node, node},
}, },
}) })
core.register_craft( -- Craft back minetest.register_craft( -- Craft back
{ {
output = node, output = node,
type = "shapeless", type = "shapeless",
@ -96,7 +96,7 @@ function partialblocks.register_material(name, desc, node, can_burn)
}) })
if can_burn then if can_burn then
core.register_craft( -- Fuel minetest.register_craft( -- Fuel
{ {
type = "fuel", type = "fuel",
recipe = "partialblocks:" .. name .. "_stair", recipe = "partialblocks:" .. name .. "_stair",

View File

@ -10,12 +10,12 @@ player_effects.registered_effects = {}
local update_time = 1 -- update every second local update_time = 1 -- update every second
local timer = 10 local timer = 10
local effects_file = core.get_worldpath() .. "/player_effects" local effects_file = minetest.get_worldpath() .. "/player_effects"
local function save_effects() local function save_effects()
local f = io.open(effects_file, "w") local f = io.open(effects_file, "w")
f:write(core.serialize(player_effects.effects)) f:write(minetest.serialize(player_effects.effects))
io.close(f) io.close(f)
end end
@ -24,7 +24,7 @@ local function load_effects()
local f = io.open(effects_file, "r") local f = io.open(effects_file, "r")
if f then if f then
player_effects.effects = core.deserialize(f:read("*all")) player_effects.effects = minetest.deserialize(f:read("*all"))
io.close(f) io.close(f)
else else
@ -59,7 +59,7 @@ function player_effects.apply_effect(player, ename)
local effect = player_effects.get_registered_effect(ename) local effect = player_effects.get_registered_effect(ename)
if effect.duration >= 0 then if effect.duration >= 0 then
player_effects.effects[player:get_player_name()][ename] = core.get_gametime() + effect.duration player_effects.effects[player:get_player_name()][ename] = minetest.get_gametime() + effect.duration
else else
player_effects.effects[player:get_player_name()][ename] = -1 player_effects.effects[player:get_player_name()][ename] = -1
end end
@ -153,9 +153,9 @@ end
local function step(dtime) local function step(dtime)
timer = timer + dtime timer = timer + dtime
if timer > update_time then if timer > update_time then
local gt = core.get_gametime() local gt = minetest.get_gametime()
for _, player in pairs(core.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
for ename, endtime in pairs(player_effects.effects[name]) do for ename, endtime in pairs(player_effects.effects[name]) do
@ -193,12 +193,12 @@ local function on_dieplayer(player)
player_effects.clear_effects(player) player_effects.clear_effects(player)
end end
core.register_globalstep(step) minetest.register_globalstep(step)
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer) minetest.register_on_leaveplayer(on_leaveplayer)
core.register_on_dieplayer(on_dieplayer) minetest.register_on_dieplayer(on_dieplayer)
core.register_chatcommand( minetest.register_chatcommand(
"player_effects", "player_effects",
{ {
description = "Show current player effects", description = "Show current player effects",
@ -210,16 +210,16 @@ core.register_chatcommand(
if endtime < 0 then if endtime < 0 then
s = s .. " " .. player_effects.registered_effects[ename].title .. ": unlimited\n" s = s .. " " .. player_effects.registered_effects[ename].title .. ": unlimited\n"
else else
s = s .. " " .. player_effects.registered_effects[ename].title .. ": " .. (endtime - core.get_gametime()) .. " seconds remaining\n" s = s .. " " .. player_effects.registered_effects[ename].title .. ": " .. (endtime - minetest.get_gametime()) .. " seconds remaining\n"
end end
ea = ea + 1 ea = ea + 1
end end
if ea > 0 then if ea > 0 then
core.chat_send_player(name, s) minetest.chat_send_player(name, s)
else else
core.chat_send_player(name, "You currently have no effects") minetest.chat_send_player(name, "You currently have no effects")
end end
end end
}) })
@ -244,15 +244,15 @@ player_effects.register_effect(
speed = 2, speed = 2,
} }
}) })
core.register_privilege("uberspeed", "Can use /uberspeed command") minetest.register_privilege("uberspeed", "Can use /uberspeed command")
core.register_chatcommand( minetest.register_chatcommand(
"uberspeed", "uberspeed",
{ {
params = "[on|off|cinematic]", params = "[on|off|cinematic]",
description = "Set Uberspeed", description = "Set Uberspeed",
privs = {uberspeed = true}, privs = {uberspeed = true},
func = function(name, param) func = function(name, param)
local player=core.get_player_by_name(name) local player=minetest.get_player_by_name(name)
if param == "on" then if param == "on" then
player_effects.apply_effect(player, "uberspeed") player_effects.apply_effect(player, "uberspeed")
@ -262,7 +262,7 @@ core.register_chatcommand(
player_effects.remove_effect(player, "uberspeed") player_effects.remove_effect(player, "uberspeed")
player_effects.remove_effect(player, "uberspeed_cinematic") player_effects.remove_effect(player, "uberspeed_cinematic")
else else
core.chat_send_player(name, "Bad param for /uberspeed; type /help uberspeed") minetest.chat_send_player(name, "Bad param for /uberspeed; type /help uberspeed")
end end
end end
}) })

View File

@ -7,8 +7,8 @@ player_skins = {}
player_skins.skin_names = {"male", "female"} player_skins.skin_names = {"male", "female"}
if core.setting_get("player_skins_names") then if minetest.setting_get("player_skins_names") then
player_skins.skin_names = util.split(core.setting_get("player_skins_names"), ",") player_skins.skin_names = util.split(minetest.setting_get("player_skins_names"), ",")
end end
player_skins.old_skins = {} player_skins.old_skins = {}
@ -16,7 +16,7 @@ player_skins.skins = {}
local update_time = 1 local update_time = 1
local timer = 10 local timer = 10
local skins_file = core.get_worldpath() .. "/player_skins" local skins_file = minetest.get_worldpath() .. "/player_skins"
local function save_skins() local function save_skins()
local f = io.open(skins_file, "w") local f = io.open(skins_file, "w")
@ -62,22 +62,22 @@ function player_skins.get_skin(name)
end end
function player_skins.set_skin(name, tex) function player_skins.set_skin(name, tex)
if core.check_player_privs(name, {player_skin = true}) then if minetest.check_player_privs(name, {player_skin = true}) then
if is_valid_skin(tex) then if is_valid_skin(tex) then
player_skins.skins[name] = tex player_skins.skins[name] = tex
save_skins() save_skins()
else else
core.chat_send_player(name, "Invalid skin") minetest.chat_send_player(name, "Invalid skin")
end end
else else
core.chat_send_player(name, "You do not have the privilege to change your skin.") minetest.chat_send_player(name, "You do not have the privilege to change your skin.")
end end
end end
local function step(dtime) local function step(dtime)
timer = timer + dtime timer = timer + dtime
if timer > update_time then if timer > update_time then
for _, player in pairs(core.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
if player_skins.skins[name] ~= player_skins.old_skins[name] then if player_skins.skins[name] ~= player_skins.old_skins[name] then
@ -97,8 +97,8 @@ local function on_joinplayer(player)
end end
end end
core.register_globalstep(step) minetest.register_globalstep(step)
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
local function get_chatparams() local function get_chatparams()
local s = "[" local s = "["
@ -138,7 +138,7 @@ function player_skins.get_formspec(playername)
return form return form
end end
core.register_on_player_receive_fields( minetest.register_on_player_receive_fields(
function(player, form_name, fields) function(player, form_name, fields)
local name = player:get_player_name() local name = player:get_player_name()
@ -148,13 +148,13 @@ core.register_on_player_receive_fields(
if skinname ~= nil then if skinname ~= nil then
player_skins.set_skin(name, skinname) player_skins.set_skin(name, skinname)
core.show_formspec(name, "core_player_skins", player_skins.get_formspec(name)) minetest.show_formspec(name, "core_player_skins", player_skins.get_formspec(name))
end end
end end
end) end)
core.register_privilege("player_skin", "Can change player skin") minetest.register_privilege("player_skin", "Can change player skin")
core.register_chatcommand( minetest.register_chatcommand(
"player_skin", "player_skin",
{ {
params = get_chatparams(), params = get_chatparams(),
@ -164,13 +164,13 @@ core.register_chatcommand(
if is_valid_skin(param) then if is_valid_skin(param) then
player_skins.set_skin(name, param) player_skins.set_skin(name, param)
elseif param == "" then elseif param == "" then
core.chat_send_player(name, "Current player skin: " .. player_skins.skins[name]) minetest.chat_send_player(name, "Current player skin: " .. player_skins.skins[name])
else else
core.chat_send_player(name, "Bad param for /player_skin; type /help player_skin") minetest.chat_send_player(name, "Bad param for /player_skin; type /help player_skin")
end end
end end
}) })
core.after(1.0, load_skins) minetest.after(1.0, load_skins)
default.log("mod:player_skins", "loaded") default.log("mod:player_skins", "loaded")

View File

@ -38,30 +38,30 @@ end
local function on_joinplayer(player) local function on_joinplayer(player)
local name = player:get_player_name() local name = player:get_player_name()
playerlist.players[name] = core.get_gametime() playerlist.players[name] = minetest.get_gametime()
end end
local function on_leaveplayer(player) local function on_leaveplayer(player)
local name = player:get_player_name() local name = player:get_player_name()
playerlist.players[name] = core.get_gametime() playerlist.players[name] = minetest.get_gametime()
end end
core.register_on_joinplayer(on_joinplayer) minetest.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer) minetest.register_on_leaveplayer(on_leaveplayer)
core.register_chatcommand( minetest.register_chatcommand(
"plist", "plist",
{ {
params = "[all|recent]", params = "[all|recent]",
description = "List players that are connected and have connected since the last server restart", description = "List players that are connected and have connected since the last server restart",
func = function(player_name, param) func = function(player_name, param)
local time = core.get_gametime() local time = minetest.get_gametime()
local str = "" local str = ""
if param == "all" then if param == "all" then
core.chat_send_player(player_name, "Players:") minetest.chat_send_player(player_name, "Players:")
elseif param == "recent" then elseif param == "recent" then
str = str .. "Recent players: " str = str .. "Recent players: "
else else
@ -70,14 +70,14 @@ core.register_chatcommand(
local player_count = 0 local player_count = 0
for name, jointime in pairs(playerlist.players) do for name, jointime in pairs(playerlist.players) do
local plyr = core.get_player_by_name(name) local plyr = minetest.get_player_by_name(name)
if param == "all" then if param == "all" then
if plyr ~= nil then if plyr ~= nil then
player_count = player_count + 1 player_count = player_count + 1
core.chat_send_player(player_name, " " .. name .. ": connected for " .. prettytime(time - jointime)) minetest.chat_send_player(player_name, " " .. name .. ": connected for " .. prettytime(time - jointime))
else else
core.chat_send_player(player_name, " " .. name .. ": last seen " .. prettytime(time - jointime) .. " ago") minetest.chat_send_player(player_name, " " .. name .. ": last seen " .. prettytime(time - jointime) .. " ago")
end end
else else
if param == "recent" then if param == "recent" then
@ -92,12 +92,12 @@ core.register_chatcommand(
end end
end end
core.chat_send_player(player_name, str) minetest.chat_send_player(player_name, str)
if param == "recent" then if param == "recent" then
core.chat_send_player(player_name, player_count .. " recent players") minetest.chat_send_player(player_name, player_count .. " recent players")
else else
core.chat_send_player(player_name, player_count .. " connected players") minetest.chat_send_player(player_name, player_count .. " connected players")
end end
end end
}) })

View File

@ -3,12 +3,12 @@
-- By Kaadmy, for Pixture -- By Kaadmy, for Pixture
-- --
local enable_saving = core.setting_getbool("pm_enable_saving") local enable_saving = minetest.setting_getbool("pm_enable_saving")
if enable_saving == nil then enable_saving = true end if enable_saving == nil then enable_saving = true end
local messages = {} local messages = {}
core.register_chatcommand( minetest.register_chatcommand(
"pm", "pm",
{ {
params = "<player> <message>", params = "<player> <message>",
@ -19,7 +19,7 @@ core.register_chatcommand(
if not sendto then return false, "Invalid usage, see /help pm." end if not sendto then return false, "Invalid usage, see /help pm." end
if not core.get_player_by_name(sendto) then if not minetest.get_player_by_name(sendto) then
if enable_saving then if enable_saving then
if messages[sendto] == nil then messages[sendto] = {} end if messages[sendto] == nil then messages[sendto] = {} end
table.insert(messages[sendto], name .. ": " .. message) table.insert(messages[sendto], name .. ": " .. message)
@ -32,15 +32,15 @@ core.register_chatcommand(
end end
end end
core.log("action", "PM from " .. name .. " to " .. sendto minetest.log("action", "PM from " .. name .. " to " .. sendto
.. ": " .. message) .. ": " .. message)
core.chat_send_player(sendto, "PM from " .. name .. ": " minetest.chat_send_player(sendto, "PM from " .. name .. ": "
.. message) .. message)
return true, "PM sent." return true, "PM sent."
end end
}) })
core.register_chatcommand( minetest.register_chatcommand(
"pms", "pms",
{ {
description = "Show saved private messages", description = "Show saved private messages",
@ -48,7 +48,7 @@ core.register_chatcommand(
if not enable_saving then return false, "PM saving is disabled." end if not enable_saving then return false, "PM saving is disabled." end
if messages[name] == nil then return false, "No saved PMs." end if messages[name] == nil then return false, "No saved PMs." end
core.chat_send_player(name, "Saved PMs:") minetest.chat_send_player(name, "Saved PMs:")
local str = "" local str = ""
local amt_pms = 0 local amt_pms = 0
@ -57,7 +57,7 @@ core.register_chatcommand(
str = str .. " " .. msg .. "\n" str = str .. " " .. msg .. "\n"
end end
core.chat_send_player(name, str) minetest.chat_send_player(name, str)
messages[name] = nil messages[name] = nil
@ -66,15 +66,15 @@ core.register_chatcommand(
}) })
if enable_saving then if enable_saving then
core.register_on_joinplayer( minetest.register_on_joinplayer(
function(player) function(player)
local name = player:get_player_name() local name = player:get_player_name()
if messages[name] ~= nil and #messages[name] >= 1 then if messages[name] ~= nil and #messages[name] >= 1 then
core.chat_send_player(name, core.colorize("#0ff", "You have " .. #messages[name] .. " saved PMs. Type /pms to view.")) minetest.chat_send_player(name, core.colorize("#0ff", "You have " .. #messages[name] .. " saved PMs. Type /pms to view."))
return false return false
else else
core.chat_send_player(name, core.colorize("#0ff", "You have no saved PMs. Send PMs with the /pm command.")) minetest.chat_send_player(name, core.colorize("#0ff", "You have no saved PMs. Send PMs with the /pm command."))
return true return true
end end
end) end)

View File

@ -3,7 +3,7 @@
-- By Kaadmy, for Pixture -- By Kaadmy, for Pixture
-- --
if core.setting_getbool("testing_enable") then if minetest.setting_getbool("testing_enable") then
local t1 = os.clock() local t1 = os.clock()
for i = 1, 10000 do for i = 1, 10000 do
dump({x=0,y=50,z=100}) dump({x=0,y=50,z=100})
@ -18,9 +18,9 @@ if core.setting_getbool("testing_enable") then
local t3 = os.clock() local t3 = os.clock()
for i = 1, 10000 do for i = 1, 10000 do
core.serialize({x=0,y=50,z=100}) minetest.serialize({x=0,y=50,z=100})
end end
print(string.format("10000 iterations with core.serialize({x=0,y=50,z=100}) took %.2fms", (os.clock() - t3) * 1000)) print(string.format("10000 iterations with minetest.serialize({x=0,y=50,z=100}) took %.2fms", (os.clock() - t3) * 1000))
local t4 = os.clock() local t4 = os.clock()
for i = 1, 10000 do for i = 1, 10000 do
@ -30,7 +30,7 @@ if core.setting_getbool("testing_enable") then
local t5 = os.clock() local t5 = os.clock()
for i = 1, 10000 do for i = 1, 10000 do
core.hash_node_position({x=0,y=50,z=100}) minetest.hash_node_position({x=0,y=50,z=100})
end end
print(string.format("10000 iterations with core.hash_node_position({x=0,y=50,z=100}) took %.2fms", (os.clock() - t5) * 1000)) print(string.format("10000 iterations with minetest.hash_node_position({x=0,y=50,z=100}) took %.2fms", (os.clock() - t5) * 1000))
end end

View File

@ -7,8 +7,8 @@
tnt = {} tnt = {}
-- Default to enabled in singleplayer and disabled in multiplayer -- Default to enabled in singleplayer and disabled in multiplayer
local singleplayer = core.is_singleplayer() local singleplayer = minetest.is_singleplayer()
local setting = core.setting_getbool("tnt_enable") local setting = minetest.setting_getbool("tnt_enable")
if (not singleplayer and setting ~= true) or (singleplayer and setting == false) then if (not singleplayer and setting ~= true) or (singleplayer and setting == false) then
return return
@ -20,15 +20,15 @@ local loss_prob = {}
loss_prob["default:cobble"] = 3 loss_prob["default:cobble"] = 3
loss_prob["default:dirt"] = 4 loss_prob["default:dirt"] = 4
local radius = tonumber(core.setting_get("tnt_radius") or 3) local radius = tonumber(minetest.setting_get("tnt_radius") or 3)
-- Fill a list with data for content IDs, after all nodes are registered -- Fill a list with data for content IDs, after all nodes are registered
local cid_data = {} local cid_data = {}
core.after( minetest.after(
0, 0,
function() function()
for name, def in pairs(core.registered_nodes) do for name, def in pairs(minetest.registered_nodes) do
cid_data[core.get_content_id(name)] = { cid_data[minetest.get_content_id(name)] = {
name = name, name = name,
drops = def.drops, drops = def.drops,
on_blast = def.on_blast, on_blast = def.on_blast,
@ -54,7 +54,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 = core.add_item(drop_pos, item) local obj = minetest.add_item(drop_pos, item)
if obj then if obj then
obj:get_luaentity().collect = true obj:get_luaentity().collect = true
obj:setacceleration({x=0, y=-10, z=0}) obj:setacceleration({x=0, y=-10, z=0})
@ -82,7 +82,7 @@ local function add_drop(drops, item)
end end
local function destroy(drops, pos, cid) local function destroy(drops, pos, cid)
if core.is_protected(pos, "") then if minetest.is_protected(pos, "") then
return return
end end
local def = cid_data[cid] local def = cid_data[cid]
@ -91,9 +91,9 @@ local function destroy(drops, pos, cid)
return return
end end
core.remove_node(pos) minetest.remove_node(pos)
if def then if def then
local node_drops = core.get_node_drops(def.name, "") local node_drops = minetest.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
@ -120,9 +120,9 @@ 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 no_water = (core.find_node_near(pos, 2, {"default:water_source"}) == nil) local no_water = (minetest.find_node_near(pos, 2, {"default:water_source"}) == nil)
local objs = core.get_objects_inside_radius(pos, radius) local objs = minetest.get_objects_inside_radius(pos, radius)
for _, obj in pairs(objs) do for _, obj in pairs(objs) do
local obj_pos = obj:getpos() local obj_pos = obj:getpos()
local obj_vel = obj:getvelocity() local obj_vel = obj:getvelocity()
@ -141,7 +141,7 @@ local function entity_physics(pos, radius)
end end
local function add_effects(pos, radius) local function add_effects(pos, radius)
core.add_particlespawner( minetest.add_particlespawner(
{ {
amount = 128, amount = 128,
time = 1, time = 1,
@ -160,11 +160,11 @@ local function add_effects(pos, radius)
end end
function tnt.burn(pos) function tnt.burn(pos)
local name = core.get_node(pos).name local name = minetest.get_node(pos).name
if name == "tnt:tnt" then if name == "tnt:tnt" then
core.sound_play("tnt_ignite", {pos = pos}) minetest.sound_play("tnt_ignite", {pos = pos})
core.set_node(pos, {name = "tnt:tnt_burning"}) minetest.set_node(pos, {name = "tnt:tnt_burning"})
core.get_node_timer(pos):start(2) minetest.get_node_timer(pos):start(2)
end end
end end
@ -181,7 +181,7 @@ local function explode(pos, radius)
local drops = {} local drops = {}
local p = {} local p = {}
local c_air = core.get_content_id("air") local c_air = minetest.get_content_id("air")
for z = -radius, radius do for z = -radius, radius do
for y = -radius, radius do for y = -radius, radius do
@ -206,8 +206,8 @@ end
function tnt.boom(pos) function tnt.boom(pos)
core.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = 128}) minetest.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = 128})
core.remove_node(pos) minetest.remove_node(pos)
local drops = explode(pos, radius) local drops = explode(pos, radius)
entity_physics(pos, radius) entity_physics(pos, radius)
@ -215,7 +215,7 @@ function tnt.boom(pos)
add_effects(pos, radius) add_effects(pos, radius)
end end
core.register_node( minetest.register_node(
"tnt:tnt", "tnt:tnt",
{ {
description = "TNT", description = "TNT",
@ -235,7 +235,7 @@ core.register_node(
end, end,
}) })
core.register_node( minetest.register_node(
"tnt:tnt_burning", "tnt:tnt_burning",
{ {
tiles = { tiles = {
@ -258,7 +258,7 @@ core.register_node(
on_blast = function() end, on_blast = function() end,
}) })
core.register_craft( minetest.register_craft(
{ {
output = "tnt:tnt", output = "tnt:tnt",
recipe = { recipe = {
@ -268,7 +268,7 @@ core.register_craft(
} }
}) })
core.register_craft( minetest.register_craft(
{ {
type = "fuel", type = "fuel",
recipe = "tnt:tnt", recipe = "tnt:tnt",

View File

@ -28,11 +28,11 @@ function util.fixlight(pos1, pos2)
--make area stay loaded --make area stay loaded
local manip = core.get_voxel_manip() local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2) manip:read_from_map(pos1, pos2)
local nodes = core.find_nodes_in_area(pos1, pos2, "air") local nodes = minetest.find_nodes_in_area(pos1, pos2, "air")
local dig_node = core.dig_node local dig_node = minetest.dig_node
for _, pos in ipairs(nodes) do for _, pos in ipairs(nodes) do
dig_node(pos) dig_node(pos)
end end
@ -41,10 +41,10 @@ function util.fixlight(pos1, pos2)
return #nodes return #nodes
end end
if core.setting_getbool("fixlight_command_enable") then if minetest.setting_getbool("fixlight_command_enable") then
core.register_privilege("fixlight", "Can use /fixlight command") minetest.register_privilege("fixlight", "Can use /fixlight command")
core.register_chatcommand( minetest.register_chatcommand(
"fixlight", "fixlight",
{ {
params = "[radius 1-20]", params = "[radius 1-20]",
@ -57,7 +57,7 @@ if core.setting_getbool("fixlight_command_enable") then
return false, "Bad param for /fixlight; type /help fixlight" return false, "Bad param for /fixlight; type /help fixlight"
end end
local player = core.get_player_by_name(name) local player = minetest.get_player_by_name(name)
local pos = player:getpos() local pos = player:getpos()
pos.x = math.floor(pos.x + 0.5) pos.x = math.floor(pos.x + 0.5)
@ -69,7 +69,7 @@ if core.setting_getbool("fixlight_command_enable") then
util.fixlight(minp, maxp) util.fixlight(minp, maxp)
core.chat_send_all("*** " .. name .. " has fixed light in a " .. rad .. "m radius at (" .. pos.x .. ", " .. pos.y .. ", " .. pos.z .. ")") minetest.chat_send_all("*** " .. name .. " has fixed light in a " .. rad .. "m radius at (" .. pos.x .. ", " .. pos.y .. ", " .. pos.z .. ")")
end end
}) })
end end
@ -80,11 +80,11 @@ function util.nodefunc(pos1, pos2, name, func, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2) local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then if not nomanip then
local manip = core.get_voxel_manip() local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2) manip:read_from_map(pos1, pos2)
end end
local nodes = core.find_nodes_in_area(pos1, pos2, name) local nodes = minetest.find_nodes_in_area(pos1, pos2, name)
for _, pos in ipairs(nodes) do for _, pos in ipairs(nodes) do
func(pos) func(pos)
end end
@ -95,7 +95,7 @@ function util.getvoxelmanip(pos1, pos2)
-- return a voxel manipulator -- return a voxel manipulator
local pos1, pos2 = util.sort_pos(pos1, pos2) local pos1, pos2 = util.sort_pos(pos1, pos2)
local manip = core.get_voxel_manip() local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2) manip:read_from_map(pos1, pos2)
return manip return manip
@ -107,14 +107,14 @@ function util.remove_area(pos1, pos2, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2) local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then if not nomanip then
local manip = core.get_voxel_manip() local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2) manip:read_from_map(pos1, pos2)
end end
for i = pos1.x, pos2.x-1 do for i = pos1.x, pos2.x-1 do
for j = pos1.y, pos2.y-1 do for j = pos1.y, pos2.y-1 do
for k = pos1.z, pos2.z-1 do for k = pos1.z, pos2.z-1 do
core.remove_node({x = i, y = j, z = k}) minetest.remove_node({x = i, y = j, z = k})
end end
end end
end end
@ -128,7 +128,7 @@ function util.areafunc(pos1, pos2, func, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2) local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then if not nomanip then
local manip = core.get_voxel_manip() local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2) manip:read_from_map(pos1, pos2)
end end
@ -147,27 +147,27 @@ function util.reconstruct(pos1, pos2, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2) local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then if not nomanip then
local manip = core.get_voxel_manip() local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2) manip:read_from_map(pos1, pos2)
end end
-- fix chests -- fix chests
local nodes = core.find_nodes_in_area(pos1, pos2, "default:chest") local nodes = minetest.find_nodes_in_area(pos1, pos2, "default:chest")
local node = core.registered_nodes["default:chest"] local node = minetest.registered_nodes["default:chest"]
for _, pos in ipairs(nodes) do for _, pos in ipairs(nodes) do
node.on_construct(pos) node.on_construct(pos)
end end
-- fix music players -- fix music players
nodes = core.find_nodes_in_area(pos1, pos2, "music:player") nodes = minetest.find_nodes_in_area(pos1, pos2, "music:player")
node = core.registered_nodes["music:player"] node = minetest.registered_nodes["music:player"]
for _, pos in ipairs(nodes) do for _, pos in ipairs(nodes) do
node.on_construct(pos) node.on_construct(pos)
end end
-- fix furnaces -- fix furnaces
nodes = core.find_nodes_in_area(pos1, pos2, "default:furnace") nodes = minetest.find_nodes_in_area(pos1, pos2, "default:furnace")
node = core.registered_nodes["default:furnace"] node = minetest.registered_nodes["default:furnace"]
for _, pos in ipairs(nodes) do for _, pos in ipairs(nodes) do
node.on_construct(pos) node.on_construct(pos)
end end

View File

@ -2,21 +2,21 @@
-- Single village generation -- Single village generation
-- --
local mp = core.get_modpath("village") local mp = minetest.get_modpath("village")
village.villages = {} village.villages = {}
local village_file = core.get_worldpath() .. "/villages" local village_file = minetest.get_worldpath() .. "/villages"
function village.get_id(name, pos) function village.get_id(name, pos)
return name .. core.hash_node_position(pos) return name .. minetest.hash_node_position(pos)
end end
function village.save_villages() function village.save_villages()
local f = io.open(village_file, "w") local f = io.open(village_file, "w")
for name, def in pairs(village.villages) do for name, def in pairs(village.villages) do
f:write(name .. " " .. def.name .. " " .. core.hash_node_position(def.pos) .. "\n") f:write(name .. " " .. def.name .. " " .. minetest.hash_node_position(def.pos) .. "\n")
end end
io.close(f) io.close(f)
@ -33,7 +33,7 @@ function village.load_villages()
for name, fname, pos in string.gfind(l, "(.+) (%a+) (%d.+)") do for name, fname, pos in string.gfind(l, "(.+) (%a+) (%d.+)") do
village.villages[name] = { village.villages[name] = {
name = fname, name = fname,
pos = core.get_position_from_hash(pos), pos = minetest.get_position_from_hash(pos),
} }
end end
until f:read(0) == nil until f:read(0) == nil
@ -156,11 +156,11 @@ function village.lift_ground(pos, scanheight)
for y = pos.y, pos.y - scanheight, -1 do for y = pos.y, pos.y - scanheight, -1 do
local p = {x = pos.x, y = y, z = pos.z} local p = {x = pos.x, y = y, z = pos.z}
local nn = core.get_node(p).name local nn = minetest.get_node(p).name
local an = core.get_node({x = p.x, y = p.y + 1, z = p.z}).name local an = minetest.get_node({x = p.x, y = p.y + 1, z = p.z}).name
if nn ~= "air" then if nn ~= "air" then
local nd = core.registered_nodes[nn] local nd = minetest.registered_nodes[nn]
if not nd.buildable_to then -- avoid grass, fluids, etc. if not nd.buildable_to then -- avoid grass, fluids, etc.
if topnode == nil and nn ~= an then if topnode == nil and nn ~= an then
topnode = nn topnode = nn
@ -197,11 +197,11 @@ function village.lift_ground(pos, scanheight)
local th = pos.y - y local th = pos.y - y
if th <= fillerdepth - topdepth then if th <= fillerdepth - topdepth then
core.set_node(p, {name = fillernode}) minetest.set_node(p, {name = fillernode})
elseif th <= topdepth then elseif th <= topdepth then
core.set_node(p, {name = topnode}) minetest.set_node(p, {name = topnode})
else else
core.set_node(p, {name = stonenode}) minetest.set_node(p, {name = stonenode})
end end
end end
end end
@ -218,7 +218,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
village.lift_ground(pos, 15) -- distance to lift ground; larger numbers will be slower village.lift_ground(pos, 15) -- distance to lift ground; larger numbers will be slower
end, true) end, true)
core.place_schematic( minetest.place_schematic(
pos, pos,
mp.."/schematics/village_empty.mts", mp.."/schematics/village_empty.mts",
"0", "0",
@ -226,7 +226,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
true true
) )
core.place_schematic( minetest.place_schematic(
{x = pos.x-6, y = pos.y-5, z = pos.z-6}, {x = pos.x-6, y = pos.y-5, z = pos.z-6},
mp.."/schematics/village_filler.mts", mp.."/schematics/village_filler.mts",
"0", "0",
@ -235,7 +235,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
) )
end end
core.place_schematic( minetest.place_schematic(
pos, pos,
mp.."/schematics/village_"..chunktype..".mts", mp.."/schematics/village_"..chunktype..".mts",
orient, orient,
@ -260,7 +260,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
"music:player", "music:player",
function(pos) function(pos)
if pr:next(1, 2) > 1 then if pr:next(1, 2) > 1 then
core.remove_node(pos) minetest.remove_node(pos)
end end
end, true) end, true)
@ -273,7 +273,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
{x = pos.x+12, y = pos.y+12, z = pos.z+12}, {x = pos.x+12, y = pos.y+12, z = pos.z+12},
"village:entity_spawner", "village:entity_spawner",
function(pos) function(pos)
core.remove_node(pos) minetest.remove_node(pos)
end) end)
return return
end end
@ -286,7 +286,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
"village:entity_spawner", "village:entity_spawner",
function(pos) function(pos)
table.insert(ent_spawns, pos) table.insert(ent_spawns, pos)
core.remove_node(pos) minetest.remove_node(pos)
end, true) end, true)
if #ent_spawns > 0 then if #ent_spawns > 0 then
@ -295,7 +295,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
local spawn = util.choice_element(ent_spawns, pr) local spawn = util.choice_element(ent_spawns, pr)
if spawn ~= nil then if spawn ~= nil then
spawn.y = spawn.y + 1.6 spawn.y = spawn.y + 1.6
core.add_entity(spawn, ent) minetest.add_entity(spawn, ent)
end end
end end
end end
@ -335,7 +335,7 @@ function village.spawn_road(pos, houses, built, roads, depth, pr)
nextpos.x = nextpos.x + 12 nextpos.x = nextpos.x + 12
end end
local hnp = core.hash_node_position(nextpos) local hnp = minetest.hash_node_position(nextpos)
if built[hnp] == nil then if built[hnp] == nil then
built[hnp] = true built[hnp] = true
@ -372,14 +372,14 @@ function village.spawn_village(pos, pr)
local spawnpos = pos local spawnpos = pos
village.spawn_chunk(pos, "0", {}, pr, "well") village.spawn_chunk(pos, "0", {}, pr, "well")
built[core.hash_node_position(pos)] = true built[minetest.hash_node_position(pos)] = true
local t1 = os.clock() local t1 = os.clock()
village.spawn_road(pos, houses, built, roads, depth, pr) village.spawn_road(pos, houses, built, roads, depth, pr)
print(string.format("Took %.2fms to spawn village", (os.clock() - t1) * 1000)) print(string.format("Took %.2fms to spawn village", (os.clock() - t1) * 1000))
local function connects(pos, nextpos) local function connects(pos, nextpos)
local hnp = core.hash_node_position(nextpos) local hnp = minetest.hash_node_position(nextpos)
if houses[hnp] ~= nil then if houses[hnp] ~= nil then
if vector.equals(houses[hnp].front, pos) then if vector.equals(houses[hnp].front, pos) then
@ -451,7 +451,7 @@ function village.spawn_village(pos, pr)
end end
end end
core.after( minetest.after(
0, 0,
function() function()
village.load_villages() village.load_villages()

View File

@ -10,10 +10,10 @@ village.max_size = 6 -- max chunk gen iterations
village.min_spawn_dist = 256 -- closest distance a village will spawn from another village village.min_spawn_dist = 256 -- closest distance a village will spawn from another village
village.pr = PseudoRandom(core.get_mapgen_params().seed) village.pr = PseudoRandom(minetest.get_mapgen_params().seed)
dofile(core.get_modpath("village").."/names.lua") dofile(minetest.get_modpath("village").."/names.lua")
dofile(core.get_modpath("village").."/generate.lua") dofile(minetest.get_modpath("village").."/generate.lua")
dofile(core.get_modpath("village").."/mapgen.lua") dofile(minetest.get_modpath("village").."/mapgen.lua")
default.log("mod:village", "loaded") default.log("mod:village", "loaded")

View File

@ -1,4 +1,4 @@
core.register_node( minetest.register_node(
"village:entity_spawner", "village:entity_spawner",
{ {
description = "Chunk defs may choose which entities to spawn here", description = "Chunk defs may choose which entities to spawn here",
@ -8,7 +8,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults() sounds = default.node_sound_wood_defaults()
}) })
core.register_node( minetest.register_node(
"village:grassland_village", "village:grassland_village",
{ {
description = "Village spawner", description = "Village spawner",
@ -18,7 +18,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults() sounds = default.node_sound_wood_defaults()
}) })
core.register_node( minetest.register_node(
"village:grassland_village_mg", "village:grassland_village_mg",
{ {
description = "Mapgen village spawner(Has chance of not spawning village)", description = "Mapgen village spawner(Has chance of not spawning village)",
@ -35,42 +35,42 @@ core.register_node(
groups = {not_in_craftingguide = 1}, groups = {not_in_craftingguide = 1},
}) })
core.register_abm( minetest.register_abm(
{ {
nodenames = {"village:grassland_village", "village:grassland_village_mg"}, nodenames = {"village:grassland_village", "village:grassland_village_mg"},
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
core.remove_node(pos) minetest.remove_node(pos)
if core.setting_getbool("mapgen_disable_villages") == true then if minetest.setting_getbool("mapgen_disable_villages") == true then
return return
end end
local pr = PseudoRandom(core.get_mapgen_params().seed+pos.x+pos.y+pos.z) local pr = PseudoRandom(minetest.get_mapgen_params().seed+pos.x+pos.y+pos.z)
if node.name == "village:grassland_village_mg" then if node.name == "village:grassland_village_mg" then
if ((core.get_mapgen_params().seed+pos.x+pos.y+pos.z) % 30) == 1 then if ((minetest.get_mapgen_params().seed+pos.x+pos.y+pos.z) % 30) == 1 then
local nearest = village.get_nearest_village(pos) local nearest = village.get_nearest_village(pos)
if nearest.dist > village.min_spawn_dist then if nearest.dist > village.min_spawn_dist then
core.log("Spawning a (Mapgen)Grassland village at "..dump(pos)) minetest.log("Spawning a (Mapgen)Grassland village at "..dump(pos))
-- a short delay to (hopefully) ensure that the surrounding terrain is generated -- a short delay to (hopefully) ensure that the surrounding terrain is generated
core.after(3.0, function() village.spawn_village(pos, pr) end) minetest.after(3.0, function() village.spawn_village(pos, pr) end)
else else
core.log("Cannot spawn village, too near another village") minetest.log("Cannot spawn village, too near another village")
end end
end end
else else
core.log("Spawning a Grassland village at "..dump(pos)) minetest.log("Spawning a Grassland village at "..dump(pos))
village.spawn_village(pos, pr) village.spawn_village(pos, pr)
end end
end end
}) })
core.register_decoration( minetest.register_decoration(
{ {
deco_type = "simple", deco_type = "simple",
place_on = "default:dirt_with_grass", place_on = "default:dirt_with_grass",

View File

@ -11,29 +11,29 @@ local function addvec(v1, v2)
return {x = v1.x + v2.x, y = v1.y + v2.y, z = v1.z + v2.z} return {x = v1.x + v2.x, y = v1.y + v2.y, z = v1.z + v2.z}
end end
local snow_enable = core.setting_getbool("weather_snow_enable") or false local snow_enable = minetest.setting_getbool("weather_snow_enable") or false
local weather_soundspec=nil local weather_soundspec=nil
local weather_pr=PseudoRandom(core.get_mapgen_params().seed + 2387) local weather_pr=PseudoRandom(minetest.get_mapgen_params().seed + 2387)
local function play_sound() local function play_sound()
if weather_soundspec ~= nil then if weather_soundspec ~= nil then
core.sound_stop(weather_soundspec) minetest.sound_stop(weather_soundspec)
end end
if weather.weather == "storm" then if weather.weather == "storm" then
weather_soundspec=core.sound_play({name="weather_storm"}) weather_soundspec=minetest.sound_play({name="weather_storm"})
core.after(18, play_sound) minetest.after(18, play_sound)
return return
elseif weather.weather == "snowstorm" then elseif weather.weather == "snowstorm" then
weather_soundspec=core.sound_play({name="weather_snowstorm"}) weather_soundspec=minetest.sound_play({name="weather_snowstorm"})
core.after(7, play_sound) minetest.after(7, play_sound)
return return
end end
core.after(3, play_sound) minetest.after(3, play_sound)
end end
function setweather_type(type) function setweather_type(type)
@ -49,9 +49,9 @@ function setweather_type(type)
end end
end end
core.register_globalstep( minetest.register_globalstep(
function(dtime) function(dtime)
if core.setting_getbool("weather_enable") then if minetest.setting_getbool("weather_enable") then
if weather_pr:next(0, 5000) < 1 then if weather_pr:next(0, 5000) < 1 then
local weathertype = weather_pr:next(0, 19) local weathertype = weather_pr:next(0, 19)
@ -70,7 +70,7 @@ core.register_globalstep(
end end
end end
local light = (core.get_timeofday()*2) local light = (minetest.get_timeofday()*2)
if light > 1 then if light > 1 then
light=1-(light-1) light=1-(light-1)
@ -79,7 +79,7 @@ core.register_globalstep(
local skycol=math.floor(light*190) local skycol=math.floor(light*190)
for _,player in ipairs(core.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
if weather.weather == "storm" or weather.weather == "snowstorm" then if weather.weather == "storm" or weather.weather == "snowstorm" then
player:set_sky({r = skycol, g = skycol, b = skycol*1.2}, "plain", {}) player:set_sky({r = skycol, g = skycol, b = skycol*1.2}, "plain", {})
player:override_day_night_ratio(light) player:override_day_night_ratio(light)
@ -91,10 +91,10 @@ core.register_globalstep(
local p=player:getpos() local p=player:getpos()
if weather.weather == "storm" then if weather.weather == "storm" then
if core.get_node_light({x=p.x, y=p.y+15, z=p.z}, 0.5) == 15 then if minetest.get_node_light({x=p.x, y=p.y+15, z=p.z}, 0.5) == 15 then
local minpos = addvec(player:getpos(), {x = -15, y = 15, z = -15}) local minpos = addvec(player:getpos(), {x = -15, y = 15, z = -15})
local maxpos = addvec(player:getpos(), {x = 15, y = 10, z = 15}) local maxpos = addvec(player:getpos(), {x = 15, y = 10, z = 15})
core.add_particlespawner( minetest.add_particlespawner(
{ {
amount = 30, amount = 30,
time = 0.5, time = 0.5,
@ -118,17 +118,17 @@ core.register_globalstep(
if math.random(0, 6000*dtime) <= 1 then if math.random(0, 6000*dtime) <= 1 then
local hp = player:get_hp() local hp = player:get_hp()
if core.get_node_light(p) == 15 then if minetest.get_node_light(p) == 15 then
player:set_hp(hp-1) player:set_hp(hp-1)
end end
end end
if core.get_node_light({x=p.x, y=p.y+15, z=p.z}, 0.5) == 15 then if minetest.get_node_light({x=p.x, y=p.y+15, z=p.z}, 0.5) == 15 then
local minpos = addvec(player:getpos(), {x = -30, y = 20, z = -30}) local minpos = addvec(player:getpos(), {x = -30, y = 20, z = -30})
local maxpos = addvec(player:getpos(), {x = 30, y = 15, z = 30}) local maxpos = addvec(player:getpos(), {x = 30, y = 15, z = 30})
local vel = {x = 16.0, y = -8, z = 13.0} local vel = {x = 16.0, y = -8, z = 13.0}
local acc = {x = -16.0, y = -8, z = -13.0} local acc = {x = -16.0, y = -8, z = -13.0}
core.add_particlespawner( minetest.add_particlespawner(
{ {
amount = 8, amount = 8,
time = 0.4, time = 0.4,
@ -154,56 +154,56 @@ core.register_globalstep(
end end
) )
core.register_abm( minetest.register_abm(
{ {
nodenames = {"weather:ice"}, nodenames = {"weather:ice"},
interval = 4, interval = 4,
chance = 80, chance = 80,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
if weather.weather ~= "snowstorm" then if weather.weather ~= "snowstorm" then
core.remove_node(pos) minetest.remove_node(pos)
end end
end end
}) })
--[[core.register_abm( --[[minetest.register_abm(
{ {
nodenames = {"air"}, nodenames = {"air"},
interval = 2, interval = 2,
chance = 80, chance = 80,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
if core.get_node_light(pos) ~= 15 then return end if minetest.get_node_light(pos) ~= 15 then return end
local under_nodepos={x=pos.x, y=pos.y-1, z=pos.z} local under_nodepos={x=pos.x, y=pos.y-1, z=pos.z}
local under_node=core.get_node(under_nodepos) local under_node=minetest.get_node(under_nodepos)
if under_node.name == "air" then return end if under_node.name == "air" then return end
local under_nodedef=core.registered_nodes[under_node.name] local under_nodedef=minetest.registered_nodes[under_node.name]
if under_node.name == "default:water_source" and weather.weather == "snowstorm" then if under_node.name == "default:water_source" and weather.weather == "snowstorm" then
core.set_node(under_nodepos, {name = "weather:ice"}) minetest.set_node(under_nodepos, {name = "weather:ice"})
else else
if under_node.name ~= "weather:snow" then if under_node.name ~= "weather:snow" then
if weather.weather == "snowstorm" then if weather.weather == "snowstorm" then
if under_node.name ~= "default:heated_dirt_path" then if under_node.name ~= "default:heated_dirt_path" then
if under_nodedef.walkable then if under_nodedef.walkable then
core.set_node(pos, {name = "weather:snow"}) minetest.set_node(pos, {name = "weather:snow"})
elseif under_nodedef.drawtype ~= "airlike" and under_nodedef.buildable_to and math.random(0, 20) <= 1 then elseif under_nodedef.drawtype ~= "airlike" and under_nodedef.buildable_to and math.random(0, 20) <= 1 then
core.set_node(under_nodepos, {name = "weather:snow"}) minetest.set_node(under_nodepos, {name = "weather:snow"})
end end
end end
end end
else else
if weather.weather ~= "snowstorm" then if weather.weather ~= "snowstorm" then
core.remove_node(under_nodepos) minetest.remove_node(under_nodepos)
end end
end end
end end
end, end,
})--]] })--]]
core.register_node( minetest.register_node(
"weather:snow", "weather:snow",
{ {
description = "Snow", description = "Snow",
@ -218,7 +218,7 @@ core.register_node(
sounds = default.node_sound_snow_defaults(), sounds = default.node_sound_snow_defaults(),
}) })
core.register_node( minetest.register_node(
"weather:ice", "weather:ice",
{ {
description = "Ice", description = "Ice",
@ -230,18 +230,18 @@ core.register_node(
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
on_destruct = function(pos) on_destruct = function(pos)
local function add_water() local function add_water()
core.set_node(pos, {name = "default:water_source"}) minetest.set_node(pos, {name = "default:water_source"})
end end
if core.find_node_near(pos, 1, {"weather:ice", "default:water_source"}) then if minetest.find_node_near(pos, 1, {"weather:ice", "default:water_source"}) then
core.after(0, add_water) minetest.after(0, add_water)
end end
end end
}) })
core.register_privilege("weather", "Can use /weather.weather command") minetest.register_privilege("weather", "Can use /weather.weather command")
core.register_chatcommand( minetest.register_chatcommand(
"weather", "weather",
{ {
params = "[storm|snowstorm|clear]", params = "[storm|snowstorm|clear]",

View File

@ -15,8 +15,8 @@ welcome.rules = {
} }
function welcome.get_formspec(name) function welcome.get_formspec(name)
if not core.setting_getbool("welcome_enable") then if not minetest.setting_getbool("welcome_enable") then
core.chat_send_player(name, "Welcoming is disabled") minetest.chat_send_player(name, "Welcoming is disabled")
return "" return ""
end end
@ -27,12 +27,12 @@ function welcome.get_formspec(name)
for _, t in ipairs(welcome.rules) do for _, t in ipairs(welcome.rules) do
if rules ~= "" then rules = rules .. "," end if rules ~= "" then rules = rules .. "," end
rules = rules .. core.formspec_escape(t) rules = rules .. minetest.formspec_escape(t)
end end
form = form .. "textlist[0.25,0.75;7.75,6.75;rules;" .. rules .. "]" form = form .. "textlist[0.25,0.75;7.75,6.75;rules;" .. rules .. "]"
if not core.check_player_privs(name, {interact = true}) then if not minetest.check_player_privs(name, {interact = true}) then
form = form .. default.ui.button_exit(1.25, 7.75, 3, 1, "decline_rules", "Nope") form = form .. default.ui.button_exit(1.25, 7.75, 3, 1, "decline_rules", "Nope")
form = form .. default.ui.button_exit(4.25, 7.75, 3, 1, "accept_rules", "Okay") form = form .. default.ui.button_exit(4.25, 7.75, 3, 1, "accept_rules", "Okay")
else else
@ -46,14 +46,14 @@ function welcome.show_rules(name)
local f = welcome.get_formspec(name) local f = welcome.get_formspec(name)
if f ~= "" then if f ~= "" then
core.show_formspec(name, "welcome:welcome", f) minetest.show_formspec(name, "welcome:welcome", f)
end end
end end
core.register_on_player_receive_fields( minetest.register_on_player_receive_fields(
function(player, form_name, fields) function(player, form_name, fields)
local name = player:get_player_name() local name = player:get_player_name()
local privs = core.get_player_privs(name) local privs = minetest.get_player_privs(name)
if privs.interact or fields.rules then if privs.interact or fields.rules then
return return
@ -61,14 +61,14 @@ core.register_on_player_receive_fields(
if fields.accept_rules then if fields.accept_rules then
privs.interact = true privs.interact = true
core.set_player_privs(name, privs) minetest.set_player_privs(name, privs)
core.chat_send_player(name, "You now have interact, follow the rules and have fun!") minetest.chat_send_player(name, "You now have interact, follow the rules and have fun!")
else else
core.chat_send_player(name, "If you want to interact, please read and accept the rules. Type /welcome to show rules.") minetest.chat_send_player(name, "If you want to interact, please read and accept the rules. Type /welcome to show rules.")
end end
end) end)
core.register_chatcommand( minetest.register_chatcommand(
"welcome", "welcome",
{ {
description = "Show rules", description = "Show rules",
@ -77,11 +77,11 @@ core.register_chatcommand(
end end
}) })
core.register_on_joinplayer( minetest.register_on_joinplayer(
function(player) function(player)
local name = player:get_player_name() local name = player:get_player_name()
if not core.check_player_privs(name, {interact = true}) and core.setting_getbool("welcome_enable") then if not minetest.check_player_privs(name, {interact = true}) and minetest.setting_getbool("welcome_enable") then
welcome.show_rules(name) welcome.show_rules(name)
end end
end) end)

View File

@ -9,13 +9,13 @@ wielditem = {}
local update_time = 1 local update_time = 1
local timer = 10 -- needs to be more than update_time local timer = 10 -- needs to be more than update_time
core.register_craftitem( minetest.register_craftitem(
"wielditem:null", "wielditem:null",
{ {
wield_image = "ui_null.png" wield_image = "ui_null.png"
}) })
core.register_entity( minetest.register_entity(
"wielditem:wielditem", "wielditem:wielditem",
{ {
textures = {"default:broadsword"}, textures = {"default:broadsword"},
@ -33,7 +33,7 @@ core.register_entity(
on_step = function(self, dtime) on_step = function(self, dtime)
local player = self.wielder local player = self.wielder
if player == nil or (core.get_player_by_name(player:get_player_name()) == nil) then if player == nil or (minetest.get_player_by_name(player:get_player_name()) == nil) then
self.object:remove() self.object:remove()
return return
end end
@ -52,7 +52,7 @@ local function attach_wielditem(player)
local name = player:get_player_name() local name = player:get_player_name()
local pos = player:getpos() local pos = player:getpos()
wielditem[name] = core.add_entity(pos, "wielditem:wielditem") wielditem[name] = minetest.add_entity(pos, "wielditem:wielditem")
wielditem[name]:set_attach(player, "right_arm", {x = -1.5, y = 5.7, z = 2.5}, {x = 90, y = -45, z = 270}) wielditem[name]:set_attach(player, "right_arm", {x = -1.5, y = 5.7, z = 2.5}, {x = 90, y = -45, z = 270})
wielditem[name]:get_luaentity().wielder = player wielditem[name]:get_luaentity().wielder = player
end end
@ -64,7 +64,7 @@ local function detach_wielditem(player)
wielditem[name] = nil wielditem[name] = nil
end end
core.register_on_joinplayer(attach_wielditem) minetest.register_on_joinplayer(attach_wielditem)
core.register_on_leaveplayer(detach_wielditem) minetest.register_on_leaveplayer(detach_wielditem)
default.log("mod:wielditem", "loaded") default.log("mod:wielditem", "loaded")