This commit is contained in:
cora 2022-03-12 00:54:51 +01:00
parent 4be7546c64
commit 13b8421714
7 changed files with 275 additions and 0 deletions

32
abmp/init.lua Normal file
View File

@ -0,0 +1,32 @@
local count={}
local times={}
local total=0
local nabm=0
minetest.register_on_mods_loaded(function()
for k,v in pairs(minetest.registered_abms) do
local n=v.label
local olda=v.action
minetest.registered_abms[k].action=function(pos, node, aoc, aocw)
local t1=os.clock()
local r=olda(pos, node, aoc, aocw)
times[n]=os.clock()-t1
if not count[n] then count[n] = 0 end
count[n]=count[n]+1
total=total+times[n]
nabm=nabm+1
return r
end
end
end)
minetest.register_chatcommand("abmp",{privs={debug=true},
description="Give an overview of the registered abms and how long they each take",
func=function(p)
table.sort(count)
table.sort(times)
minetest.chat_send_player(p,"counts:"..dump(count))
minetest.chat_send_player(p,"times:"..dump(times))
minetest.chat_send_player(p,"total abm time last interval:"..dump(total))
minetest.chat_send_player(p,"total abms registered:"..dump(#times))
end})

32
gsp/init.lua Normal file
View File

@ -0,0 +1,32 @@
-- This probably needs some hack to be loaded first.
-- It seems to be working at least to a degree though.
-- unlike abms globalsteps don't have a label attached
-- to them so unless we overwrite so the register
-- function we will have no idea where we're coming from.
local times={}
local total=0
local ngs=0
local oldgs=minetest.register_globalstep
function minetest.register_globalstep(func)
local n=debug.getinfo(2).short_src
ngs=ngs+1
oldgs(function(dtime)
local t1=os.clock()
local r=func(dtime)
times[n]=os.clock()-t1
total=total+times[n]
return r
end)
end
minetest.register_chatcommand("gsp",{privs={debug=true},
description="Give an overview of the registered globalsteps and how long they each take",
func=function(p)
table.sort(times)
minetest.chat_send_player(p,"times:"..dump(times))
minetest.chat_send_player(p,"total globalstep time last interval:"..dump(total))
minetest.chat_send_player(p,"total globalsteps registered:"..dump(ngs))
end})

1
gsp/mod.conf Normal file
View File

@ -0,0 +1 @@
depends=mcl_init

View File

@ -0,0 +1,150 @@
local F = minetest.formspec_escape
-- Create a detached inventory
local inv_everything = minetest.create_detached_inventory("everything", {
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
allow_put = function(inv, listname, index, stack, player)
return 0
end,
allow_take = function(inv, listname, index, stack, player)
return -1
end,
})
local inv_trash = minetest.create_detached_inventory("trash", {
allow_take = function(inv, listname, index, stack, player)
return 0
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
on_put = function(inv, listname, index, stack, player)
inv:set_list("main", {})
end,
})
inv_trash:set_size("main", 1)
local max_page = 1
local function get_chest_formspec(page)
local start = 0 + (page-1)*32
return "size[9,8.75]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", "Goddess Chest")).."]"..
"list[detached:everything;main;0,0.5;9,3;"..start.."]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"button[0,3.5;1,1;mcl_chest_of_everything_prev;"..F("<").."]"..
"button[1,3.5;1,1;mcl_chest_of_everything_next;"..F(">").."]"..
"label[2,3.5;"..F("Page: "..page).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"listring[detached:everything;main]"..
"listring[current_player;main]"
end
minetest.register_node("mcl_chest_of_everything:chest", {
description = "Chest of Everything" .. "\n" ..
"Grants access to all items",
tiles ={"chest_of_everything_chest.png^[sheet:2x2:0,0", "chest_of_everything_chest.png^[sheet:2x2:0,0",
"chest_of_everything_chest.png^[sheet:2x2:1,0", "chest_of_everything_chest.png^[sheet:2x2:1,0",
"chest_of_everything_chest.png^[sheet:2x2:1,0", "chest_of_everything_chest.png^[sheet:2x2:0,1"},
paramtype2 = "facedir",
groups = {dig_immediate=2,choppy=3},
is_ground_content = false,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Chest of Everything")
meta:set_int("page", 1)
meta:set_string("formspec", get_chest_formspec(1))
end,
on_receive_fields = function(pos, formname, fields, sender)
if formname == "" then
local meta = minetest.get_meta(pos)
local page = meta:get_int("page")
if fields.mcl_chest_of_everything_prev then
page = page - 1
elseif fields.mcl_chest_of_everything_next then
page = page + 1
end
if page < 1 then
page = 1
end
if page > max_page then
page = max_page
end
meta:set_int("page", page)
meta:set_string("formspec", get_chest_formspec(page))
end
end,
})
minetest.register_on_mods_loaded(function()
local items = {}
for itemstring,_ in pairs(minetest.registered_items) do
if itemstring ~= "" and itemstring ~= "unknown" and itemstring ~= "ignore" then
local g=minetest.get_item_group(itemstring, "not_in_creative_inventory")
if g == 0 then
table.insert(items, itemstring)
end
end
end
--[[ Sort items in this order:
* Chest of Everything
* Test tools
* Other tools
* Craftitems
* Other items
* Dummy items
* not in creative inv items]]
local function compare(item1, item2)
local def1 = minetest.registered_items[item1]
local def2 = minetest.registered_items[item2]
local tool1 = def1.type == "tool"
local tool2 = def2.type == "tool"
local testtool1 = minetest.get_item_group(item1, "testtool") == 1
local testtool2 = minetest.get_item_group(item2, "testtool") == 1
local dummy1 = minetest.get_item_group(item1, "dummy") == 1
local dummy2 = minetest.get_item_group(item2, "dummy") == 1
local craftitem1 = def1.type == "craft"
local craftitem2 = def2.type == "craft"
local nici1=minetest.get_item_group(item1, "not_in_creative_inventory")
local nici2=minetest.get_item_group(item2, "not_in_creative_inventory")
if item1 == "mcl_chest_of_everything:chest" then
return true
elseif item2 == "mcl_chest_of_everything:chest" then
return false
elseif dummy1 and not dummy2 then
return false
elseif not dummy1 and dummy2 then
return true
elseif testtool1 and not testtool2 then
return true
elseif not testtool1 and testtool2 then
return false
elseif tool1 and not tool2 then
return true
elseif not tool1 and tool2 then
return false
elseif craftitem1 and not craftitem2 then
return true
elseif not craftitem1 and craftitem2 then
return false
elseif nici1 and not nici2 then
return true
elseif not nici1 and nici2 then
return false
else
return item1 < item2
end
end
table.sort(items, compare)
inv_everything:set_size("main", #items)
max_page = math.ceil(#items / 32)
for i=1, #items do
inv_everything:add_item("main", items[i].." 1337")
end
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

58
mdv_chatcommands/init.lua Normal file
View File

@ -0,0 +1,58 @@
local S = minetest.get_translator("mcl_burning")
minetest.register_chatcommand("biome", {
params = "",
description = "Gets current biome",
privs = {debug = true},
func = function(name)
local player=minetest.get_player_by_name(name)
local biome=minetest.get_biome_data(player:get_pos())
local bname = minetest.get_biome_name(biome.biome)
minetest.chat_send_player(name,bname.. " " ..dump(biome))
end
})
minetest.register_chatcommand("burn", {
params = S("<playername> <duration> <reason>"),
description = S("Sets a player on fire for the given amount of seconds with the given reason."),
privs = { debug = true },
func = function(name, params)
local playername, duration, reason = params:match("^(.+) (.+) (.+)$")
if not (playername and duration and reason) then
return false, S("Error: Parameter missing.")
end
local player = minetest.get_player_by_name(playername)
if not player then
return false, S(
"Error: Player “@1” not found.",
playername
)
end
local duration_number = tonumber(duration)
-- Lua numbers are truthy
-- NaN is not equal to NaN
if not duration_number or (duration_number ~= duration_number) then
return false, S(
"Error: Duration “@1” is not a number.",
duration
)
end
if duration_number < 0 then
return false, S(
"Error: Duration “@1” is negative.",
duration
)
end
mcl_burning.set_on_fire(
player,
duration_number,
reason
)
return true, S(
"Set @1 on fire for @2s for the following reason: @3",
playername,
duration,
reason
)
end,
})

2
modpack.conf Normal file
View File

@ -0,0 +1,2 @@
name = mcl_devtest
author = cora