Skip to content

Instantly share code, notes, and snippets.

@Alloyed
Created January 4, 2017 16:41
Show Gist options
  • Save Alloyed/51d4bc67b44e91d04ced4d07fea93f36 to your computer and use it in GitHub Desktop.
Save Alloyed/51d4bc67b44e91d04ced4d07fea93f36 to your computer and use it in GitHub Desktop.
--- A log function that's compatible with lua's standard print function.
-- usage: print("hi", table, entity, 3.4) -- output: hi <table:0xdeadbeef> <userdata:0xeeeeeeee> 3.4
local function print(...)
local str, sep = "", ""
for i=1, select('#', ...) do
str = str .. sep .. tostring(select(i, ...))
sep = '\t'
end
return Isaac.DebugString(str)
end
-- An onscreen logger, from epicbob57#8905 on #themoddingofisaac discord
local eLog = {"Log:"}
function mod:eLogDraw()
for i,j in ipairs(eLog) do
Isaac.RenderText(j,50,i*15,255,255,255,255)
end
end
mod:AddCallback(ModCallbacks.MC_POST_RENDER, mod.eLogDraw);
local function eLogWrite(str)
table.insert(eLog,str)
if #eLog > 10 then
table.remove(eLog,1)
end
end
-- more to come? ping me here or on reddit
@ikskuh
Copy link

ikskuh commented Jan 10, 2017

I would use table.pack(...) instead of select for iterating the argument list, but i actually don't know if it's better or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment