Skip to content

Commit

Permalink
Attempt file io in lua (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 20, 2024
1 parent 13bfbef commit fb26ab9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/src/lib/utils.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local function get_data_file(name, mode)
local file = io.open("../_data/" .. name, mode)
local filename = "../_data/" .. name
local file = io.open(filename, mode)

if not file then
print("Could not open file: " .. filename)
Expand All @@ -25,9 +26,9 @@ local function get_answer(id)

if type_ == 'str' then
return value
else if type_ == 'int' then
elseif type_ == 'int' then
return tonumber(value)
else if type_ == 'uint' then
elseif type_ == 'uint' then
if length < 64 then
return tonumber(value)
end
Expand All @@ -39,6 +40,7 @@ local function get_answer(id)
end
end
end
return nil, "Answer not found"
end

return {
Expand Down

0 comments on commit fb26ab9

Please sign in to comment.