plots_of_id #3558
AliasAlreadyTaken
commented 2023-01-18 10:38:48 +00:00
Owner
```
2023-01-18 10:37:51: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '??' in callback on_chat_message(): (load):61: attempt to index field 'format' (a nil value)
2023-01-18 10:37:51: ERROR[Main]: stack traceback:
2023-01-18 10:37:51: ERROR[Main]: (load):61: in function 'func'
2023-01-18 10:37:51: ERROR[Main]: ...inetest_test/bin/../builtin/profiler/instrumentation.lua:107: in function 'func'
2023-01-18 10:37:51: ERROR[Main]: /home/mt/5.6.1/Minetest_test/bin/../builtin/game/chat.lua:79: in function 'func'
2023-01-18 10:37:51: ERROR[Main]: ...inetest_test/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_test/bin/../builtin/profiler/instrumentation.lua:100>
2023-01-18 10:37:51: ERROR[Main]: .../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:431: in function <.../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:417>
```
AliasAlreadyTaken
commented 2023-01-18 10:38:59 +00:00
Author
Owner
```
function print_plots(name, param)
--defense
if not areas or not areas.areas then
return false, "Missing dependency to areas"
end
if not name or not param then
return false, "Missing param. See usage /help plots_of_id"
end
if not core.get_player_by_name(name) then
return false, "No legit player"
end
if not tonumber(param) or not areas.areas[tonumber(param)] then
return false, "Area does not exist"
end
if not areas.areas[tonumber(param)].yl_city then
return false, "Area is not a city"
end
local city = areas.areas[tonumber(param)]
local pos1 = city.pos1
local pos2 = city.pos2
local inner_areas_of_city = areas:getAreasIntersectingArea(pos1,pos2)
-- Which of those inner areas are plots?
local plot_areas_of_city = {}
for area_id,area in pairs(inner_areas_of_city) do
if area.yl_plot then
plot_areas_of_city[area_id] = area
end
end
-- Find the one and only subarea of every plotarea
local count = 1
local t_text = {}
t_text[count] = {"#", "ID", "Name", "Owner", "Due"}
for plotarea_id,_ in pairs(plot_areas_of_city) do
local children_of_plot = areas:getChildren(plotarea_id)
if #children_of_plot ~= 1 then
core.log("warning","[MOD] yl_cities: Plot has more than one subarea! Area ID: "..plotarea_id)
else
--sub_areas_of_plots[children_of_plot[1]] = areas.areas[children_of_plot[1]]
local childarea = areas.areas[children_of_plot[1]]
count = count +1
local pauth = core.get_auth_handler().get_auth(childarea.owner)
local due = "???"
if pauth and pauth.last_login and pauth.last_login ~= -1 then
due = os.date("!%Y-%m-%dT%H:%M:%SZ", pauth.last_login)
end
t_text[count] = {count-1, children_of_plot[1],childarea.name,childarea.owner,due}
end
end
-- return the result
local ret = ""
if core.get_modpath("worldeditadditions") then
if type(worldeditadditions.make_ascii_table) == "function" then
ret = worldeditadditions.make_ascii_table(t_text)
elseif type(worldeditadditions.format.make_ascii_table) == "function" then
ret = worldeditadditions.format.make_ascii_table(t_text)
else
core.log("error","Something went wrong, no function available")
ret = "Something went wrong, no function available"
end
else
for k, v in ipairs(t_text) do
ret = ret .. table.concat(t_text[k], " ") .. "\n"
end
end
return true,ret
end
local chatcommand_cmd = "plots_of_id"
local chatcommand_definition = {
params = "<city area id>", -- Short parameter description
description = "Plot status of area id", -- Full description
privs = {staff = true}, -- Require the "privs" privilege to run
func = function(name, param)
return print_plots(name, param)
end
-- Called when command is run. Returns boolean success and text output.
-- Special case: The help message is shown to the player if `func`
-- returns false without a text output.
}
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)
```
AliasAlreadyTaken
added the 2023-01-18 10:42:10 +00:00
1. kind/bug
label
Labels
No Label
1. kind/balancing
1. kind/breaking
1. kind/bug
1. kind/construction
1. kind/documentation
1. kind/enhancement
1. kind/griefing
1. kind/invalid
1. kind/meme
1. kind/node limit
1. kind/other
1. kind/protocol
2. prio/controversial
2. prio/critical
2. prio/elevated
2. prio/good first issue
2. prio/interesting
2. prio/low
3. source/art
3. source/client
3. source/engine
3. source/ingame
3. source/integration
3. source/lag
3. source/license
3. source/mod upstream
3. source/unknown
3. source/website
4. step/approved
4. step/at work
4. step/blocked
4. step/discussion
4. step/help wanted
4. step/needs confirmation
4. step/partially fixed
4. step/question
4. step/ready to deploy
4. step/ready to QA test
4. step/want approval
5. result/cannot reproduce
5. result/duplicate
5. result/fixed
5. result/maybe
5. result/wontfix
ugh/petz
ugh/QA main
ugh/QA NOK
ugh/QA OK
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: your-land/bugtracker#3558
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?