Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Version: 3.0.39
Date: ???
Changes:
- Cars, tanks, and spidertrons are no longer remote-drivable if they have the "hidden" flag.
- Fixed a possible stack overflow.
---------------------------------------------------------------------------------------------------
Version: 3.0.38
Date: 2025-08-23
Expand Down
29 changes: 23 additions & 6 deletions lib/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ local pysex_globals = {
"Planets",
"H2O2",
"Centrifuge",
"RocketSilo",
-- tries to read nil
"on_search",
}
Expand Down Expand Up @@ -273,13 +274,19 @@ if py.stage == "data" then
}
end

local message_sent = false
local data_message_sent = false
local control_message_sent = false
local control_globals_outside_of_events = false
if py.stage == "control" then
py.on_event(defines.events.on_tick, function(_)
---@diagnostic disable-next-line: undefined-field
if not message_sent and prototypes.mod_data["py-undocumented-globals"].get("exist") then
if not data_message_sent and prototypes.mod_data["py-undocumented-globals"].get("exist") then
game.print("[color=255,0,0]found references to undefined globals in data stage, check logs[/color]")
message_sent = true
data_message_sent = true
end
if not control_message_sent and control_globals_outside_of_events then
game.print("[color=255,0,0]found references to undefined globals in control stage, check logs[/color]")
control_message_sent = true
end
end)
end
Expand All @@ -290,19 +297,28 @@ if settings.startup["pypp-no-globals"].value then
if not declaredNames[n] then
if py.stage == "control" then
-- temp
game.print(debug.traceback("attempt to write to undeclared global variable, please report it\nIf this is intended, add it to the globals list in pypp/lib/lib.lua" .. n, 2))
if game then
game.print(debug.traceback("attempt to write to undeclared global variable, please report it\nIf this is intended, add it to the globals list in pypp/lib/lib.lua\n" .. n, 2))
else
log(debug.traceback("attempt to write to undeclared global variable, please report it\nIf this is intended, add it to the globals list in pypp/lib/lib.lua\n" .. n, 2))
control_globals_outside_of_events = true
end
-- end temp
-- error("attempt to write to undeclared variable: " .. n, 2)
end
log(debug.traceback("INFO: creating a new global variable\nIf this is intended, add it to the globals list in pypp/lib/lib.lua" .. n, 2))
log(debug.traceback("INFO: creating a new global variable\nIf this is intended, add it to the globals list in pypp/lib/lib.lua\n" .. n, 2))
end
rawset(t, n, v) -- do the actual set
end,
__index = function(_, n)
if not declaredNames[n] then
if py.stage == "control" then
-- temp
game.print(debug.traceback("attempt to read undeclared global variable, please report it: " .. n, 2))
if game then
game.print(debug.traceback("attempt to read undeclared global variable, please report it: " .. n, 2))
else
control_globals_outside_of_events = true
end
log(debug.traceback("attempt to read undeclared global variable: " .. n, 2))
-- end temp
-- error("attempt to read undeclared variable: " .. n, 2)
Expand Down Expand Up @@ -336,3 +352,4 @@ for _, var in pairs(global_vars) do
end

declare("_")
declare("game") -- needed for globals used outside of events