v0.2
This commit is contained in:
1 parent
93fbc37b31
commit
bdc8537014
1 file changed
+96
-54
+96
-54
@@ -18,20 +18,20 @@ local logLocation = os.getenv("SYSTEMDRIVE") .. "/Users/" .. os.getenv("USERNAME
|
|||||||
local logFound = false
|
local logFound = false
|
||||||
local logCursor = 0
|
local logCursor = 0
|
||||||
|
|
||||||
local newLogLocation = os.getenv("SYSTEMDRIVE") .. "/Users/" .. os.getenv("USERNAME") .. "/Documents/My Games/Binding of Isaac Repentance/log2.txt"
|
|
||||||
local secondaryLog = io.open(newLogLocation, "w+")
|
|
||||||
secondaryLog:write("[EID] For performance and accuracy reasons, reading glitched item descriptions from the log file requires wiping the log regularly, so while you have TMTRAINER, most of the log will be moved here\n")
|
|
||||||
--test using file:seek instead, to just move our cursor to the start of new text!
|
|
||||||
|
|
||||||
--currently english only
|
--currently english only
|
||||||
local attributeConversions = {
|
local attributeConversions = {
|
||||||
|
--chain = "Then: ",
|
||||||
chain = "",
|
chain = "",
|
||||||
active = "On use:",
|
active = "On use:#",
|
||||||
pickup_collected = "When you collect a pickup:",
|
pickup_collected = "When you collect a pickup:#",
|
||||||
enemy_kill = "On kill, chance to:",
|
enemy_kill = "On kill, chance to:#",
|
||||||
|
damage_taken = "When you take damage:#",
|
||||||
|
entity_spawned = "When a {T1} is spawned, chance to:#",
|
||||||
|
tear_fire = "When you fire a tear, chance to:#",
|
||||||
|
enemy_hit = "On hitting an enemy, chance to:#",
|
||||||
|
room_clear = "On room clear:#",
|
||||||
|
|
||||||
|
area_damage = "Deal {1} damage in an area around you",
|
||||||
area_damage = "Deal {1} damage to all enemies in the room",
|
|
||||||
add_temporary_effect = "Gain {1} for the room",
|
add_temporary_effect = "Gain {1} for the room",
|
||||||
convert_entities = "Convert all {1} in the room to {2}",
|
convert_entities = "Convert all {1} in the room to {2}",
|
||||||
use_active_item = "Use {1}",
|
use_active_item = "Use {1}",
|
||||||
@@ -39,17 +39,27 @@ local attributeConversions = {
|
|||||||
fart = "Fart with size {1}",
|
fart = "Fart with size {1}",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local lastEffectTrigger = "chain"
|
||||||
|
|
||||||
local function parseEffectLine(raw)
|
local function parseEffectLine(raw)
|
||||||
local words = {}
|
local words = {}
|
||||||
for w in string.gmatch(raw,"%S+") do table.insert(words, w) end
|
for w in string.gmatch(raw,"%S+") do table.insert(words, w) end
|
||||||
|
|
||||||
|
local triggerReplacements = {}
|
||||||
|
local replacements = {}
|
||||||
|
|
||||||
-- words[1] = "[INFO]", words[2] = "-"
|
-- words[1] = "[INFO]", words[2] = "-"
|
||||||
local effectTrigger = words[3]
|
local effectTrigger = words[3]
|
||||||
|
if (string.find(effectTrigger, "entity_spawned")) then
|
||||||
|
effectTrigger = "entity_spawned"
|
||||||
|
triggerReplacements[1] = string.sub(words[3], 16, -2)
|
||||||
|
end
|
||||||
-- words[4] = "->"
|
-- words[4] = "->"
|
||||||
local effectType = words[5]
|
local effectType = words[5]
|
||||||
local fullEffect = ""
|
local fullEffect = ""
|
||||||
for i=5,#words do fullEffect = fullEffect .. words[i] .. " " end
|
for i=5,#words do fullEffect = fullEffect .. words[i] .. " " end
|
||||||
|
|
||||||
local replacements = {}
|
|
||||||
local extraText = ""
|
local extraText = ""
|
||||||
-- switch statement for how to handle the words after the effect type
|
-- switch statement for how to handle the words after the effect type
|
||||||
if effectType == "add_temporary_effect" or effectType == "use_active_item" then
|
if effectType == "add_temporary_effect" or effectType == "use_active_item" then
|
||||||
@@ -59,67 +69,71 @@ local function parseEffectLine(raw)
|
|||||||
name = name .. words[i]
|
name = name .. words[i]
|
||||||
if (i ~= #words) then name = name .. " " end
|
if (i ~= #words) then name = name .. " " end
|
||||||
end
|
end
|
||||||
replacements[1] = name
|
|
||||||
|
replacements[1] = "{{Collectible" .. Isaac.GetItemIdByName(name) .. "}}" .. name
|
||||||
elseif effectType == "convert_entities" then
|
elseif effectType == "convert_entities" then
|
||||||
--figure out how to convert entity numbers
|
--figure out how to convert entity numbers
|
||||||
replacements[1] = words[6]
|
replacements[1] = words[6]
|
||||||
replacements[2] = words[8]
|
replacements[2] = words[8]
|
||||||
|
elseif effectType == "spawn_entity" then
|
||||||
|
replacements[1] = words[6]
|
||||||
|
elseif effectType == "fart" then
|
||||||
|
replacements[1] = words[6]
|
||||||
|
elseif effectType == "area_damage" then
|
||||||
|
--I could check for 0 damage here and not show it
|
||||||
|
--It also has flags in words[8] but they don't seem very useful, usually all zeroes
|
||||||
|
replacements[1] = words[6]
|
||||||
end
|
end
|
||||||
|
|
||||||
local eidString = ""
|
local eidString = ""
|
||||||
eidString = eidString .. (attributeConversions[effectTrigger] or effectTrigger) .. "#"
|
if effectTrigger ~= lastEffectTrigger then eidString = eidString .. (attributeConversions[effectTrigger] or (effectTrigger .. "#")) end
|
||||||
eidString = eidString .. (attributeConversions[effectType] or fullEffect) .. extraText .. "#"
|
eidString = eidString .. (attributeConversions[effectType] or fullEffect) .. extraText .. "#"
|
||||||
for k,v in ipairs(replacements) do
|
for k,v in ipairs(triggerReplacements) do eidString = string.gsub(eidString, "{T" .. k .. "}", v) end
|
||||||
eidString = string.gsub(eidString, "{" .. k .. "}", v)
|
for k,v in ipairs(replacements) do eidString = string.gsub(eidString, "{" .. k .. "}", v) end
|
||||||
end
|
|
||||||
|
if effectTrigger ~= "chain" then lastEffectTrigger = effectTrigger end
|
||||||
return eidString
|
return eidString
|
||||||
end
|
end
|
||||||
|
|
||||||
--work on how resuming a game works (determine current id by checking if item ids exist)
|
--SOMETHING SCREWY WITH GLOWING HOURGLASS
|
||||||
|
|
||||||
local function GameStartTMTRAINER(_,isSave)
|
local function CountLogItems()
|
||||||
local theLog = io.open(logLocation, "r")
|
local theLog = io.open(logLocation, "r")
|
||||||
if (theLog == nil) then
|
theLog:seek("set", logCursor)
|
||||||
print("[EID] Could not find the log file at " .. logLocation .. "; glitched item descriptions won't work!")
|
|
||||||
logFound = false
|
|
||||||
return
|
|
||||||
else
|
|
||||||
logFound = true
|
|
||||||
end
|
|
||||||
spawnedItems = 0
|
|
||||||
if isSave then
|
|
||||||
--check what item ID we're on
|
|
||||||
local config = Isaac.GetItemConfig()
|
|
||||||
while config:GetCollectible(maxNumber - spawnedItems - 1) ~= nil do
|
|
||||||
spawnedItems = spawnedItems + 1
|
|
||||||
end
|
|
||||||
print("resuming at " .. (maxNumber - spawnedItems - 1))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, GameStartTMTRAINER)
|
|
||||||
|
|
||||||
--[[
|
local itemCount = 0
|
||||||
EID:AddCallback(ModCallbacks.MC_PRE_ENTITY_SPAWN, function(_, enttype, variant, subtype, pos, vel, spawner, seed)
|
|
||||||
if (EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER) and enttype == 5 and variant == 100 and subtype == 0) then
|
local line = theLog:read()
|
||||||
print("[EID] TMTRAINER SPAWNED " .. (maxNumber - spawnedItems - 1))
|
while line ~= nil do
|
||||||
Isaac.DebugString("[EID] TMTRAINER SPAWNED " .. (maxNumber - spawnedItems - 1))
|
if string.find(line, "initialized with") then
|
||||||
--print("PRE ENTITY SPAWN " .. enttype .. "." .. variant .. "." .. subtype .. ", " .. tostring(pos))
|
itemCount = itemCount + 1
|
||||||
--Isaac.DebugString("PRE ENTITY SPAWN " .. enttype .. "." .. variant .. "." .. subtype .. ", " .. tostring(pos))
|
end
|
||||||
|
line = theLog:read()
|
||||||
|
end
|
||||||
|
|
||||||
|
theLog:close()
|
||||||
|
return itemCount
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
]]
|
|
||||||
|
|
||||||
local function CheckLogForItems(_)
|
local function CheckLogForItems(_)
|
||||||
if (not logFound or game:GetFrameCount() % 5 ~= 0 or not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER)) then return end
|
if (not logFound or game:GetFrameCount() % 5 ~= 0 or not EID:PlayersHaveCollectible(CollectibleType.COLLECTIBLE_TMTRAINER)) then return end
|
||||||
local logLines = io.lines(logLocation)
|
|
||||||
local numEffects = 0
|
local numEffects = 0
|
||||||
local itemScore = 0
|
local itemScore = 0
|
||||||
local effects = {}
|
local effects = {}
|
||||||
local eidDesc = ""
|
local eidDesc = ""
|
||||||
for line in io.lines(logLocation) do
|
|
||||||
|
local theLog = io.open(logLocation, "r")
|
||||||
|
theLog:seek("set", logCursor)
|
||||||
|
|
||||||
|
local logLines = {}
|
||||||
|
local line = theLog:read()
|
||||||
|
while line ~= nil do
|
||||||
if string.find(line, "initialized with") then
|
if string.find(line, "initialized with") then
|
||||||
local count = 0
|
local count = 0
|
||||||
spawnedItems = spawnedItems + 1
|
spawnedItems = spawnedItems + 1
|
||||||
|
lastEffectTrigger = "chain"
|
||||||
|
eidDesc = ""
|
||||||
-- find the number of effects, and the score given
|
-- find the number of effects, and the score given
|
||||||
-- (this match gets every number in the line)
|
-- (this match gets every number in the line)
|
||||||
for s in string.gmatch(line, "%d*%.?%d+") do
|
for s in string.gmatch(line, "%d*%.?%d+") do
|
||||||
@@ -130,22 +144,50 @@ local function CheckLogForItems(_)
|
|||||||
itemScore = tonumber(s)
|
itemScore = tonumber(s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
eidDesc = "Score: " .. itemScore .. "#"
|
|
||||||
elseif numEffects > 0 then
|
elseif numEffects > 0 then
|
||||||
numEffects = numEffects - 1
|
numEffects = numEffects - 1
|
||||||
table.insert(effects, line)
|
table.insert(effects, line)
|
||||||
eidDesc = eidDesc .. parseEffectLine(line)
|
eidDesc = eidDesc .. parseEffectLine(line)
|
||||||
-- also display the unparsed line for debug purposes (REMOVE THIS)
|
-- also display the unparsed line for debug purposes (REMOVE THIS)
|
||||||
eidDesc = eidDesc .. "(" .. line .. ")#"
|
--eidDesc = eidDesc .. "(" .. line .. ")#"
|
||||||
if numEffects == 0 then
|
if numEffects == 0 then
|
||||||
|
-- Glowing Hour Glass type effects will cause the game to reload all items, check if our desc is equal to the first one
|
||||||
|
if (EID:getDescriptionObj(5, 100, maxNumber - 1).Description == eidDesc) then spawnedItems = 1 end
|
||||||
EID:addCollectible(maxNumber - spawnedItems, eidDesc)
|
EID:addCollectible(maxNumber - spawnedItems, eidDesc)
|
||||||
|
print("adding " .. (maxNumber - spawnedItems))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- there are some lines that have a gigantic amount of white space and I don't know why, don't write those I guess...
|
|
||||||
if (#line < 200) then secondaryLog:write("LINE: " .. #line .. ": " .. line .. "\n") end
|
line = theLog:read()
|
||||||
end
|
end
|
||||||
secondaryLog:flush()
|
|
||||||
-- wipe the log file
|
logCursor = theLog:seek()
|
||||||
io.open(logLocation, "w+")
|
theLog:close()
|
||||||
end
|
end
|
||||||
EID:AddCallback(ModCallbacks.MC_POST_UPDATE, CheckLogForItems)
|
EID:AddCallback(ModCallbacks.MC_POST_UPDATE, CheckLogForItems)
|
||||||
|
|
||||||
|
-- figure out where to resume loading item descriptions when continuing a file
|
||||||
|
-- unfortunately, I'm not bothering to save descriptions if you close the game
|
||||||
|
local function GameStartTMTRAINER(_,isSave)
|
||||||
|
local theLog = io.open(logLocation, "r")
|
||||||
|
if (theLog == nil) then
|
||||||
|
print("[EID] Could not find the log file at " .. logLocation .. "; glitched item descriptions won't work!")
|
||||||
|
logFound = false
|
||||||
|
return
|
||||||
|
else
|
||||||
|
logFound = true
|
||||||
|
end
|
||||||
|
spawnedItems = 0
|
||||||
|
--[[if isSave then
|
||||||
|
-- check what item ID we're on
|
||||||
|
local config = Isaac.GetItemConfig()
|
||||||
|
while config:GetCollectible(maxNumber - spawnedItems - 1) ~= nil do
|
||||||
|
spawnedItems = spawnedItems + 1
|
||||||
|
end
|
||||||
|
-- if we exit and reload in a room with a new pedestal to spawn, that item's info is grabbable but spawnedItems would be too high
|
||||||
|
spawnedItems = spawnedItems - CountLogItems()
|
||||||
|
|
||||||
|
print("resuming at " .. (maxNumber - spawnedItems - 1))
|
||||||
|
end]]
|
||||||
|
end
|
||||||
|
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, GameStartTMTRAINER)
|
||||||
Reference in new issue
Block a user