Skip to content

minetest -> core #1407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mods/apis/ctf_gui/dev.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
local unset_function = "return "

function ctf_gui.show_formspec_dev(player, formname, formspec, formcontext)
local filepath = minetest.get_worldpath().."/ctf_gui/"
local filepath = core.get_worldpath().."/ctf_gui/"
local filename = filepath.."file_edit.txt"
local slower_loop = false

minetest.chat_send_all("Started formspec editing file at "..filename)
core.chat_send_all("Started formspec editing file at "..filename)

minetest.mkdir(filepath)
core.mkdir(filepath)

local file = assert(io.open(filename, "w"))
if type(formspec) ~= "function" then
Expand All @@ -24,15 +24,15 @@ function ctf_gui.show_formspec_dev(player, formname, formspec, formcontext)
local result, form = pcall((loadstring(formspec) or function() return function() end end)(), formcontext)

ctf_gui.show_formspec(player, formname,
result and form or "size[10,10]hypertext[0,0;10,10;err;"..minetest.formspec_escape(form or "").."]"
result and form or "size[10,10]hypertext[0,0;10,10;err;"..core.formspec_escape(form or "").."]"
)

slower_loop = not result
else
ctf_gui.show_formspec(player, formname, formspec)
end

minetest.after(slower_loop and 3 or 1, function()
core.after(slower_loop and 3 or 1, function()
local f = assert(io.open(filename, "r"))
local new_form = f:read("*a")

Expand All @@ -45,7 +45,7 @@ function ctf_gui.show_formspec_dev(player, formname, formspec, formcontext)
if type(formspec) == "function" or not formspec:match("^exit") then
interval()
else
minetest.request_shutdown("Formspec dev requested shutdown", true)
core.request_shutdown("Formspec dev requested shutdown", true)
end
end)
end
Expand Down
64 changes: 32 additions & 32 deletions mods/apis/ctf_gui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local context = {}
local gui_users_initialized = {}

function ctf_gui.init()
local modname = minetest.get_current_modname()
local modname = core.get_current_modname()

assert(not gui_users_initialized[modname], "Already initialized for mod "..dump(modname))

Expand All @@ -20,11 +20,11 @@ function ctf_gui.init()

if ctx._formname == formname and ctx._on_formspec_input then
if ctx._privs then
local playerprivs = minetest.get_player_privs(pname)
local playerprivs = core.get_player_privs(pname)

for priv, needed in pairs(ctx._privs) do
if needed and not playerprivs[priv] then
minetest.log("warning", string.format(
core.log("warning", string.format(
"Player '%q' doesn't have the privs needed to access the formspec '%s'",
pname, formname
))
Expand All @@ -39,16 +39,16 @@ function ctf_gui.init()
local action = ctx._on_formspec_input(pname, ctx, fields, ...)

if action == "refresh" then
minetest.log("action", "Refreshing formspec "..dump(ctx._formname).." to "..dump(pname))
minetest.show_formspec(pname, ctx._formname, ctx._formspec(ctx))
core.log("action", "Refreshing formspec "..dump(ctx._formname).." to "..dump(pname))
core.show_formspec(pname, ctx._formname, ctx._formspec(ctx))
end
end
end
end)
end

function ctf_gui.old_init()
local modname = minetest.get_current_modname()
local modname = core.get_current_modname()

assert(not gui_users_initialized[modname], "Already initialized for mod: "..modname)

Expand All @@ -60,11 +60,11 @@ function ctf_gui.old_init()

if ctx.formname == formname and ctx.elements then
if ctx.privs then
local playerprivs = minetest.get_player_privs(pname)
local playerprivs = core.get_player_privs(pname)

for priv, needed in pairs(ctx.privs) do
if needed and not playerprivs[priv] then
minetest.log("warning", string.format(
core.log("warning", string.format(
"Player '%q' doesn't have the privs needed to access the formspec '%s'",
pname, formname
))
Expand All @@ -86,7 +86,7 @@ function ctf_gui.old_init()
end
end
if bad then
minetest.log("warning", string.format(
core.log("warning", string.format(
"Player %s sent unallowed values for formspec %s : %s",
pname, formname, dump(fields)
))
Expand Down Expand Up @@ -116,18 +116,18 @@ function ctf_gui.show_formspec(player, formname, formspec, formcontext)
context[player]._formname = formname
context[player]._formspec = formspec

minetest.log("action", "Showing new_formspec "..dump(formname).." to "..dump(player))
core.log("action", "Showing new_formspec "..dump(formname).." to "..dump(player))
if type(formspec) == "function" then
minetest.show_formspec(player, formname, formspec(formcontext))
core.show_formspec(player, formname, formspec(formcontext))
else
minetest.show_formspec(player, formname, formspec)
core.show_formspec(player, formname, formspec)
end
end

do
local remove = table.remove
local concat = table.concat
local formspec_escape = minetest.formspec_escape
local formspec_escape = core.formspec_escape
local format = string.format
local unpck = unpack

Expand All @@ -146,7 +146,7 @@ do
end
end

-- minetest.log("action", "[ctf_gui] unpacking: "..dump(l))
-- core.log("action", "[ctf_gui] unpacking: "..dump(l))
return format(base, unpck(l))
end

Expand Down Expand Up @@ -180,7 +180,7 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
formdef.scroll_pos = {}
end

minetest.handle_async(function(fdef, ELEM_SIZE, SCROLLBAR_WIDTH)
core.handle_async(function(fdef, ELEM_SIZE, SCROLLBAR_WIDTH)
local maxscroll = {x = 0, y = 0}
local formspec = "formspec_version[4]" ..
string.format("size[%f,%f]", fdef.size.x + SCROLLBAR_WIDTH, fdef.size.y + SCROLLBAR_WIDTH) ..
Expand Down Expand Up @@ -231,7 +231,7 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
)

for id, def in pairs(fdef.elements) do
id = minetest.formspec_escape(id)
id = core.formspec_escape(id)

if def.type == "label" then
if def.centered then
Expand All @@ -244,14 +244,14 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
def.size.x,
def.size.y,
id,
minetest.formspec_escape(def.label)
core.formspec_escape(def.label)
)
else
formspec = formspec .. string.format(
"label[%f,%f;%s]",
def.pos.x,
def.pos.y,
minetest.formspec_escape(def.label)
core.formspec_escape(def.label)
)
end
elseif def.type == "field" then
Expand All @@ -265,8 +265,8 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
def.size.x,
def.size.y,
id,
minetest.formspec_escape(def.label or ""),
minetest.formspec_escape(def.default or "")
core.formspec_escape(def.label or ""),
core.formspec_escape(def.default or "")
)
elseif def.type == "button" then
formspec = formspec .. string.format(
Expand All @@ -277,7 +277,7 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
def.size.x,
def.size.y,
id,
minetest.formspec_escape(def.label)
core.formspec_escape(def.label)
)
elseif def.type == "dropdown" then
formspec = formspec .. string.format(
Expand All @@ -297,7 +297,7 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
def.pos.x,
def.pos.y,
id,
minetest.formspec_escape(def.label),
core.formspec_escape(def.label),
def.default and "true" or "false"
)
elseif def.type == "textarea" then
Expand All @@ -308,8 +308,8 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
def.size.x,
def.size.y,
def.read_only and "" or id,
minetest.formspec_escape(def.label or ""),
minetest.formspec_escape(def.default or "")
core.formspec_escape(def.label or ""),
core.formspec_escape(def.default or "")
)
elseif def.type == "image" then
formspec = formspec .. string.format(
Expand All @@ -318,12 +318,12 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
def.pos.y,
def.size.x,
def.size.y,
minetest.formspec_escape(def.texture or "")
core.formspec_escape(def.texture or "")
)
elseif def.type == "textlist" then
if def.items then
for k, v in pairs(def.items) do
def.items[k] = minetest.formspec_escape(v)
def.items[k] = core.formspec_escape(v)
end
end

Expand Down Expand Up @@ -364,7 +364,7 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
column.type = nil

for k, v in pairs(column) do
tc_out = string.format("%s,%s=%s", tc_out, k, minetest.formspec_escape(v))
tc_out = string.format("%s,%s=%s", tc_out, k, core.formspec_escape(v))
end

table.insert(tablecolumns, tc_out)
Expand Down Expand Up @@ -460,16 +460,16 @@ function ctf_gui.old_show_formspec(player, formname, formdef)
formdef._info = formdef
context[player] = formdef

if minetest.get_player_by_name(player) then
minetest.log("action", "Showing formspec "..dump(formname).." to "..dump(player))
minetest.show_formspec(player, formname, formspec)
if core.get_player_by_name(player) then
core.log("action", "Showing formspec "..dump(formname).." to "..dump(player))
core.show_formspec(player, formname, formspec)
end
end,
formdef, ctf_gui.ELEM_SIZE, ctf_gui.SCROLLBAR_WIDTH)
end

minetest.register_on_leaveplayer(function(player)
core.register_on_leaveplayer(function(player)
context[player:get_player_name()] = nil
end)

dofile(minetest.get_modpath("ctf_gui").."/dev.lua")
dofile(core.get_modpath("ctf_gui").."/dev.lua")
4 changes: 2 additions & 2 deletions mods/apis/ctf_settings/global_settings.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local S = minetest.get_translator(minetest.get_current_modname())
local S = core.get_translator(core.get_current_modname())

ctf_settings.register("ctf_kill_list:tp_size", {
type = "list",
Expand All @@ -16,7 +16,7 @@ ctf_settings.register("use_hudbars", {
"health, stamina, and breath.\n" ..
"Disconnect and reconnect to see effects.",
on_change = function(player, new_value)
minetest.chat_send_player(player:get_player_name(), minetest.colorize("cyan",
core.chat_send_player(player:get_player_name(), core.colorize("cyan",
"[Notice]: You need to rejoin for your HUD to change"
))
end,
Expand Down
10 changes: 5 additions & 5 deletions mods/apis/ctf_settings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ ctf_settings = {
local FORMSIZE = {x = 8, y = 9.4}
local SCROLLBAR_W = 0.4

local S = minetest.get_translator(minetest.get_current_modname())
local S = core.get_translator(core.get_current_modname())

minetest.after(0, function()
core.after(0, function()
table.sort(ctf_settings.settings_list, function(a, b) return a < b end)
end)

Expand Down Expand Up @@ -62,7 +62,7 @@ local function make_scrollbaroptions_for_scroll_container(visible_l, total_l, sc
return ("scrollbaroptions[min=0;max=%f;thumbsize=%f]"):format(max / scroll_factor, thumb_size / scroll_factor)
end

minetest.register_on_mods_loaded(function()
core.register_on_mods_loaded(function()
sfinv.register_page("ctf_settings:settings", {
title = S("Settings"),
get = function(self, player, context)
Expand Down Expand Up @@ -197,7 +197,7 @@ minetest.register_on_mods_loaded(function()
refresh = true
end
elseif setting.type == "bar" then
local scrollevent = minetest.explode_scrollbar_event(value)
local scrollevent = core.explode_scrollbar_event(value)

if scrollevent.value and context.setting[field] ~= tostring(scrollevent.value) then
context.setting[field] = tostring(scrollevent.value)
Expand All @@ -216,7 +216,7 @@ minetest.register_on_mods_loaded(function()
if not refresh then return end

if fields.settings_scrollbar then
local scrollevent = minetest.explode_scrollbar_event(fields.settings_scrollbar)
local scrollevent = core.explode_scrollbar_event(fields.settings_scrollbar)

if scrollevent.value then
context.settings_scrollbar = scrollevent.value
Expand Down
12 changes: 6 additions & 6 deletions mods/apis/hud_events/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ local hud_queues = {
}
local quick_event_timer = {}

minetest.register_on_leaveplayer(function(player)
core.register_on_leaveplayer(function(player)
local pname = player:get_player_name()

for channel=1, #hud_queues do
Expand Down Expand Up @@ -59,7 +59,7 @@ local function show_quick_hud_event(player, huddef)
if quick_event_timer[pname] then
quick_event_timer[pname]:cancel()
end
quick_event_timer[pname] = minetest.after(HUD_SHOW_QUICK_TIME, function()
quick_event_timer[pname] = core.after(HUD_SHOW_QUICK_TIME, function()
if not player:is_player() then return end

if hud:exists(player, "hud_event_quick") then
Expand Down Expand Up @@ -90,14 +90,14 @@ local function handle_hud_events(player, channel)
})
end

hud_queues[channel][pname].t = minetest.after(HUD_SHOW_TIME, function()
player = minetest.get_player_by_name(pname)
hud_queues[channel][pname].t = core.after(HUD_SHOW_TIME, function()
player = core.get_player_by_name(pname)

if player then
hud:change(player, event_name, {text = ""})

hud_queues[channel][pname].t = minetest.after(HUD_SHOW_NEXT_TIME, function()
player = minetest.get_player_by_name(pname)
hud_queues[channel][pname].t = core.after(HUD_SHOW_NEXT_TIME, function()
player = core.get_player_by_name(pname)

if player then
if #hud_queues[channel][pname].e >= 1 then
Expand Down
6 changes: 3 additions & 3 deletions mods/apis/physics/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ local default_overrides = {
gravity = 1.0,
}

minetest.register_on_joinplayer(function(player)
core.register_on_joinplayer(function(player)
players[player:get_player_name()] = {}
end)

minetest.register_on_leaveplayer(function(player)
core.register_on_leaveplayer(function(player)
players[player:get_player_name()] = nil
end)

local function update(name)
local player = minetest.get_player_by_name(name)
local player = core.get_player_by_name(name)
local override = table.copy(default_overrides)

for _, layer in pairs(players[name]) do
Expand Down
Loading