Refactor legacy addons into Clusterio format (#413)

* Refactor custom start

* Refactor afk kick

* Fix use of assert get player

* Refactor chat popup

* Refactor chat auto reply

* Refactor help bubbles

* Refactor damage popups

* Refactor death markers

* Refactor deconstruction log

* Remove FAGC logging

* Refactor discord alerts

* Refactor insert pickup

* Refactor inventory clear

* Refactor extra logging

* Refactor nuke protection

* Refactor pollution grading

* Refactor protection jail

* Refactor report jail

* Refactor mine depletion

* Refactor degrading tiles

* Refactor station auto name

* Refactor spawn area

* Refactor fast deconstruction

* Bug Fixes
This commit is contained in:
Cooldude2606
2025-12-02 18:34:24 +00:00
committed by GitHub
parent a45f53bc48
commit 9bd699ebf1
69 changed files with 2614 additions and 2260 deletions

View File

@@ -109,7 +109,8 @@ Async._function_metatable = {
--- @field tick number? If present, the function will be called on this game tick
--- @field next_id number? The id of the async function to be called with the return value
--- @field canceled boolean? True if the call has been canceled
--- @field returned any[]? The return values of the function call
--- @field completed boolean? True if the call has completed
--- @field return_values any? The return values of the function call
Async._return_prototype = {} -- Prototype of the async return type
Async._return_metatable = {
@@ -164,8 +165,8 @@ end
--- @param async_func Async.AsyncFunction The function which will be called using start_soon
function Async._return_prototype:return_to(async_func)
self.next_id = async_func.id
if self.returned then
async_func(table.unpack(self.returned))
if self.completed then
async_func(table.unpack(self.return_values))
end
end
@@ -239,7 +240,8 @@ function Async._function_prototype:start_now(...)
return setmetatable({
func_id = self.id,
args = { ... },
returned = rtn1,
completed = true,
return_values = rtn1,
}, Async._return_metatable)
else
error("Async function " .. self.id .. " returned an invalid status: " .. table.inspect(status))
@@ -315,7 +317,8 @@ local function exec(pending, tick)
elseif status == Async.status.complete or status == nil then
-- The function has finished execution, raise the custom event
Async._queue_pressure[pending.func_id] = Async._queue_pressure[pending.func_id] - 1
pending.returned = rtn1
pending.return_values = rtn1 or {}
pending.completed = true
if pending.next_id then
resolve_next[#resolve_next + 1] = setmetatable({
func_id = pending.next_id,