function Cloaks:Init()
if (file_exists)(Cloaks.DB) == false) then
print('Creating Admiral Cloak Database')
table.save({},Cloaks.DB, FILE_WRITE)
end
end
The error is in your if, assuming everything else is fine, it should be like this
function Cloaks:Init()
if ((file_exists)(Cloaks.DB)) == false) then
print('Creating Admiral Cloak Database')
table.save({},Cloaks.DB, FILE_WRITE)
end
end
you were missing parentheses
according to link the if statement does not need parentheses:
if a<0 then a = 0 end
your code would be like this:
function Cloaks:Init()
if (file_exists)(Cloaks.DB) == false then
print('Creating Admiral Cloak Database')
table.save({},Cloaks.DB, FILE_WRITE)
end
end
trying to understand a bit the conditional logic if
in your post, it should be clarified that if you do in Lua the following:
print((true)(true)) -- asumo que deseas hacer una especie de multiplicación en lugar del operador lógico and
You will get an error, I think the solution could go like this:
local file_exists = "existeArchivo"
local Cloaks = {}
-- Cloaks.DB -- no definido o nil
Cloaks.Init = function()
if not (file_exists and Cloaks.DB) then print("¡listo!") end
end
Cloaks.Init() -- se imprime: ¡listo!
Note that Lua considers a null or false variable to be false, this can be confusing because it could even be believed in the first instance that an empty table is null which is not true for Lua
if {} then print("verdad") end -- se imprime: verdad
if you put it that way?
if((file_exists(Cloaks.DB)) == false) then