Code: Select all
javaInjectAgent()
local classes = java_getLoadedClasses()
Code: Select all
for k, v in pairs(classes) do
if (v.signature:find("^Lmindustry/core/GameState;") ~= nil) then
local jclass = v.jclass
local instances = java_findAllObjectsFromClass(jclass)
local len = math.min(100, #instances)
print(string.format("objs=%s, length=%d", tostring(instances), #instances))
for k, v in pairs(instances) do
addGameState(jclass, v)
end
end
end
Code: Select all
local jClass = java_findClass('Lmindustry/core/GameState;')
So my GameState function does the following:
Code: Select all
function addGameState(class, instance)
local fields = java_getClassFields(class)
print(string.format("fields=%d", #fields))
for k, field in pairs(fields) do
local fieldValue = java_getField(instance, field.jfieldid, field.signature)
print(string.format("%s %s = %s", field.signature, field.name, tostring(fieldValue)))
end
end
So full script:
Code: Select all
javaInjectAgent()
local addressList = getAddressList()
local classes = java_getLoadedClasses()
if addressList.Count >= 1 then
for i = addressList.Count - 1, 0, -1 do
local mr = addressList.getMemoryRecord(i)
mr.delete()
end
end
function addGameStates()
-- Find GameStates
gsHeader = addressList.createMemoryRecord()
gsHeader.Description = "Game States"
gsHeader.IsGroupHeader = true
for k, v in pairs(classes) do
if (v.signature:find("^Lmindustry/core/GameState;") ~= nil) then
local jclass = v.jclass
local instances = java_findAllObjectsFromClass(jclass)
local len = math.min(100, #instances)
print(string.format("objs=%s, length=%d", tostring(instances), #instances))
for k, v in pairs(instances) do
printGameState(jclass, v)
end
end
end
end
function printGameState(class, instance)
local fields = java_getClassFields(class)
print(string.format("fields=%d", #fields))
for k, field in pairs(fields) do
local fieldValue = java_getField(instance, field.jfieldid, field.signature)
print(string.format("%s %s = %s", field.signature, field.name, tostring(fieldValue)))
end
end
addGameStates()
Code: Select all
objs=table: 000000001C25B200, length=2
fields=12
I wave = 1
F wavetime = 0.0
Z gameOver = false
Z serverPaused = false
Z wasTimeout = false
Lmindustry/maps/Map; map = 1647081208
Lmindustry/game/Rules; rules = 1647081200
Lmindustry/game/GameStats; stats = 1647081192
Lmindustry/world/blocks/Attributes; envAttrs = 1647081184
Lmindustry/game/Teams; teams = 1647081176
I enemies = 0
Lmindustry/core/GameState$State; state = 1647081168
fields=12
I wave = 26
F wavetime = 3753.3090820313
Z gameOver = false
Z serverPaused = false
Z wasTimeout = false
Lmindustry/maps/Map; map = 1647081160
Lmindustry/game/Rules; rules = 1647081152
Lmindustry/game/GameStats; stats = 1647081144
Lmindustry/world/blocks/Attributes; envAttrs = 1647081136
Lmindustry/game/Teams; teams = 1647081128
I enemies = 0
Lmindustry/core/GameState$State; state = 1647081120