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_list = {}
local achievements_file = core.get_worldpath() .. "/achievements"
local achievements_file = minetest.get_worldpath() .. "/achievements"
function achievements.register_achievement(name, def)
local rd = {
@ -28,7 +28,7 @@ end
local function save_achievements()
local f = io.open(achievements_file, "w")
f:write(core.serialize(achievements.achievements))
f:write(minetest.serialize(achievements.achievements))
io.close(f)
end
@ -37,7 +37,7 @@ local function load_achievements()
local f = io.open(achievements_file, "r")
if f then
achievements.achievements = core.deserialize(f:read("*all"))
achievements.achievements = minetest.deserialize(f:read("*all"))
io.close(f)
else
@ -69,8 +69,8 @@ function achievements.trigger_achievement(player, aname, times)
if achievements.achievements[name][aname] >= achievements.registered_achievements[aname].times then
achievements.achievements[name][aname] = -1
core.after(2.0, function()
core.chat_send_all(
minetest.after(2.0, function()
minetest.chat_send_all(
core.colorize("#0f0", "*** " .. name .." has earned the achievement [" ..
achievements.registered_achievements[aname].title .. "]"))
end)
@ -101,7 +101,7 @@ local function on_craft(itemstack, player, craftgrid, craftinv)
else
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)
end
end
@ -118,7 +118,7 @@ local function on_dig(pos, oldnode, player)
else
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)
end
end
@ -134,7 +134,7 @@ local function on_place(pos, newnode, player, oldnode, itemstack, pointed_thing)
else
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)
end
end
@ -144,13 +144,13 @@ end
-- 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)
core.register_on_dignode(on_dig)
core.register_on_placenode(on_place)
minetest.register_on_craft(on_craft)
minetest.register_on_dignode(on_dig)
minetest.register_on_placenode(on_place)
-- Formspecs
@ -187,8 +187,8 @@ function achievements.get_formspec(name, row)
achievement_list = achievement_list .. ","
end
achievement_list = achievement_list .. core.formspec_escape(def.title) .. ","
achievement_list = achievement_list .. core.formspec_escape(def.description) .. ","
achievement_list = achievement_list .. minetest.formspec_escape(def.title) .. ","
achievement_list = achievement_list .. minetest.formspec_escape(def.description) .. ","
achievement_list = achievement_list .. progress
end
@ -210,12 +210,12 @@ function achievements.get_formspec(name, row)
progress = "Missing"
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[7.25,0.25;" .. core.formspec_escape(progress) .. "]"
form = form .. "label[0.25,0.25;" .. minetest.formspec_escape(def.title) .. "]"
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
end
@ -230,17 +230,17 @@ local function receive_fields(player, form_name, fields)
local selected = 1
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
selected = selection.row
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
core.register_on_player_receive_fields(receive_fields)
minetest.register_on_player_receive_fields(receive_fields)
--
-- Below are the default achievements

View File

@ -14,7 +14,7 @@ ambiance.sounds["birds"] = {
dist = 8,
nodename = "group:leaves",
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
return true
@ -31,7 +31,7 @@ ambiance.sounds["crickets"] = {
dist = 8,
nodename = "group:grass",
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
return true
@ -49,13 +49,13 @@ ambiance.sounds["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 lastsound = {}
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
return nodepos
@ -67,12 +67,12 @@ end
local function step(dtime)
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 name = player:get_player_name()
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
lastsound[name][soundname] = lastsound[name][soundname] + dtime
else
@ -88,7 +88,7 @@ local function step(dtime)
if sourcepos == nil then
if soundspec[name][soundname] then
core.sound_stop(soundspec[name][soundname])
minetest.sound_stop(soundspec[name][soundname])
soundspec[name][soundname] = nil
lastsound[name][soundname] = 0
@ -102,7 +102,7 @@ local function step(dtime)
end
if ok then
soundspec[name][soundname] = core.sound_play(
soundspec[name][soundname] = minetest.sound_play(
sound.file,
{
pos = sourcepos,
@ -135,8 +135,8 @@ local function on_leaveplayer(player)
lastsound[name] = nil
end
core.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer)
core.register_globalstep(step)
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_leaveplayer(on_leaveplayer)
minetest.register_globalstep(step)
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")
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
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.groups.is_armor then
@ -45,7 +45,7 @@ function armor.is_slot(itemname, slot)
end
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())
else
return armor.player_skin
@ -61,7 +61,7 @@ function armor.get_texture(player, base)
local itemstack = inv:get_stack("armor_"..slot, 1)
local itemname = itemstack:get_name()
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]
image = image .. "^armor_" .. slot .. "_" .. mat ..".png"
@ -86,7 +86,7 @@ function armor.get_groups(player)
local itemname = itemstack:get_name()
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
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)
}
local drop = core.add_item(rpos, item)
local drop = minetest.add_item(rpos, item)
if drop then
drop:setvelocity(
@ -177,14 +177,14 @@ local function step(dtime)
armor_timer = armor_timer + dtime
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)
end
armor_timer = 0
end
end
core.register_craftitem(
minetest.register_craftitem(
"armor:chainmail_sheet",
{
description = "Chainmail sheet",
@ -195,7 +195,7 @@ core.register_craftitem(
stack_max = 20,
})
core.register_craft(
minetest.register_craft(
{
output = "armor:chainmail_sheet 3",
recipe = {
@ -213,7 +213,7 @@ for mat_index, _ in ipairs(armor.materials) do
-- print("Material " .. mat .. ": " .. armor_def)
for _, slot in ipairs(armor.slots) do
core.register_craftitem(
minetest.register_craftitem(
"armor:"..slot.."_"..mat,
{
description = def[4].." "..slot,
@ -233,7 +233,7 @@ for mat_index, _ in ipairs(armor.materials) do
local n = def[2]
core.register_craft(
minetest.register_craft(
{
output = "armor:helmet_"..mat,
recipe = {
@ -242,7 +242,7 @@ for mat_index, _ in ipairs(armor.materials) do
{"", "", ""},
}
})
core.register_craft(
minetest.register_craft(
{
output = "armor:chestplate_"..mat,
recipe = {
@ -251,7 +251,7 @@ for mat_index, _ in ipairs(armor.materials) do
{n, n, n},
}
})
core.register_craft(
minetest.register_craft(
{
output = "armor:boots_"..mat,
recipe = {
@ -262,12 +262,12 @@ for mat_index, _ in ipairs(armor.materials) do
})
end
core.register_on_newplayer(on_newplayer)
core.register_on_joinplayer(on_joinplayer)
minetest.register_on_newplayer(on_newplayer)
minetest.register_on_joinplayer(on_joinplayer)
if enable_drop then
core.register_on_dieplayer(on_die)
minetest.register_on_dieplayer(on_die)
end
core.register_globalstep(step)
minetest.register_globalstep(step)
local form_armor = default.ui.get_page("core_2part")
form_armor = form_armor .. "list[current_player;main;0.25,4.75;8,4;]"

View File

@ -6,7 +6,7 @@
local players_in_bed = {}
core.register_node(
minetest.register_node(
"bed:bed_foot",
{
description = "Bed",
@ -29,34 +29,34 @@ core.register_node(
},
after_place_node = function(pos)
local node = core.get_node(pos)
local dir = core.facedir_to_dir(node.param2)
local node = minetest.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
local head_pos = vector.add(pos, dir)
node.name = "bed:bed_head"
if core.registered_nodes[core.get_node(head_pos).name].buildable_to then
core.set_node(head_pos, node)
if minetest.registered_nodes[minetest.get_node(head_pos).name].buildable_to then
minetest.set_node(head_pos, node)
else
core.remove_node(pos)
minetest.remove_node(pos)
end
end,
on_destruct = function(pos)
local node = core.get_node(pos)
local dir = core.facedir_to_dir(node.param2)
local node = minetest.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
local head_pos = vector.add(pos, dir)
if core.get_node(head_pos).name == "bed:bed_head" then
core.remove_node(head_pos)
if minetest.get_node(head_pos).name == "bed:bed_head" then
minetest.remove_node(head_pos)
end
end,
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
end
local name = clicker:get_player_name()
local meta = core.get_meta(pos)
local put_pos = vector.add(pos, vector.divide(core.facedir_to_dir(node.param2), 2))
local meta = minetest.get_meta(pos)
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
put_pos.y = put_pos.y - 0.5
@ -94,11 +94,11 @@ core.register_node(
end,
can_dig = function(pos)
return core.get_meta(pos):get_string("player") == ""
return minetest.get_meta(pos):get_string("player") == ""
end
})
core.register_node(
minetest.register_node(
"bed:bed_head",
{
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",
recipe = {
@ -127,16 +127,16 @@ core.register_craft(
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
bed_player_spawns = core.deserialize(file:read("*all"))
bed_player_spawns = minetest.deserialize(file:read("*all"))
file:close()
end
local timer = 0
local wait = false
core.register_globalstep(
minetest.register_globalstep(
function(dtime)
if timer < 2 then
timer = timer + dtime
@ -151,24 +151,24 @@ core.register_globalstep(
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 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
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
core.after(2, function()
core.set_timeofday(0.23)
minetest.after(2, function()
minetest.set_timeofday(0.23)
wait = false
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()
end
local file = io.open(core.get_worldpath().."/bed.txt", "w")
file:write(core.serialize(bed_player_spawns))
local file = io.open(minetest.get_worldpath().."/bed.txt", "w")
file:write(minetest.serialize(bed_player_spawns))
file:close()
end
end
@ -188,7 +188,7 @@ player_effects.register_effect(
}
})
core.register_on_respawnplayer(
minetest.register_on_respawnplayer(
function(player)
local name = player:get_player_name()
if bed_player_spawns[name] then
@ -196,7 +196,7 @@ core.register_on_respawnplayer(
end
end)
core.register_on_leaveplayer(
minetest.register_on_leaveplayer(
function(player)
players_in_bed[player:get_player_name()] = nil
end)

View File

@ -4,7 +4,7 @@
-- By Kaadmy, for Pixture
--
core.register_craftitem(
minetest.register_craftitem(
":default:book",
{
description = "Book",
@ -12,7 +12,7 @@ core.register_craftitem(
stack_max = 1,
on_use = function(itemstack, player, pointed_thing)
local name = player:get_player_name()
local data = core.deserialize(itemstack:get_metadata())
local data = minetest.deserialize(itemstack:get_metadata())
local title = ""
local text = ""
@ -23,26 +23,26 @@ core.register_craftitem(
end
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 .. "textarea[0.5,1.75;8,6.75;text;Contents:;"..core.formspec_escape(text).."]"
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:;"..minetest.formspec_escape(text).."]"
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,
})
core.register_on_player_receive_fields(
minetest.register_on_player_receive_fields(
function(player, form_name, fields)
if form_name ~= "book:book" or not fields.write then return end
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
data.text = fields.text
data.title = fields.title
itemstack:set_metadata(core.serialize(data))
itemstack:set_metadata(minetest.serialize(data))
player:set_wielded_item(itemstack)
end)

View File

@ -4,7 +4,7 @@
-- Tweaked by Kaadmy, for Pixture
--
core.register_entity(
minetest.register_entity(
":__builtin:item",
{
initial_properties = {
@ -39,9 +39,9 @@ core.register_entity(
local item_texture = nil
local item_type = ""
if core.registered_items[itemname] then
item_texture = core.registered_items[itemname].inventory_image
item_type = core.registered_items[itemname].type
if minetest.registered_items[itemname] then
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
local prop = {
is_visible = true,
@ -63,7 +63,7 @@ core.register_entity(
get_staticdata = function(self)
--return self.itemstring
return core.serialize(
return minetest.serialize(
{
itemstring = self.itemstring,
always_collect = self.always_collect,
@ -73,7 +73,7 @@ core.register_entity(
on_activate = function(self, staticdata, dtime_s)
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
self.itemstring = data.itemstring
self.always_collect = data.always_collect
@ -93,7 +93,7 @@ core.register_entity(
end,
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 self.timer then self.timer = 0 end
@ -104,17 +104,17 @@ core.register_entity(
local p = self.object:getpos()
local name = core.get_node(p).name
if core.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})
local name = minetest.get_node(p).name
if minetest.registered_nodes[name].damage_per_second > 0 or name == "maptools:igniter" then
minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.45})
self.object:remove()
return
end
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 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
self.object:setvelocity({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[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
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].itemno = itemno
core.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
minetest.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
end
end
@ -146,8 +146,8 @@ local function on_leaveplayer(player)
end
local function load_recipes()
for itemname, itemdef in pairs(core.registered_items) do
local recipes = core.get_all_craft_recipes(itemname)
for itemname, itemdef in pairs(minetest.registered_items) do
local recipes = minetest.get_all_craft_recipes(itemname)
if recipes ~= nil and itemname ~= "" then
-- print(dump(recipes))
@ -161,11 +161,11 @@ local function load_recipes()
print("Got "..#craftingguide.itemlist.." craftable items")
end
core.after(0, load_recipes)
minetest.after(0, load_recipes)
core.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer)
core.register_on_player_receive_fields(receive_fields)
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_leaveplayer(on_leaveplayer)
minetest.register_on_player_receive_fields(receive_fields)
local form_craftingguide = default.ui.get_page("core")
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.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 .. "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)

View File

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

View File

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

View File

@ -26,7 +26,7 @@ function default.ui.get_hotbar_itemslot_bg(x, y, w, h)
end
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.."]"
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 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.."]"
return form
end
local function get_itemdef_field(itemname, fieldname)
if not core.registered_items[itemname] then
if not minetest.registered_items[itemname] then
return nil
end
return core.registered_items[itemname][fieldname]
return minetest.registered_items[itemname][fieldname]
end
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 itemdesc = ""
if core.registered_items[itemname] and core.registered_items[itemname].description ~= nil then
itemdesc = core.registered_items[itemname].description
if minetest.registered_items[itemname] and minetest.registered_items[itemname].description ~= nil then
itemdesc = minetest.registered_items[itemname].description
end
if itemamt <= 1 then itemamt = "" end
@ -94,7 +94,7 @@ function default.ui.fake_itemstack(x, y, itemstack, name)
if itemname ~= "" then
-- 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 .. "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 .. "tooltip["..name..";"..itemdesc.."]"
end
@ -106,15 +106,15 @@ function default.ui.fake_simple_itemstack(x, y, itemname, name)
local name = name or "fake_simple_itemstack"
local itemdesc = ""
if core.registered_items[itemname] and core.registered_items[itemname].description ~= nil then
itemdesc = core.registered_items[itemname].description
if minetest.registered_items[itemname] and minetest.registered_items[itemname].description ~= nil then
itemdesc = minetest.registered_items[itemname].description
end
local result = ""
if itemname ~= "" then
-- 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 .. "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.."]"
end
@ -126,22 +126,22 @@ function default.ui.item_group(x, y, group, name)
local itemname = ""
for itemn, itemdef in pairs(core.registered_items) do
if core.get_item_group(itemn, group) ~= 0 and core.get_item_group(itemn, "not_in_craftingguide") ~= 1 then
for itemn, itemdef in pairs(minetest.registered_items) do
if minetest.get_item_group(itemn, group) ~= 0 and minetest.get_item_group(itemn, "not_in_craftingguide") ~= 1 then
itemname = itemn
end
end
local itemdesc = ""
if core.registered_items[itemname] and core.registered_items[itemname].description ~= nil then
itemdesc = core.registered_items[itemname].description
if minetest.registered_items[itemname] and minetest.registered_items[itemname].description ~= nil then
itemdesc = minetest.registered_items[itemname].description
end
local result = ""
if itemname ~= "" then
-- 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 .. "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.."]"
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.bg
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")
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")
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")
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")
end
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))
if fields.tab_crafting then
core.show_formspec(name, "core_crafting", default.ui.get_page("core_crafting"))
elseif core.get_modpath("craftingguide") ~= nil and fields.tab_craftingguide then
core.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
elseif core.get_modpath("armor") ~= nil and fields.tab_armor then
core.show_formspec(name, "core_armor", default.ui.get_page("core_armor"))
elseif core.get_modpath("achievements") ~= nil and fields.tab_achievements then
core.show_formspec(name, "core_achievements", achievements.get_formspec(name))
elseif core.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_crafting", default.ui.get_page("core_crafting"))
elseif minetest.get_modpath("craftingguide") ~= nil and fields.tab_craftingguide then
minetest.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
elseif minetest.get_modpath("armor") ~= nil and fields.tab_armor then
minetest.show_formspec(name, "core_armor", default.ui.get_page("core_armor"))
elseif minetest.get_modpath("achievements") ~= nil and fields.tab_achievements then
minetest.show_formspec(name, "core_achievements", achievements.get_formspec(name))
elseif minetest.get_modpath("player_skins") ~= nil and fields.tab_player_skins then
minetest.show_formspec(name, "core_player_skins", player_skins.get_formspec(name))
end
end
core.register_on_player_receive_fields(
minetest.register_on_player_receive_fields(
function(player, form_name, fields)
default.ui.receive_fields(player, form_name, fields)
end)
core.register_on_joinplayer(
minetest.register_on_joinplayer(
function(player)
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
core.after(1.0, welcome)
minetest.after(1.0, welcome)
player:set_inventory_formspec(default.ui.get_page("core_crafting"))
end)

View File

@ -5,11 +5,11 @@
-- Chest naming via signs
function default.write_name(pos, text)
-- 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 abovedef = nil
if core.registered_nodes[core.get_node(above).name] then
abovedef = core.registered_nodes[core.get_node(above).name]
if minetest.registered_nodes[minetest.get_node(above).name] then
abovedef = minetest.registered_nodes[minetest.get_node(above).name]
end
if abovedef and abovedef.write_name ~= nil then
abovedef.write_name(above, text)
@ -19,8 +19,8 @@ function default.write_name(pos, text)
-- then below
local below = {x = pos.x, y = pos.y - 1, z = pos.z}
local belowdef = nil
if core.registered_nodes[core.get_node(below).name] then
belowdef = core.registered_nodes[core.get_node(below).name]
if minetest.registered_nodes[minetest.get_node(below).name] then
belowdef = minetest.registered_nodes[minetest.get_node(below).name]
end
if belowdef and belowdef.write_name ~= nil then
belowdef.write_name(below, text)
@ -32,28 +32,28 @@ end
function default.grow_tree(pos, variety)
local function grow()
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
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
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
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
core.register_abm( -- apple trees or default trees
minetest.register_abm( -- apple trees or default trees
{
nodenames = {"default:sapling"},
interval = 10,
chance = 40,
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
@ -61,25 +61,25 @@ core.register_abm( -- apple trees or default trees
end
})
core.register_abm( -- oak trees
minetest.register_abm( -- oak trees
{
nodenames = {"default:sapling_oak"},
interval = 10,
chance = 60,
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
default.grow_tree(pos, "oak")
end
})
core.register_abm( -- birch trees
minetest.register_abm( -- birch trees
{
nodenames = {"default:sapling_birch"},
interval = 10,
chance = 50,
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
default.grow_tree(pos, "birch")
end
@ -90,18 +90,18 @@ core.register_abm( -- birch trees
function default.dig_up(pos, node, digger)
-- if digger == nil then return end
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
core.node_dig(np, nn, digger)
minetest.node_dig(np, nn, digger)
end
end
function default.dig_down(pos, node, digger)
-- if digger == nil then return end
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
core.node_dig(np, nn, digger)
minetest.node_dig(np, nn, digger)
end
end
@ -112,19 +112,19 @@ default.leafdecay_enable_cache = true
-- Spread the load of finding trunks
default.leafdecay_trunk_find_allow_accumulator = 0
core.register_globalstep(function(dtime)
minetest.register_globalstep(function(dtime)
local finds_per_second = 5000
default.leafdecay_trunk_find_allow_accumulator =
math.floor(dtime * finds_per_second)
end)
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
core.set_node(pos, node)
minetest.set_node(pos, node)
end
core.register_abm( -- leaf decay
minetest.register_abm( -- leaf decay
{
nodenames = {"group:leafdecay"},
neighbors = {"air", "group:liquid"},
@ -135,23 +135,23 @@ core.register_abm( -- leaf decay
action = function(p0, node, _, _)
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
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
--print("not groups.leafdecay")
return
end
local n0 = core.get_node(p0)
local n0 = minetest.get_node(p0)
if n0.param2 ~= 0 then
--print("param2 ~= 0")
return
end
local p0_hash = nil
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]
if trunkp then
local n = core.get_node(trunkp)
local reg = core.registered_nodes[n.name]
local n = minetest.get_node(trunkp)
local reg = minetest.registered_nodes[n.name]
-- 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
--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 - 1
-- 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
do_preserve = true
if default.leafdecay_enable_cache then
@ -179,55 +179,55 @@ core.register_abm( -- leaf decay
end
if not do_preserve then
-- 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
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 = {
x = p0.x - 0.5 + math.random(),
y = p0.y - 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
-- Remove node
core.remove_node(p0)
minetest.remove_node(p0)
nodeupdate(p0)
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"},
interval = 2,
chance = 40,
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = core.get_node(above).name
local nodedef = core.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
core.set_node(pos, {name = "default:dirt_with_grass"})
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (minetest.get_node_light(above) or 0) >= 8 then
minetest.set_node(pos, {name = "default:dirt_with_grass"})
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"},
interval = 2,
chance = 10,
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = core.get_node(above).name
local nodedef = core.registered_nodes[name]
local name = minetest.get_node(above).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
core.set_node(pos, {name = "default:dirt"})
minetest.set_node(pos, {name = "default:dirt"})
end
end
})
core.register_abm( -- grass expands
minetest.register_abm( -- grass expands
{
nodenames = {"default:grass"},
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 downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
local edgenode = core.get_node(edgepos)
local downnode = core.get_node(downpos)
local edgenode = minetest.get_node(edgepos)
local downnode = minetest.get_node(downpos)
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
})
core.register_abm( -- clams grow
minetest.register_abm( -- clams grow
{
nodenames = {"default:clam"},
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 downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
local edgenode = core.get_node(edgepos)
local downnode = core.get_node(downpos)
local edgenode = minetest.get_node(edgepos)
local downnode = minetest.get_node(downpos)
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
})
core.register_abm( -- cactus grows
minetest.register_abm( -- cactus grows
{
nodenames = {"default:cactus"},
neighbors = {"group:sand"},
@ -275,24 +275,24 @@ core.register_abm( -- cactus grows
chance = 10,
action = function(pos, node)
pos.y = pos.y-1
local name = core.get_node(pos).name
if core.get_item_group(name, "sand") ~= 0 then
local name = minetest.get_node(pos).name
if minetest.get_item_group(name, "sand") ~= 0 then
pos.y = pos.y+1
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
pos.y = pos.y+1
end
if height < 3 then
if core.get_node(pos).name == "air" then
core.set_node(pos, {name="default:cactus"})
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:cactus"})
end
end
end
end,
})
core.register_abm( -- papyrus grows
minetest.register_abm( -- papyrus grows
{
nodenames = {"default:papyrus"},
neighbors = {"group:plantable_sandy", "group:plantable_soil"},
@ -300,26 +300,26 @@ core.register_abm( -- papyrus grows
chance = 10,
action = function(pos, node)
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
end
pos.y = pos.y+1
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
pos.y = pos.y+1
end
if height < 3 then
if core.get_node(pos).name == "air" then
core.set_node(pos, {name="default:papyrus"})
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:papyrus"})
end
end
end,
})
core.register_abm( -- papyrus grows
minetest.register_abm( -- papyrus grows
{
nodenames = {"default:thistle"},
neighbors = {"group:plantable_soil"},
@ -327,26 +327,26 @@ core.register_abm( -- papyrus grows
chance = 30,
action = function(pos, node)
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
pos.y = pos.y+1
end
if height < 3 then
if core.get_node(pos).name == "air" then
core.set_node(pos, {name="default:thistle"})
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:thistle"})
end
end
end,
})
--[[ 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"},
interval = 5,
chance = 1,
action = function(pos, node)
core.add_particlespawner(
minetest.add_particlespawner(
{
amount = 10,
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"},
interval = 3,
chance = 60,
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
})

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)
core.register_node(
minetest.register_node(
"default:furnace",
{
description = "Furnace",
@ -61,7 +61,7 @@ core.register_node(
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
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("infotext", "Furnace")
@ -71,7 +71,7 @@ core.register_node(
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = core.get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
@ -84,7 +84,7 @@ core.register_node(
end,
})
core.register_node(
minetest.register_node(
"default:furnace_active",
{
description = "Furnace",
@ -97,7 +97,7 @@ core.register_node(
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
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("infotext", "Furnace");
@ -107,7 +107,7 @@ core.register_node(
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = core.get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
@ -121,15 +121,15 @@ core.register_node(
})
function swap_node(pos, name)
local node = core.get_node(pos)
local node = minetest.get_node(pos)
if node.name == name then
return
end
node.name = name
core.swap_node(pos, node)
minetest.swap_node(pos, node)
end
core.register_abm(
minetest.register_abm(
{
nodenames = {"default:furnace", "default:furnace_active"},
interval = 1.0,
@ -138,7 +138,7 @@ core.register_abm(
--
-- 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 src_time = meta:get_float("src_time") 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
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
if cooked.time == 0 then
@ -194,7 +194,7 @@ core.register_abm(
-- Furnace ran out of fuel
if cookable then
-- 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
-- No valid fuel in fuel list

View File

@ -69,7 +69,7 @@ function default.hud.initialize_builtin_statbars(player)
player:hud_set_flags(flg)
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
health_bar_definition.number = player:get_hp()
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
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
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
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
player:hud_remove(default.hud.ids[name].id_healthbar)
default.hud.initialize_builtin_statbars(player)
@ -174,7 +174,7 @@ function default.hud.replace_builtin(name, definition)
breath_bar_definition = definition
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
player:hud_remove(default.hud.ids[name].id_breathbar)
default.hud.initialize_builtin_statbars(player)
@ -186,9 +186,9 @@ function default.hud.replace_builtin(name, definition)
return false
end
core.register_on_joinplayer(default.hud.initialize_builtin_statbars)
core.register_on_leaveplayer(default.hud.cleanup_builtin_statbars)
core.register_playerevent(default.hud.player_event_handler)
minetest.register_on_joinplayer(default.hud.initialize_builtin_statbars)
minetest.register_on_leaveplayer(default.hud.cleanup_builtin_statbars)
minetest.register_playerevent(default.hud.player_event_handler)
default.log("hud", "loaded")

View File

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

View File

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

View File

@ -107,14 +107,14 @@ function default.player_set_animation(player, anim_name, speed)
end
-- Update appearance when the player joins
core.register_on_joinplayer(
minetest.register_on_joinplayer(
function(player)
default.player_attached[player:get_player_name()] = false
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)
end)
core.register_on_leaveplayer(
minetest.register_on_leaveplayer(
function(player)
local name = player:get_player_name()
player_model[name] = nil
@ -127,9 +127,9 @@ local player_set_animation = default.player_set_animation
local player_attached = default.player_attached
-- Check each player and apply animations
core.register_globalstep(
minetest.register_globalstep(
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 model_name = player_model[name]
local model = model_name and models[model_name]

View File

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

View File

@ -8,7 +8,7 @@ local particlespawners = {}
local function step(dtime)
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 head_pos = player_pos
local name=player:get_player_name()
@ -16,14 +16,14 @@ local function step(dtime)
if player_pos.x < -30000 or player_pos.x > 30000
or player_pos.y < -30000 or player_pos.y > 30000
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])
end
player_lastpos[name] = player:getpos()
if player:get_hp() < player_health[name] then
core.sound_play(
minetest.sound_play(
"default_hurt",
{
pos = player_pos,
@ -44,8 +44,8 @@ local function step(dtime)
player_lastsound[name] = player_lastsound[name] + dtime
if core.get_item_group(core.get_node(head_pos).name, 'water') > 0 then
particlespawners[name] = core.add_particlespawner(
if minetest.get_item_group(minetest.get_node(head_pos).name, 'water') > 0 then
particlespawners[name] = minetest.add_particlespawner(
{
amount = 2,
time = 0.1,
@ -62,12 +62,12 @@ local function step(dtime)
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
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
player_soundspec[name]=core.sound_play(
player_soundspec[name]=minetest.sound_play(
"default_water",
{
pos = player_pos,
@ -77,17 +77,17 @@ local function step(dtime)
end
else
if player_soundspec[name] ~= nil then
core.sound_stop(player_soundspec[name])
minetest.sound_stop(player_soundspec[name])
player_lastsound[name] = 100
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.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
@ -121,8 +121,8 @@ local function on_leaveplayer(player)
player_lastpos[name] = nil
end
core.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer)
core.register_globalstep(step)
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_leaveplayer(on_leaveplayer)
minetest.register_globalstep(step)
default.log("player", "loaded")

View File

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

View File

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

View File

@ -3,7 +3,7 @@
-- 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 pos = player:getpos()
@ -19,7 +19,7 @@ local function on_die(player)
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
local x = math.random(1, 5)
@ -39,7 +39,7 @@ local function on_die(player)
end
if enable_drop then
core.register_on_dieplayer(on_die)
minetest.register_on_dieplayer(on_die)
end
default.log("mod:drop_items_on_die", "loaded")

View File

@ -1,33 +1,33 @@
core.register_craftitem(
minetest.register_craftitem(
"farming:cotton",
{
description = "Cotton",
inventory_image = "farming_cotton.png"
})
core.register_craftitem(
minetest.register_craftitem(
"farming:wheat",
{
description = "Wheat",
inventory_image = "farming_wheat.png"
})
core.register_craftitem(
minetest.register_craftitem(
"farming:flour",
{
description = "Flour",
inventory_image = "farming_flour.png"
})
core.register_craftitem(
minetest.register_craftitem(
"farming:bread",
{
description = "Bread",
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",
recipe = {
@ -36,7 +36,7 @@ core.register_craft(
}
})
core.register_craft(
minetest.register_craft(
{
output = "farming:cotton_bale 2",
recipe = {
@ -45,7 +45,7 @@ core.register_craft(
}
})
core.register_craft(
minetest.register_craft(
{
type = "cooking",
output = "farming:bread",

View File

@ -6,26 +6,26 @@
farming = {}
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
local on_node = core.get_node({x = pos.x, y = pos.y-1, z = pos.z})
local on_nodedef = core.registered_nodes[on_node.name]
local on_node = minetest.get_node({x = pos.x, y = pos.y-1, z = pos.z})
local on_nodedef = minetest.registered_nodes[on_node.name]
for _, can_grow_on in ipairs(plant.grows_on) do
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 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
core.set_node(pos, {name = "farming:"..name.."_3"})
minetest.set_node(pos, {name = "farming:"..name.."_3"})
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
break
@ -39,7 +39,7 @@ function farming.register_plant(name, plant)
--
-- format: "farming:[plant name]_[stage from 1-4]"
core.register_abm(
minetest.register_abm(
{
nodenames = {
"farming:"..name.."_1",
@ -52,7 +52,7 @@ function farming.register_plant(name, plant)
action = function(pos, node, active_object_count, active_object_count_wider)
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
print("Fertilizer!")
@ -66,8 +66,8 @@ function farming.register_plant(name, plant)
})
end
dofile(core.get_modpath("farming").."/nodes.lua")
dofile(core.get_modpath("farming").."/plants.lua")
dofile(core.get_modpath("farming").."/craft.lua")
dofile(minetest.get_modpath("farming").."/nodes.lua")
dofile(minetest.get_modpath("farming").."/plants.lua")
dofile(minetest.get_modpath("farming").."/craft.lua")
default.log("mod:farming", "loaded")

View File

@ -1,4 +1,4 @@
core.register_node(
minetest.register_node(
"farming:wheat_1",
{
description = "Wheat Seed",
@ -24,7 +24,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:wheat_2",
{
description = "Wheat",
@ -48,7 +48,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:wheat_3",
{
description = "Wheat",
@ -72,7 +72,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:wheat_4",
{
description = "Wheat",
@ -99,7 +99,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:cotton_1",
{
description = "Cotton Seed",
@ -125,7 +125,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:cotton_2",
{
description = "Cotton",
@ -149,7 +149,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:cotton_3",
{
description = "Cotton",
@ -173,7 +173,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:cotton_4",
{
description = "Cotton",
@ -200,7 +200,7 @@ core.register_node(
local name = player:get_wielded_item():get_name()
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
if math.random(1, 2) == 1 then
@ -218,7 +218,7 @@ core.register_node(
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
local x = math.random(1, 5)
@ -238,7 +238,7 @@ core.register_node(
sounds=default.node_sound_leaves_defaults()
})
core.register_node(
minetest.register_node(
"farming:cotton_bale",
{
description = "Cotton Bale",
@ -248,7 +248,7 @@ core.register_node(
sounds = default.node_sound_leaves_defaults(),
})
core.register_alias("farming:cotton_seed", "farming:cotton_1")
core.register_alias("farming:wheat_seed", "farming:wheat_1")
minetest.register_alias("farming:cotton_seed", "farming:cotton_1")
minetest.register_alias("farming:wheat_seed", "farming:wheat_1")
default.log("nodes", "loaded")

View File

@ -3,7 +3,7 @@
-- 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)
if giveme then
@ -14,6 +14,6 @@ local function give_initial_stuff(player)
end
end
core.register_on_newplayer(give_initial_stuff)
minetest.register_on_newplayer(give_initial_stuff)
default.log("mod:give_initial_stuff", "loaded")

View File

@ -5,12 +5,12 @@
gold = {}
gold.pr = PseudoRandom(core.get_mapgen_params().seed+8732)
gold.pr = PseudoRandom(minetest.get_mapgen_params().seed+8732)
gold.trades = {}
gold.trade_names = {}
if core.get_modpath("mobs") ~= nil then
if minetest.get_modpath("mobs") ~= nil then
gold.trades["farmer"] = {
-- plants
{"gold:gold", "", "farming:wheat_1 6"},
@ -95,7 +95,7 @@ if core.get_modpath("mobs") ~= nil then
}
-- trading currency
if core.get_modpath("jewels") ~= nil then -- jewels/gold
if minetest.get_modpath("jewels") ~= nil then -- jewels/gold
--farmer
table.insert(gold.trades["farmer"], {"gold:gold 16", "", "jewels:jewel"})
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", 2, trade[2])
local meta = core.deserialize(item:get_metadata())
local meta = minetest.deserialize(item:get_metadata())
if not meta then meta = {} end
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 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, 2.25, trade_wanted2, "trade_wanted2")
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
item:set_metadata(core.serialize(meta))
item:set_metadata(minetest.serialize(meta))
player:set_wielded_item(item)
return true
end
core.register_on_player_receive_fields(
minetest.register_on_player_receive_fields(
function(player, form_name, fields)
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 meta = core.deserialize(item:get_metadata())
local meta = minetest.deserialize(item:get_metadata())
local trade = {"gold:gold", "gold:gold", "default:stick"}
local trade_type = ""
@ -241,7 +241,7 @@ core.register_on_player_receive_fields(
end
end)
core.register_craftitem(
minetest.register_craftitem(
"gold:trading_book",
{
description = "Trading Book",
@ -249,7 +249,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"gold:gold",
{
description = "Gold",
@ -257,16 +257,16 @@ core.register_craftitem(
stack_max = 120
})
core.register_craft(
minetest.register_craft(
{
output = "gold:trading_book",
type = "shapeless",
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",
{
description = "Gold Ore",
@ -277,7 +277,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(),
})
core.register_ore(
minetest.register_ore(
{
ore_type = "scatter",
ore = "gold:ore",

View File

@ -27,7 +27,7 @@ goodies.types["FURNACE_DST"] = {
}
-- chunk types for villages
if core.get_modpath("village") ~= nil then
if minetest.get_modpath("village") ~= nil then
goodies.types["forge"] = {
["default:ingot_steel"] = 10,
["default:lump_coal"] = 4,
@ -55,13 +55,13 @@ if core.get_modpath("village") ~= nil then
}
-- 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:jewel"] = 34
goodies.types["tavern"]["jewels:jewel"] = 32
goodies.types["forge"]["jewels:jewel"] = 30
end
if core.get_modpath("gold") ~= nil then
if minetest.get_modpath("gold") ~= nil then
goodies.types["house"]["gold:gold"] = 12
goodies.types["tavern"]["gold:gold"] = 10
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 pr:next(1, keepchance) ~= 1 then
core.remove_node(pos)
minetest.remove_node(pos)
return
end
local meta = core.get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local size = inv:get_size(listname)

View File

@ -5,12 +5,12 @@
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
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)
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
end
core.register_entity(
minetest.register_entity(
"headbars:hpbar",
{
visual = "sprite",
@ -50,7 +50,7 @@ core.register_entity(
on_step = function(self, dtime)
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()
return
end
@ -66,7 +66,7 @@ function headbars.attach_hpbar(to)
if not enable_headbars then return end
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
@ -78,5 +78,5 @@ function headbars.attach_hpbar(to)
bar.wielder = to
end
core.register_on_joinplayer(headbars.attach_hpbar)
minetest.register_on_joinplayer(headbars.attach_hpbar)
default.log("mod:headbars", "loaded")

View File

@ -15,8 +15,8 @@ local particlespawners = {}
local player_step = {}
local player_health_step = {}
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 file = core.get_worldpath() .. "/hunger"
local base_interval = tonumber(minetest.setting_get("hunger_step")) or 3.0 -- seconds per hunger update, 2.0 is slightly fast
local file = minetest.get_worldpath() .. "/hunger"
function hunger.save_hunger()
local output = io.open(file, "w")
@ -44,7 +44,7 @@ local function load_hunger()
hunger.hunger[name] = hnger
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
io.close(input)
else
@ -73,7 +73,7 @@ function hunger.update_bar(player)
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(
"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)
core.register_on_dignode(
minetest.register_on_dignode(
function(pos, oldnode, player)
if not player then return end
local name = player:get_player_name()
hunger.active[name] = hunger.active[name]+ 2
end)
core.register_on_placenode(
minetest.register_on_placenode(
function(pos, node, player)
if not player then return end
local name = player:get_player_name()
hunger.active[name] = hunger.active[name]+ 2
end)
core.register_on_joinplayer(
minetest.register_on_joinplayer(
function(player)
local name = player:get_player_name()
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)
end)
core.register_on_leaveplayer(
minetest.register_on_leaveplayer(
function(player)
local name = player:get_player_name()
player_bar[name] = nil
end)
core.register_on_respawnplayer(
minetest.register_on_respawnplayer(
function(player)
local name = player:get_player_name()
hunger.hunger[name] = 20
@ -132,7 +132,7 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
hunger.save_hunger()
end)
core.register_on_item_eat(
minetest.register_on_item_eat(
function(hpdata, replace_with_item, itemstack, player, pointed_thing)
if not player 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()
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,
time = 0.1,
@ -180,7 +180,7 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
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")
@ -194,9 +194,9 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
-- Main function
local timer = 0
core.register_globalstep(
minetest.register_globalstep(
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 controls = player:get_player_control()
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
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 hp = player:get_hp()
@ -254,7 +254,7 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
hunger.hunger[name] = 0
local pos_sound = player:getpos()
core.chat_send_player(name, "You are hungry.")
minetest.chat_send_player(name, "You are hungry.")
end
end
end
@ -274,11 +274,11 @@ if core.setting_getbool("enable_damage") and core.setting_getbool("hunger_enable
hunger.save_hunger()
end)
else
core.register_on_item_eat(
minetest.register_on_item_eat(
function(hpdata, replace_with_item, itemstack, player, pointed_thing)
local headpos = player:getpos()
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)

View File

@ -8,14 +8,14 @@ local function valid(object)
return object:get_luaentity().timer ~= nil and object:get_luaentity().timer > 1
end
core.register_globalstep(
minetest.register_globalstep(
function(dtime)
for _,player in ipairs(core.get_connected_players()) do
if player:get_hp() > 0 or not core.setting_getbool("enable_damage") then
for _,player in ipairs(minetest.get_connected_players()) do
if player:get_hp() > 0 or not minetest.setting_getbool("enable_damage") then
local pos = player:getpos()
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 inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
local pos1 = pos
@ -42,7 +42,7 @@ core.register_globalstep(
if inv:room_for_item("main", ItemStack(lua.itemstring)) then
inv:add_item("main", ItemStack(lua.itemstring))
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
lua.itemstring = ""
object:remove()
@ -62,7 +62,7 @@ core.register_globalstep(
end
end)
function core.handle_node_drops(pos, drops, digger)
function minetest.handle_node_drops(pos, drops, digger)
for _,item in ipairs(drops) do
local count, name
if type(item) == "string" then
@ -73,7 +73,7 @@ function core.handle_node_drops(pos, drops, digger)
name = item:get_name()
end
for i=1,count do
local obj = core.add_item(pos, name)
local obj = minetest.add_item(pos, name)
if obj ~= nil then
local x = math.random(1, 5)
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})
-- FIXME this doesnt work for deactiveted objects
if core.setting_get("remove_items") and tonumber(core.setting_get("remove_items")) then
core.after(tonumber(core.setting_get("remove_items")), function(obj)
if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
obj:remove()
end, obj)
end

View File

@ -33,7 +33,7 @@ function jewels.register_jewel(toolname, new_toolname, def)
end
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 = ""
if tooldef.inventory_image then
@ -101,7 +101,7 @@ function jewels.register_jewel(toolname, new_toolname, def)
new_tooldef.description = desc
core.register_tool(new_toolname, new_tooldef)
minetest.register_tool(new_toolname, new_tooldef)
end
function jewels.can_jewel(toolname)
@ -122,7 +122,7 @@ function jewels.get_jeweled(toolname)
end
end
core.register_craftitem(
minetest.register_craftitem(
"jewels:jewel",
{
description = "Jewel",
@ -130,7 +130,7 @@ core.register_craftitem(
stack_max = 10
})
core.register_node(
minetest.register_node(
"jewels:bench",
{
description = "Jewelers Workbench",
@ -141,7 +141,7 @@ core.register_node(
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
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("infotext", "Jewelers Workbench")
@ -149,7 +149,7 @@ core.register_node(
inv:set_size("main", 1)
end,
can_dig = function(pos, player)
local meta = core.get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main")
@ -158,7 +158,7 @@ core.register_node(
local itemstack = player:get_wielded_item()
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 itemname = inv:get_stack("main", 1):get_name()
@ -177,7 +177,7 @@ core.register_node(
end,
})
core.register_craft(
minetest.register_craft(
{
output = "jewels:bench",
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)
default.ui.register_page("jewels_bench", form_bench)
core.register_node(
minetest.register_node(
"jewels:jewel_ore",
{
description = "Jewel Ore",
@ -212,7 +212,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults(),
})
core.register_ore(
minetest.register_ore(
{
ore_type = "scatter",
ore = "jewels:jewel_ore",
@ -224,7 +224,7 @@ core.register_ore(
y_max = 31000,
})
dofile(core.get_modpath("jewels").."/jewels.lua")
dofile(minetest.get_modpath("jewels").."/jewels.lua")
-- Achievements

View File

@ -5,8 +5,8 @@
locks = {}
local picked_time = tonumber(core.setting_get("locks_picked_time")) or 15 -- unlocked for 15 seconds
local all_unlocked = core.setting_getbool("locks_all_unlocked")
local picked_time = tonumber(minetest.setting_get("locks_picked_time")) or 15 -- unlocked for 15 seconds
local all_unlocked = minetest.setting_getbool("locks_all_unlocked")
function locks.is_owner(meta, player)
local name = player:get_player_name()
@ -24,7 +24,7 @@ function locks.is_locked(meta, player)
return false
end
local t = core.get_gametime()
local t = minetest.get_gametime()
local lp = meta:get_float("last_lock_pick")
@ -41,7 +41,7 @@ function locks.is_locked(meta, player)
return true
end
core.register_tool(
minetest.register_tool(
"locks:pick",
{
description = "Lock Pick",
@ -55,12 +55,12 @@ core.register_tool(
if math.random(1, 5) <= 1 then
local pos = pointed_thing.under
local meta = core.get_meta(pos)
meta:set_float("last_lock_pick", core.get_gametime() + picked_time)
local meta = minetest.get_meta(pos)
meta:set_float("last_lock_pick", minetest.get_gametime() + picked_time)
local own = meta:get_string("lock_owner")
if own then
core.chat_send_player(
minetest.chat_send_player(
own,
core.colorize("#f00", player:get_player_name() .. " has broken into your locked chest!"))
end
@ -71,7 +71,7 @@ core.register_tool(
end,
})
core.register_craftitem(
minetest.register_craftitem(
"locks:lock",
{
description = "Lock",
@ -80,7 +80,7 @@ core.register_craftitem(
wield_image = "locks_lock.png",
})
core.register_craft(
minetest.register_craft(
{
output = "locks:pick",
recipe = {
@ -90,7 +90,7 @@ core.register_craft(
},
})
core.register_craft(
minetest.register_craft(
{
output = "locks:lock",
recipe = {
@ -100,7 +100,7 @@ core.register_craft(
},
})
core.register_node(
minetest.register_node(
"locks:chest",
{
description = "Locked Chest",
@ -111,7 +111,7 @@ core.register_node(
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = core.get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_float("last_lock_pick", -1)
local inv = meta:get_inventory()
@ -120,17 +120,17 @@ core.register_node(
after_place_node = function(pos, player)
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("lock_owner", name)
end,
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 locks.is_owner(meta, player) then
-- 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
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_itemslot_bg(0.25, 5.75, 8, 3)
core.show_formspec(
minetest.show_formspec(
player:get_player_name(),
"default_chest",
form
@ -152,33 +152,33 @@ core.register_node(
end
end,
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
return 0
end
return cnt
end,
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
return 0
end
return itemstack:get_count()
end,
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
return 0
end
return itemstack:get_count()
end,
can_dig = function(pos, player)
local meta = core.get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main") and locks.is_owner(meta, player)
end,
write_name = function(pos, text)
local meta = core.get_meta(pos)
local meta = minetest.get_meta(pos)
if text ~= "" then
meta:set_string("infotext", text .. " (Owned by " .. meta:get_string("lock_owner") .. ")")
@ -189,7 +189,7 @@ core.register_node(
on_blast = function() end,
})
core.register_craft(
minetest.register_craft(
{
output = "locks:chest",
type = "shapeless",

View File

@ -6,7 +6,7 @@
local lumien_on_radius = 2
local lumien_off_radius = 4
core.register_node(
minetest.register_node(
"lumien:crystal_on",
{
description = "Lumien Crystal",
@ -28,7 +28,7 @@ core.register_node(
sounds = default.node_sound_glass_defaults(),
})
core.register_node(
minetest.register_node(
"lumien:crystal_off",
{
description = "Lumien Crystal",
@ -49,7 +49,7 @@ core.register_node(
sounds = default.node_sound_glass_defaults(),
})
core.register_node(
minetest.register_node(
"lumien:block",
{
description = "Lumien Block",
@ -59,7 +59,7 @@ core.register_node(
sounds = default.node_sound_stone_defaults(),
})
core.register_node(
minetest.register_node(
"lumien:ore",
{
description = "Lumien Ore",
@ -69,14 +69,14 @@ core.register_node(
sounds = default.node_sound_stone_defaults(),
})
core.register_craft(
minetest.register_craft(
{
output = "lumien:crystal_off 9",
recipe = {"lumien:block"},
type = "shapeless",
})
core.register_craft(
minetest.register_craft(
{
output = "lumien:block",
recipe = {
@ -86,7 +86,7 @@ core.register_craft(
},
})
core.register_ore(
minetest.register_ore(
{
ore_type = "scatter",
ore = "lumien:ore",
@ -98,7 +98,7 @@ core.register_ore(
y_max = -64,
})
core.register_abm(
minetest.register_abm(
{
nodenames = {"lumien:crystal_on"},
interval = 1,
@ -115,14 +115,14 @@ core.register_abm(
)
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
ok = false
end
end
if ok then
core.set_node(
minetest.set_node(
pos,
{
name = "lumien:crystal_off",
@ -134,7 +134,7 @@ core.register_abm(
})
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()
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},
"lumien:crystal_off",
function(pos)
local node = core.get_node(pos)
local node = minetest.get_node(pos)
core.set_node(
minetest.set_node(
pos,
{
name = "lumien:crystal_on",
@ -157,7 +157,7 @@ local function step(dtime)
end
end
core.register_globalstep(step)
minetest.register_globalstep(step)
-- Achievements

View File

@ -3,25 +3,25 @@ mobs = {}
mobs.mod = "redo"
-- Initial settings check
local damage_enabled = core.setting_getbool("enable_damage") or false
local peaceful_only = core.setting_getbool("only_peaceful_mobs") or false
local enable_blood = core.setting_getbool("mobs_enable_blood") or false
mobs.protected = tonumber(core.setting_get("mobs_spawn_protected")) or 0
mobs.remove = core.setting_getbool("remove_far_mobs") or false
local damage_enabled = minetest.setting_getbool("enable_damage") or false
local peaceful_only = minetest.setting_getbool("only_peaceful_mobs") or false
local enable_blood = minetest.setting_getbool("mobs_enable_blood") or false
mobs.protected = tonumber(minetest.setting_get("mobs_spawn_protected")) or 0
mobs.remove = minetest.setting_getbool("remove_far_mobs") or false
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
end
local sp = core.setting_get_pos("static_spawnpoint") or {x = 0, y = 0, z = 0}
local rad = core.setting_get("static_spawn_radius") or 256
local sp = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 0, z = 0}
local rad = minetest.setting_get("static_spawn_radius") or 256
return (vector.distance(pos, sp) < rad)
end
function mobs:register_mob(name, def)
core.register_entity(
minetest.register_entity(
name,
{
stepheight = def.stepheight or 0.6,
@ -120,7 +120,7 @@ function mobs:register_mob(name, def)
-- make sound when fed so many times
if self.sounds.random then
core.sound_play(
minetest.sound_play(
self.sounds.random,
{
object = self.object,
@ -135,7 +135,7 @@ function mobs:register_mob(name, def)
if self.state ~= "attack" then
if math.random(0,100) < 90
and self.sounds.war_cry then
core.sound_play(
minetest.sound_play(
self.sounds.war_cry,
{
object = self.object,
@ -251,7 +251,7 @@ function mobs:register_mob(name, def)
self.lifetimer = self.lifetimer - dtime
if self.lifetimer <= 0
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")
self.object:remove()
return
@ -264,13 +264,13 @@ function mobs:register_mob(name, def)
and math.random(1, self.replace_rate) == 1 then
local pos = self.object:getpos()
pos.y = pos.y + self.replace_offset
-- print ("replace node = ".. core.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
-- print ("replace node = ".. minetest.get_node(pos).name, pos.y)
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
if self.on_replace ~= nil then
self.on_replace(self, pos)
else
core.set_node(pos, {name = self.replace_with})
minetest.set_node(pos, {name = self.replace_with})
end
end
end
@ -280,9 +280,9 @@ function mobs:register_mob(name, def)
if not self.fly then
-- floating in water (or falling)
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
local nodef = core.registered_nodes[nod]
local nodef = minetest.registered_nodes[nod]
local v = self.object:getvelocity()
if v.y > 0.1 then
@ -343,7 +343,7 @@ function mobs:register_mob(name, def)
if self.sounds.random
and math.random(1, 100) <= 1 then
core.sound_play(
minetest.sound_play(
self.sounds.random,
{
object = self.object,
@ -354,23 +354,23 @@ function mobs:register_mob(name, def)
local do_env_damage = function(self)
local pos = self.object:getpos()
local tod = core.get_timeofday()
local tod = minetest.get_timeofday()
-- daylight above ground
if self.light_damage ~= 0
and pos.y > 0
and tod > 0.2
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)
effect(pos, 5, "tnt_smoke.png")
if check_for_death(self) then return end
end
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)
local nodef = core.registered_nodes[nod.name]
local nodef = minetest.registered_nodes[nod.name]
pos.y = pos.y + 1
-- water
@ -400,16 +400,16 @@ function mobs:register_mob(name, def)
if self.jumptimer < 3 then
local pos = self.object:getpos()
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)
if not nod
or not core.registered_nodes[nod.name]
or core.registered_nodes[nod.name].walkable == false then
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == false then
return
end
if self.direction then
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,
y = pos.y,
@ -419,7 +419,7 @@ function mobs:register_mob(name, def)
if nod and nod.name and
(nod.name ~= "air"
or self.walk_chance == 0) then
local def = core.registered_items[nod.name]
local def = minetest.registered_items[nod.name]
if (def
and def.walkable
and not nod.name:find("fence"))
@ -430,7 +430,7 @@ function mobs:register_mob(name, def)
v.z = v.z * 2.2
self.object:setvelocity(v)
if self.sounds.jump then
core.sound_play(
minetest.sound_play(
self.sounds.jump,
{
object = self.object,
@ -468,7 +468,7 @@ function mobs:register_mob(name, def)
local min_dist = self.view_range + 1
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
player = oir
@ -492,7 +492,7 @@ function mobs:register_mob(name, def)
if dist < self.view_range then
-- and self.in_fov(self,p) then
-- 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
min_dist = dist
min_player = player
@ -515,7 +515,7 @@ function mobs:register_mob(name, def)
and self.state ~= "attack" then
local s = self.object:getpos()
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()
if obj
and obj.type == "monster" then
@ -565,7 +565,7 @@ function mobs:register_mob(name, def)
and self.hornytimer <= 40 then
local pos = self.object:getpos()
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 ent = nil
for i,obj in ipairs(ents) do
@ -598,10 +598,10 @@ function mobs:register_mob(name, def)
if num > 1 then
self.hornytimer = 41
ent.hornytimer = 41
core.after(
minetest.after(
7,
function(dtime)
local mob = core.add_entity(pos, self.name)
local mob = minetest.add_entity(pos, self.name)
local ent2 = mob:get_luaentity()
local textures = self.base_texture
if def.child_texture then
@ -635,7 +635,7 @@ function mobs:register_mob(name, def)
-- find player to follow
if (self.follow ~= "" or self.order == "follow") and not self.following and self.state ~= "attack" then
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()
p = player:getpos()
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()
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
for _,o in ipairs(o) do
@ -776,7 +776,7 @@ function mobs:register_mob(name, def)
elseif self.state == "walk" then
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
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
local pos = vector.round(self.object:getpos())
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()
if self.sounds.explode ~= "" then
core.sound_play(self.sounds.explode, {
minetest.sound_play(self.sounds.explode, {
pos = pos,
gain = 1.0,
max_hear_distance = 16
@ -917,7 +917,7 @@ function mobs:register_mob(name, def)
if self.fly
and dist > 2 then
local nod = core.get_node_or_nil(s)
local nod = minetest.get_node_or_nil(s)
local p1 = s
local me_y = math.floor(p1.y)
local p2 = p
@ -995,9 +995,9 @@ function mobs:register_mob(name, def)
local s2 = s
p2.y = p2.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
core.sound_play(
minetest.sound_play(
self.sounds.attack,
{
object = self.object,
@ -1054,7 +1054,7 @@ function mobs:register_mob(name, def)
self:set_animation("punch")
if self.sounds.attack then
core.sound_play(
minetest.sound_play(
self.sounds.attack,
{
object = self.object,
@ -1064,7 +1064,7 @@ function mobs:register_mob(name, def)
local p = self.object:getpos()
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 v = obj:get_luaentity().velocity
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
if staticdata then
local tmp = core.deserialize(staticdata)
local tmp = minetest.deserialize(staticdata)
if tmp then
for _,stat in pairs(tmp) do
self[_] = stat
@ -1183,7 +1183,7 @@ function mobs:register_mob(name, def)
end
end
-- print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
return core.serialize(tmp)
return minetest.serialize(tmp)
end,
on_punch = function(self, hitter, tflp, tool_capabilities, dir)
@ -1198,12 +1198,12 @@ function mobs:register_mob(name, def)
-- weapon sounds
if weapon:get_definition().sounds ~= nil then
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,
max_hear_distance = 8
})
else
core.sound_play("default_punch", {
minetest.sound_play("default_punch", {
object = hitter,
max_hear_distance = 5
})
@ -1248,7 +1248,7 @@ function mobs:register_mob(name, def)
end
-- alert others to the attack
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()
if obj then
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)
mobs.spawning_mobs[name] = true
core.register_abm(
minetest.register_abm(
{
nodenames = nodes,
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
if mobs.protected == 1
and core.is_protected(pos, "") then
and minetest.is_protected(pos, "") then
return
end
-- 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
or light > max_light
or light < min_light
@ -1299,32 +1299,32 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
end
-- 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
or not nod.name
or not core.registered_nodes[nod.name]
or core.registered_nodes[nod.name].walkable == true then
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == true then
return
end
pos.y = pos.y + 1
nod = core.get_node_or_nil(pos)
nod = minetest.get_node_or_nil(pos)
if not nod
or not nod.name
or not core.registered_nodes[nod.name]
or core.registered_nodes[nod.name].walkable == true then
or not minetest.registered_nodes[nod.name]
or minetest.registered_nodes[nod.name].walkable == true then
return
end
if core.setting_getbool("display_mob_spawn") then
core.chat_send_all("[mobs] Add "..name.." at "..core.pos_to_string(pos))
if minetest.setting_getbool("display_mob_spawn") then
minetest.chat_send_all("[mobs] Add "..name.." at "..minetest.pos_to_string(pos))
end
-- spawn mob half block higher
pos.y = pos.y - 0.5
core.add_entity(pos, name)
--print ("Spawned "..name.." at "..core.pos_to_string(pos).." on "..node.name.." near "..neighbors[1])
minetest.add_entity(pos, name)
--print ("Spawned "..name.." at "..minetest.pos_to_string(pos).." on "..node.name.." near "..neighbors[1])
end
})
@ -1337,7 +1337,7 @@ end
-- particle effects
function effect(pos, amount, texture, max_size)
core.add_particlespawner(
minetest.add_particlespawner(
{
amount = amount,
time = 0.25,
@ -1367,21 +1367,21 @@ function mobs:explosion(pos, radius, fire, smoke, sound)
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm:get_data()
local p = {}
local c_air = core.get_content_id("air")
local c_ignore = core.get_content_id("ignore")
local c_obsidian = core.get_content_id("default:obsidian")
local c_brick = core.get_content_id("default:obsidianbrick")
local c_chest = core.get_content_id("default:chest_locked")
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")
local c_obsidian = minetest.get_content_id("default:obsidian")
local c_brick = minetest.get_content_id("default:obsidianbrick")
local c_chest = minetest.get_content_id("default:chest_locked")
if sound
and sound ~= "" then
core.sound_play(sound, {
minetest.sound_play(sound, {
pos = pos,
gain = 1.0,
max_hear_distance = 16
})
end
-- if area protected then no blast damage
if core.is_protected(pos, "") then
if minetest.is_protected(pos, "") then
return
end
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
and data[vi] ~= c_obsidian and data[vi] ~= c_brick
and data[vi] ~= c_chest then
local n = core.get_node(p).name
if core.get_item_group(n, "unbreakable") ~= 1 then
local n = minetest.get_node(p).name
if minetest.get_item_group(n, "unbreakable") ~= 1 then
-- if chest then drop items inside
if n == "default:chest" then
local meta = core.get_meta(p)
local meta = minetest.get_meta(p)
local inv = meta:get_inventory()
for i = 1,32 do
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
obj:setvelocity({x = math.random(-2, 2), y = 7, z = math.random(-2, 2)})
end
end
end
if fire > 0
and (core.registered_nodes[n].groups.flammable
and (minetest.registered_nodes[n].groups.flammable
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
core.remove_node(p)
minetest.remove_node(p)
end
if smoke > 0 then
effect(p, 2, "tnt_smoke.png", 5)
@ -1432,7 +1432,7 @@ function check_for_death(self)
if hp > 0 then
self.health = hp
if self.sounds.damage ~= nil then
core.sound_play(
minetest.sound_play(
self.sounds.damage,
{
object = self.object,
@ -1446,7 +1446,7 @@ function check_for_death(self)
local obj = nil
for _,drop in ipairs(self.drops) do
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
obj:setvelocity(
{
@ -1458,7 +1458,7 @@ function check_for_death(self)
end
end
if self.sounds.death ~= nil then
core.sound_play(
minetest.sound_play(
self.sounds.death,
{
object = self.object,
@ -1486,7 +1486,7 @@ end
-- modified from TNT mod
function entity_physics(pos, radius)
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
for _, obj in pairs(objs) do
obj_pos = obj:getpos()
@ -1503,7 +1503,7 @@ end
-- register arrow for shoot attack
function mobs:register_arrow(name, def)
if not name or not def then return end -- errorcheck
core.register_entity(
minetest.register_entity(
name,
{
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 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 self.hit_node
and core.registered_nodes[node]
and core.registered_nodes[node].walkable then
and minetest.registered_nodes[node]
and minetest.registered_nodes[node].walkable then
self.hit_node(self, pos, node)
if self.drop == true then
pos.y = pos.y + 1
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
self.object:remove() ; -- print ("hit node")
return
@ -1541,7 +1541,7 @@ function mobs:register_arrow(name, def)
if (self.hit_player or self.hit_mob)
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
and player:is_player() then
self.hit_player(self, player)
@ -1565,7 +1565,7 @@ end
-- Spawn Egg
function mobs:register_egg(mob, desc, background)
local invimg = background
core.register_craftitem(
minetest.register_craftitem(
mob,
{
description = desc,
@ -1573,9 +1573,9 @@ function mobs:register_egg(mob, desc, background)
on_place = function(itemstack, placer, pointed_thing)
local pos = 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
local mob = core.add_entity(pos, mob)
local mob = minetest.add_entity(pos, mob)
local ent = mob:get_luaentity()
if ent.type ~= "monster" then
-- set owner
@ -1603,13 +1603,13 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
-- is mob tamed?
if self.tamed == false and force_take == false then
core.chat_send_player(name, "Not tamed!")
minetest.chat_send_player(name, "Not tamed!")
return
end
-- cannot pick up if not owner
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
end
@ -1636,7 +1636,7 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, chance_lasso,
clicker:get_inventory():add_item("main", mobname)
self.object:remove()
else
core.chat_send_player(name, "Missed!")
minetest.chat_send_player(name, "Missed!")
end
end
end
@ -1658,7 +1658,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed)
if itemstring == self.follow then
if name ~= nil then
-- take item
if not core.setting_getbool("creative_mode") then
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
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")
-- raw porkchop
core.register_craftitem(
minetest.register_craftitem(
"mobs:pork_raw",
{
description = "Raw Porkchop",
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
core.register_craftitem(
minetest.register_craftitem(
"mobs:pork",
{
description = "Cooked Porkchop",
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",
output = "mobs:pork",

View File

@ -1,5 +1,5 @@
-- wool
core.register_node(
minetest.register_node(
"mobs:wool",
{
description = "Wool Bundle",
@ -10,24 +10,24 @@ core.register_node(
})
-- raw meat
core.register_craftitem(
minetest.register_craftitem(
"mobs:meat_raw",
{
description = "Raw Meat",
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
core.register_craftitem(
minetest.register_craftitem(
"mobs:meat",
{
description = "Cooked Meat",
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",
output = "mobs:meat",
@ -36,14 +36,14 @@ core.register_craft(
})
-- net (right click to capture animal)
core.register_tool(
minetest.register_tool(
"mobs:net",
{
description = "Net (Right-click to capture)",
inventory_image = "mobs_net.png",
})
core.register_craft(
minetest.register_craft(
{
output = "mobs:net",
recipe = {
@ -54,14 +54,14 @@ core.register_craft(
})
-- lasso (right click to capture animal)
core.register_tool(
minetest.register_tool(
"mobs:lasso",
{
description = "Lasso (Right-click to capture)",
inventory_image = "mobs_lasso.png",
})
core.register_craft(
minetest.register_craft(
{
output = "mobs:lasso",
recipe = {

View File

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

View File

@ -75,7 +75,7 @@ for _, npc_type in pairs(npc_types) do
local hp = self.object:get_hp()
-- return if full health
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
end
@ -84,7 +84,7 @@ for _, npc_type in pairs(npc_types) do
self.object:set_hp(hp)
-- take item
if not core.setting_getbool("creative_mode") then
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end

View File

@ -50,7 +50,7 @@ mobs:register_mob(
replace_with = "air",
replace_offset = -1,
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 self.gotten == false then
self.object:set_properties(
@ -84,7 +84,7 @@ mobs:register_mob(
self.gotten = true -- shaved
local pos = self.object:getpos()
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
obj:setvelocity(
{

View File

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

View File

@ -3,7 +3,7 @@
local wield_image_0 = "nav_compass_inventory_0.png"
local wield_image_1 = "nav_compass_inventory_1.png"
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_0",
{
description = "Compass(E)",
@ -15,7 +15,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_1",
{
description = "Compass(NE)",
@ -27,7 +27,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_2",
{
description = "Compass(N)",
@ -39,7 +39,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_3",
{
description = "Compass(NW)",
@ -51,7 +51,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_4",
{
description = "Compass(W)",
@ -63,7 +63,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_5",
{
description = "Compass(SW)",
@ -75,7 +75,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_6",
{
description = "Compass(S)",
@ -87,7 +87,7 @@ core.register_craftitem(
stack_max = 1,
})
core.register_craftitem(
minetest.register_craftitem(
"nav:compass_7",
{
description = "Compass(SE)",
@ -99,9 +99,9 @@ core.register_craftitem(
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",
recipe = {
@ -112,7 +112,7 @@ core.register_craft(
})
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 yaw = player:get_look_yaw()
@ -128,7 +128,7 @@ function step(dtime)
for i = 1, 8 do
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.groups.nav_compass then
@ -139,7 +139,7 @@ function step(dtime)
end
end
core.register_globalstep(step)
minetest.register_globalstep(step)
-- Achievements

View File

@ -5,5 +5,5 @@
nav = {}
dofile(core.get_modpath("nav").."/map.lua")
dofile(core.get_modpath("nav").."/compass.lua")
dofile(minetest.get_modpath("nav").."/map.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 = ""
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
end
@ -65,7 +65,7 @@ function nav.show_map(player)
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]"
@ -84,9 +84,9 @@ function nav.show_map(player)
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 .. "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
local function recieve_fields(player, form_name, fields)
@ -97,11 +97,11 @@ local function recieve_fields(player, form_name, fields)
end
end
if core.setting_get_pos("static_spawnpoint") and (not core.is_singleplayer()) then
core.after(
if minetest.setting_get_pos("static_spawnpoint") and (not minetest.is_singleplayer()) then
minetest.after(
1.0,
function()
nav.add_waypoint(core.setting_get_pos("static_spawnpoint"),
nav.add_waypoint(minetest.setting_get_pos("static_spawnpoint"),
"spawn", "Spawn", true, "spawn")
end)
end
@ -109,7 +109,7 @@ end
local function on_joinplayer(player)
local name = player:get_player_name()
core.after(
minetest.after(
1.0,
function()
nav.add_waypoint(player:getpos(), "player_"..name, name, true, "player")
@ -128,7 +128,7 @@ local function step(dtime)
if timer > update_time then
local players = {}
for _, player in pairs(core.get_connected_players()) do
for _, player in pairs(minetest.get_connected_players()) do
if player ~= nil then
local name = player:get_player_name()
@ -140,7 +140,7 @@ local function step(dtime)
for wptname, wpt in pairs(nav.waypoints) do
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())
end
end
@ -150,7 +150,7 @@ local function step(dtime)
end
end
core.register_craftitem(
minetest.register_craftitem(
"nav:map",
{
description = "Map",
@ -163,7 +163,7 @@ core.register_craftitem(
end,
})
core.register_craft(
minetest.register_craft(
{
output = "nav:map",
recipe = {
@ -174,10 +174,10 @@ core.register_craft(
})
core.register_on_joinplayer(on_joinplayer)
core.register_on_leaveplayer(on_leaveplayer)
core.register_globalstep(step)
core.register_on_player_receive_fields(recieve_fields)
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_leaveplayer(on_leaveplayer)
minetest.register_globalstep(step)
minetest.register_on_player_receive_fields(recieve_fields)
-- Achievements

View File

@ -14,7 +14,7 @@ function a(v)
return ((m * g + 0.5 * cw * rho * A * v * v) / m)
end
core.register_craftitem(
minetest.register_craftitem(
"parachute:parachute", {
description = "Parachute",
inventory_image = "parachute_inventory.png",
@ -23,7 +23,7 @@ core.register_craftitem(
on_use = function(itemstack, player, pointed_thing)
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
return
@ -33,7 +33,7 @@ core.register_craftitem(
-- Spawn parachute
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})
@ -48,14 +48,14 @@ core.register_craftitem(
itemstack:take_item()
return itemstack
else
core.chat_send_player(
minetest.chat_send_player(
player:get_player_name(),
"Cannot open parachute on ground!")
end
end
})
core.register_entity(
minetest.register_entity(
"parachute:entity",
{
visual = "mesh",
@ -66,7 +66,7 @@ core.register_entity(
attached = nil,
on_step = function(self, dtime)
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
local vel = self.object:getvelocity()
@ -119,7 +119,7 @@ core.register_entity(
end
})
core.register_craft(
minetest.register_craft(
{
output = "parachute:parachute",
recipe = {

View File

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

View File

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

View File

@ -7,8 +7,8 @@ player_skins = {}
player_skins.skin_names = {"male", "female"}
if core.setting_get("player_skins_names") then
player_skins.skin_names = util.split(core.setting_get("player_skins_names"), ",")
if minetest.setting_get("player_skins_names") then
player_skins.skin_names = util.split(minetest.setting_get("player_skins_names"), ",")
end
player_skins.old_skins = {}
@ -16,7 +16,7 @@ player_skins.skins = {}
local update_time = 1
local timer = 10
local skins_file = core.get_worldpath() .. "/player_skins"
local skins_file = minetest.get_worldpath() .. "/player_skins"
local function save_skins()
local f = io.open(skins_file, "w")
@ -62,22 +62,22 @@ function player_skins.get_skin(name)
end
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
player_skins.skins[name] = tex
save_skins()
else
core.chat_send_player(name, "Invalid skin")
minetest.chat_send_player(name, "Invalid skin")
end
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
local function step(dtime)
timer = timer + dtime
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()
if player_skins.skins[name] ~= player_skins.old_skins[name] then
@ -97,8 +97,8 @@ local function on_joinplayer(player)
end
end
core.register_globalstep(step)
core.register_on_joinplayer(on_joinplayer)
minetest.register_globalstep(step)
minetest.register_on_joinplayer(on_joinplayer)
local function get_chatparams()
local s = "["
@ -138,7 +138,7 @@ function player_skins.get_formspec(playername)
return form
end
core.register_on_player_receive_fields(
minetest.register_on_player_receive_fields(
function(player, form_name, fields)
local name = player:get_player_name()
@ -148,13 +148,13 @@ core.register_on_player_receive_fields(
if skinname ~= nil then
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)
core.register_privilege("player_skin", "Can change player skin")
core.register_chatcommand(
minetest.register_privilege("player_skin", "Can change player skin")
minetest.register_chatcommand(
"player_skin",
{
params = get_chatparams(),
@ -164,13 +164,13 @@ core.register_chatcommand(
if is_valid_skin(param) then
player_skins.set_skin(name, param)
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
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
})
core.after(1.0, load_skins)
minetest.after(1.0, load_skins)
default.log("mod:player_skins", "loaded")

View File

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

View File

@ -3,12 +3,12 @@
-- 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
local messages = {}
core.register_chatcommand(
minetest.register_chatcommand(
"pm",
{
params = "<player> <message>",
@ -19,7 +19,7 @@ core.register_chatcommand(
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 messages[sendto] == nil then messages[sendto] = {} end
table.insert(messages[sendto], name .. ": " .. message)
@ -32,15 +32,15 @@ core.register_chatcommand(
end
end
core.log("action", "PM from " .. name .. " to " .. sendto
minetest.log("action", "PM from " .. name .. " to " .. sendto
.. ": " .. message)
core.chat_send_player(sendto, "PM from " .. name .. ": "
minetest.chat_send_player(sendto, "PM from " .. name .. ": "
.. message)
return true, "PM sent."
end
})
core.register_chatcommand(
minetest.register_chatcommand(
"pms",
{
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 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 amt_pms = 0
@ -57,7 +57,7 @@ core.register_chatcommand(
str = str .. " " .. msg .. "\n"
end
core.chat_send_player(name, str)
minetest.chat_send_player(name, str)
messages[name] = nil
@ -66,15 +66,15 @@ core.register_chatcommand(
})
if enable_saving then
core.register_on_joinplayer(
minetest.register_on_joinplayer(
function(player)
local name = player:get_player_name()
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
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
end
end)

View File

@ -3,7 +3,7 @@
-- By Kaadmy, for Pixture
--
if core.setting_getbool("testing_enable") then
if minetest.setting_getbool("testing_enable") then
local t1 = os.clock()
for i = 1, 10000 do
dump({x=0,y=50,z=100})
@ -18,9 +18,9 @@ if core.setting_getbool("testing_enable") then
local t3 = os.clock()
for i = 1, 10000 do
core.serialize({x=0,y=50,z=100})
minetest.serialize({x=0,y=50,z=100})
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()
for i = 1, 10000 do
@ -30,7 +30,7 @@ if core.setting_getbool("testing_enable") then
local t5 = os.clock()
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
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

View File

@ -7,8 +7,8 @@
tnt = {}
-- Default to enabled in singleplayer and disabled in multiplayer
local singleplayer = core.is_singleplayer()
local setting = core.setting_getbool("tnt_enable")
local singleplayer = minetest.is_singleplayer()
local setting = minetest.setting_getbool("tnt_enable")
if (not singleplayer and setting ~= true) or (singleplayer and setting == false) then
return
@ -20,15 +20,15 @@ local loss_prob = {}
loss_prob["default:cobble"] = 3
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
local cid_data = {}
core.after(
minetest.after(
0,
function()
for name, def in pairs(core.registered_nodes) do
cid_data[core.get_content_id(name)] = {
for name, def in pairs(minetest.registered_nodes) do
cid_data[minetest.get_content_id(name)] = {
name = name,
drops = def.drops,
on_blast = def.on_blast,
@ -54,7 +54,7 @@ local function eject_drops(drops, pos, radius)
item:set_count(count)
end
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
obj:get_luaentity().collect = true
obj:setacceleration({x=0, y=-10, z=0})
@ -82,7 +82,7 @@ local function add_drop(drops, item)
end
local function destroy(drops, pos, cid)
if core.is_protected(pos, "") then
if minetest.is_protected(pos, "") then
return
end
local def = cid_data[cid]
@ -91,9 +91,9 @@ local function destroy(drops, pos, cid)
return
end
core.remove_node(pos)
minetest.remove_node(pos)
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
add_drop(drops, item)
end
@ -120,9 +120,9 @@ local function entity_physics(pos, radius)
-- Make the damage radius larger than the destruction radius
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
local obj_pos = obj:getpos()
local obj_vel = obj:getvelocity()
@ -141,7 +141,7 @@ local function entity_physics(pos, radius)
end
local function add_effects(pos, radius)
core.add_particlespawner(
minetest.add_particlespawner(
{
amount = 128,
time = 1,
@ -160,11 +160,11 @@ local function add_effects(pos, radius)
end
function tnt.burn(pos)
local name = core.get_node(pos).name
local name = minetest.get_node(pos).name
if name == "tnt:tnt" then
core.sound_play("tnt_ignite", {pos = pos})
core.set_node(pos, {name = "tnt:tnt_burning"})
core.get_node_timer(pos):start(2)
minetest.sound_play("tnt_ignite", {pos = pos})
minetest.set_node(pos, {name = "tnt:tnt_burning"})
minetest.get_node_timer(pos):start(2)
end
end
@ -181,7 +181,7 @@ local function explode(pos, radius)
local drops = {}
local p = {}
local c_air = core.get_content_id("air")
local c_air = minetest.get_content_id("air")
for z = -radius, radius do
for y = -radius, radius do
@ -206,8 +206,8 @@ end
function tnt.boom(pos)
core.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = 128})
core.remove_node(pos)
minetest.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = 128})
minetest.remove_node(pos)
local drops = explode(pos, radius)
entity_physics(pos, radius)
@ -215,7 +215,7 @@ function tnt.boom(pos)
add_effects(pos, radius)
end
core.register_node(
minetest.register_node(
"tnt:tnt",
{
description = "TNT",
@ -235,7 +235,7 @@ core.register_node(
end,
})
core.register_node(
minetest.register_node(
"tnt:tnt_burning",
{
tiles = {
@ -258,7 +258,7 @@ core.register_node(
on_blast = function() end,
})
core.register_craft(
minetest.register_craft(
{
output = "tnt:tnt",
recipe = {
@ -268,7 +268,7 @@ core.register_craft(
}
})
core.register_craft(
minetest.register_craft(
{
type = "fuel",
recipe = "tnt:tnt",

View File

@ -28,11 +28,11 @@ function util.fixlight(pos1, pos2)
--make area stay loaded
local manip = core.get_voxel_manip()
local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2)
local nodes = core.find_nodes_in_area(pos1, pos2, "air")
local dig_node = core.dig_node
local nodes = minetest.find_nodes_in_area(pos1, pos2, "air")
local dig_node = minetest.dig_node
for _, pos in ipairs(nodes) do
dig_node(pos)
end
@ -41,10 +41,10 @@ function util.fixlight(pos1, pos2)
return #nodes
end
if core.setting_getbool("fixlight_command_enable") then
core.register_privilege("fixlight", "Can use /fixlight command")
if minetest.setting_getbool("fixlight_command_enable") then
minetest.register_privilege("fixlight", "Can use /fixlight command")
core.register_chatcommand(
minetest.register_chatcommand(
"fixlight",
{
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"
end
local player = core.get_player_by_name(name)
local player = minetest.get_player_by_name(name)
local pos = player:getpos()
pos.x = math.floor(pos.x + 0.5)
@ -69,7 +69,7 @@ if core.setting_getbool("fixlight_command_enable") then
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
@ -80,11 +80,11 @@ function util.nodefunc(pos1, pos2, name, func, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then
local manip = core.get_voxel_manip()
local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2)
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
func(pos)
end
@ -95,7 +95,7 @@ function util.getvoxelmanip(pos1, pos2)
-- return a voxel manipulator
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)
return manip
@ -107,14 +107,14 @@ function util.remove_area(pos1, pos2, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then
local manip = core.get_voxel_manip()
local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2)
end
for i = pos1.x, pos2.x-1 do
for j = pos1.y, pos2.y-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
@ -128,7 +128,7 @@ function util.areafunc(pos1, pos2, func, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then
local manip = core.get_voxel_manip()
local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2)
end
@ -147,27 +147,27 @@ function util.reconstruct(pos1, pos2, nomanip)
local pos1, pos2 = util.sort_pos(pos1, pos2)
if not nomanip then
local manip = core.get_voxel_manip()
local manip = minetest.get_voxel_manip()
manip:read_from_map(pos1, pos2)
end
-- fix chests
local nodes = core.find_nodes_in_area(pos1, pos2, "default:chest")
local node = core.registered_nodes["default:chest"]
local nodes = minetest.find_nodes_in_area(pos1, pos2, "default:chest")
local node = minetest.registered_nodes["default:chest"]
for _, pos in ipairs(nodes) do
node.on_construct(pos)
end
-- fix music players
nodes = core.find_nodes_in_area(pos1, pos2, "music:player")
node = core.registered_nodes["music:player"]
nodes = minetest.find_nodes_in_area(pos1, pos2, "music:player")
node = minetest.registered_nodes["music:player"]
for _, pos in ipairs(nodes) do
node.on_construct(pos)
end
-- fix furnaces
nodes = core.find_nodes_in_area(pos1, pos2, "default:furnace")
node = core.registered_nodes["default:furnace"]
nodes = minetest.find_nodes_in_area(pos1, pos2, "default:furnace")
node = minetest.registered_nodes["default:furnace"]
for _, pos in ipairs(nodes) do
node.on_construct(pos)
end

View File

@ -2,21 +2,21 @@
-- Single village generation
--
local mp = core.get_modpath("village")
local mp = minetest.get_modpath("village")
village.villages = {}
local village_file = core.get_worldpath() .. "/villages"
local village_file = minetest.get_worldpath() .. "/villages"
function village.get_id(name, pos)
return name .. core.hash_node_position(pos)
return name .. minetest.hash_node_position(pos)
end
function village.save_villages()
local f = io.open(village_file, "w")
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
io.close(f)
@ -33,7 +33,7 @@ function village.load_villages()
for name, fname, pos in string.gfind(l, "(.+) (%a+) (%d.+)") do
village.villages[name] = {
name = fname,
pos = core.get_position_from_hash(pos),
pos = minetest.get_position_from_hash(pos),
}
end
until f:read(0) == nil
@ -156,11 +156,11 @@ function village.lift_ground(pos, scanheight)
for y = pos.y, pos.y - scanheight, -1 do
local p = {x = pos.x, y = y, z = pos.z}
local nn = core.get_node(p).name
local an = core.get_node({x = p.x, y = p.y + 1, z = p.z}).name
local nn = minetest.get_node(p).name
local an = minetest.get_node({x = p.x, y = p.y + 1, z = p.z}).name
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 topnode == nil and nn ~= an then
topnode = nn
@ -197,11 +197,11 @@ function village.lift_ground(pos, scanheight)
local th = pos.y - y
if th <= fillerdepth - topdepth then
core.set_node(p, {name = fillernode})
minetest.set_node(p, {name = fillernode})
elseif th <= topdepth then
core.set_node(p, {name = topnode})
minetest.set_node(p, {name = topnode})
else
core.set_node(p, {name = stonenode})
minetest.set_node(p, {name = stonenode})
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
end, true)
core.place_schematic(
minetest.place_schematic(
pos,
mp.."/schematics/village_empty.mts",
"0",
@ -226,7 +226,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
true
)
core.place_schematic(
minetest.place_schematic(
{x = pos.x-6, y = pos.y-5, z = pos.z-6},
mp.."/schematics/village_filler.mts",
"0",
@ -235,7 +235,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
)
end
core.place_schematic(
minetest.place_schematic(
pos,
mp.."/schematics/village_"..chunktype..".mts",
orient,
@ -260,7 +260,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
"music:player",
function(pos)
if pr:next(1, 2) > 1 then
core.remove_node(pos)
minetest.remove_node(pos)
end
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},
"village:entity_spawner",
function(pos)
core.remove_node(pos)
minetest.remove_node(pos)
end)
return
end
@ -286,7 +286,7 @@ function village.spawn_chunk(pos, orient, replace, pr, chunktype, nofill)
"village:entity_spawner",
function(pos)
table.insert(ent_spawns, pos)
core.remove_node(pos)
minetest.remove_node(pos)
end, true)
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)
if spawn ~= nil then
spawn.y = spawn.y + 1.6
core.add_entity(spawn, ent)
minetest.add_entity(spawn, ent)
end
end
end
@ -335,7 +335,7 @@ function village.spawn_road(pos, houses, built, roads, depth, pr)
nextpos.x = nextpos.x + 12
end
local hnp = core.hash_node_position(nextpos)
local hnp = minetest.hash_node_position(nextpos)
if built[hnp] == nil then
built[hnp] = true
@ -372,14 +372,14 @@ function village.spawn_village(pos, pr)
local spawnpos = pos
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()
village.spawn_road(pos, houses, built, roads, depth, pr)
print(string.format("Took %.2fms to spawn village", (os.clock() - t1) * 1000))
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 vector.equals(houses[hnp].front, pos) then
@ -451,7 +451,7 @@ function village.spawn_village(pos, pr)
end
end
core.after(
minetest.after(
0,
function()
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.pr = PseudoRandom(core.get_mapgen_params().seed)
village.pr = PseudoRandom(minetest.get_mapgen_params().seed)
dofile(core.get_modpath("village").."/names.lua")
dofile(core.get_modpath("village").."/generate.lua")
dofile(core.get_modpath("village").."/mapgen.lua")
dofile(minetest.get_modpath("village").."/names.lua")
dofile(minetest.get_modpath("village").."/generate.lua")
dofile(minetest.get_modpath("village").."/mapgen.lua")
default.log("mod:village", "loaded")

View File

@ -1,4 +1,4 @@
core.register_node(
minetest.register_node(
"village:entity_spawner",
{
description = "Chunk defs may choose which entities to spawn here",
@ -8,7 +8,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults()
})
core.register_node(
minetest.register_node(
"village:grassland_village",
{
description = "Village spawner",
@ -18,7 +18,7 @@ core.register_node(
sounds = default.node_sound_wood_defaults()
})
core.register_node(
minetest.register_node(
"village:grassland_village_mg",
{
description = "Mapgen village spawner(Has chance of not spawning village)",
@ -35,42 +35,42 @@ core.register_node(
groups = {not_in_craftingguide = 1},
})
core.register_abm(
minetest.register_abm(
{
nodenames = {"village:grassland_village", "village:grassland_village_mg"},
interval = 1,
chance = 1,
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
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 ((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)
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
core.after(3.0, function() village.spawn_village(pos, pr) end)
minetest.after(3.0, function() village.spawn_village(pos, pr) end)
else
core.log("Cannot spawn village, too near another village")
minetest.log("Cannot spawn village, too near another village")
end
end
else
core.log("Spawning a Grassland village at "..dump(pos))
minetest.log("Spawning a Grassland village at "..dump(pos))
village.spawn_village(pos, pr)
end
end
})
core.register_decoration(
minetest.register_decoration(
{
deco_type = "simple",
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}
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_pr=PseudoRandom(core.get_mapgen_params().seed + 2387)
local weather_pr=PseudoRandom(minetest.get_mapgen_params().seed + 2387)
local function play_sound()
if weather_soundspec ~= nil then
core.sound_stop(weather_soundspec)
minetest.sound_stop(weather_soundspec)
end
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
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
end
core.after(3, play_sound)
minetest.after(3, play_sound)
end
function setweather_type(type)
@ -49,9 +49,9 @@ function setweather_type(type)
end
end
core.register_globalstep(
minetest.register_globalstep(
function(dtime)
if core.setting_getbool("weather_enable") then
if minetest.setting_getbool("weather_enable") then
if weather_pr:next(0, 5000) < 1 then
local weathertype = weather_pr:next(0, 19)
@ -70,7 +70,7 @@ core.register_globalstep(
end
end
local light = (core.get_timeofday()*2)
local light = (minetest.get_timeofday()*2)
if light > 1 then
light=1-(light-1)
@ -79,7 +79,7 @@ core.register_globalstep(
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
player:set_sky({r = skycol, g = skycol, b = skycol*1.2}, "plain", {})
player:override_day_night_ratio(light)
@ -91,10 +91,10 @@ core.register_globalstep(
local p=player:getpos()
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 maxpos = addvec(player:getpos(), {x = 15, y = 10, z = 15})
core.add_particlespawner(
minetest.add_particlespawner(
{
amount = 30,
time = 0.5,
@ -118,17 +118,17 @@ core.register_globalstep(
if math.random(0, 6000*dtime) <= 1 then
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)
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 maxpos = addvec(player:getpos(), {x = 30, y = 15, z = 30})
local vel = {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,
time = 0.4,
@ -154,56 +154,56 @@ core.register_globalstep(
end
)
core.register_abm(
minetest.register_abm(
{
nodenames = {"weather:ice"},
interval = 4,
chance = 80,
action = function(pos, node, active_object_count, active_object_count_wider)
if weather.weather ~= "snowstorm" then
core.remove_node(pos)
minetest.remove_node(pos)
end
end
})
--[[core.register_abm(
--[[minetest.register_abm(
{
nodenames = {"air"},
interval = 2,
chance = 80,
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_node=core.get_node(under_nodepos)
local under_node=minetest.get_node(under_nodepos)
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
core.set_node(under_nodepos, {name = "weather:ice"})
minetest.set_node(under_nodepos, {name = "weather:ice"})
else
if under_node.name ~= "weather:snow" then
if weather.weather == "snowstorm" then
if under_node.name ~= "default:heated_dirt_path" 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
core.set_node(under_nodepos, {name = "weather:snow"})
minetest.set_node(under_nodepos, {name = "weather:snow"})
end
end
end
else
if weather.weather ~= "snowstorm" then
core.remove_node(under_nodepos)
minetest.remove_node(under_nodepos)
end
end
end
end,
})--]]
core.register_node(
minetest.register_node(
"weather:snow",
{
description = "Snow",
@ -218,7 +218,7 @@ core.register_node(
sounds = default.node_sound_snow_defaults(),
})
core.register_node(
minetest.register_node(
"weather:ice",
{
description = "Ice",
@ -230,18 +230,18 @@ core.register_node(
sounds = default.node_sound_glass_defaults(),
on_destruct = function(pos)
local function add_water()
core.set_node(pos, {name = "default:water_source"})
minetest.set_node(pos, {name = "default:water_source"})
end
if core.find_node_near(pos, 1, {"weather:ice", "default:water_source"}) then
core.after(0, add_water)
if minetest.find_node_near(pos, 1, {"weather:ice", "default:water_source"}) then
minetest.after(0, add_water)
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",
{
params = "[storm|snowstorm|clear]",

View File

@ -15,8 +15,8 @@ welcome.rules = {
}
function welcome.get_formspec(name)
if not core.setting_getbool("welcome_enable") then
core.chat_send_player(name, "Welcoming is disabled")
if not minetest.setting_getbool("welcome_enable") then
minetest.chat_send_player(name, "Welcoming is disabled")
return ""
end
@ -27,12 +27,12 @@ function welcome.get_formspec(name)
for _, t in ipairs(welcome.rules) do
if rules ~= "" then rules = rules .. "," end
rules = rules .. core.formspec_escape(t)
rules = rules .. minetest.formspec_escape(t)
end
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(4.25, 7.75, 3, 1, "accept_rules", "Okay")
else
@ -46,14 +46,14 @@ function welcome.show_rules(name)
local f = welcome.get_formspec(name)
if f ~= "" then
core.show_formspec(name, "welcome:welcome", f)
minetest.show_formspec(name, "welcome:welcome", f)
end
end
core.register_on_player_receive_fields(
minetest.register_on_player_receive_fields(
function(player, form_name, fields)
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
return
@ -61,14 +61,14 @@ core.register_on_player_receive_fields(
if fields.accept_rules then
privs.interact = true
core.set_player_privs(name, privs)
core.chat_send_player(name, "You now have interact, follow the rules and have fun!")
minetest.set_player_privs(name, privs)
minetest.chat_send_player(name, "You now have interact, follow the rules and have fun!")
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)
core.register_chatcommand(
minetest.register_chatcommand(
"welcome",
{
description = "Show rules",
@ -77,11 +77,11 @@ core.register_chatcommand(
end
})
core.register_on_joinplayer(
minetest.register_on_joinplayer(
function(player)
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)
end
end)

View File

@ -9,13 +9,13 @@ wielditem = {}
local update_time = 1
local timer = 10 -- needs to be more than update_time
core.register_craftitem(
minetest.register_craftitem(
"wielditem:null",
{
wield_image = "ui_null.png"
})
core.register_entity(
minetest.register_entity(
"wielditem:wielditem",
{
textures = {"default:broadsword"},
@ -33,7 +33,7 @@ core.register_entity(
on_step = function(self, dtime)
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()
return
end
@ -52,7 +52,7 @@ local function attach_wielditem(player)
local name = player:get_player_name()
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]:get_luaentity().wielder = player
end
@ -64,7 +64,7 @@ local function detach_wielditem(player)
wielditem[name] = nil
end
core.register_on_joinplayer(attach_wielditem)
core.register_on_leaveplayer(detach_wielditem)
minetest.register_on_joinplayer(attach_wielditem)
minetest.register_on_leaveplayer(detach_wielditem)
default.log("mod:wielditem", "loaded")