Page 1 of 1

No libraries are working for me :/

Posted: Wed Aug 24, 2022 3:17 pm
by komega
So I've been trying to create a screen that switches between multiple different images, almost identically to the home screen of Five Nights at Freddy's 1. My issue has been timers and delays, trying to get functions to execute after a set amount of time. I've seen a lot of people suggest using the Cron or Tick libraries, but when I set them up and try to run the program, I get this error every time;

Error

main.lua:5: attempt to index local 'cron' (a boolean value)


Traceback

[love "callbacks.lua"]:228: in function 'handler'
main.lua:5: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

this is the line it is referencing;
cron.update(dt)

i believe i've set everything up correctly, i have the cron.lua file in my main game folder, and the first line in my main.lua file is;
local cron = require 'cron'

i've tried getting rid of the "local" part, no difference is made. i hope i'm just being dumb, could someone please help me out? i've been going crazy over the course of the last hour trying to solve this.

Re: No libraries are working for me :/

Posted: Wed Aug 24, 2022 3:34 pm
by ReFreezed
Does cron.lua return a table? When you require() a module and the module file doesn't return anything then the default value returned from require() is 'true'. Maybe Cron adds globals that you're expected to use instead of the returned value from require().

Re: No libraries are working for me :/

Posted: Wed Aug 24, 2022 3:47 pm
by komega
ReFreezed wrote: Wed Aug 24, 2022 3:34 pm Does cron.lua return a table? When you require() a module and the module file doesn't return anything then the default value returned from require() is 'true'. Maybe Cron adds globals that you're expected to use instead of the returned value from require().
attached are the cron installation instructions, which i think i followed, but maybe i misunderstood something in them. this is all that's listed for installing/making cron work.

Re: No libraries are working for me :/

Posted: Wed Aug 24, 2022 8:07 pm
by 1414codeforge
Could you attach the main.lua, so we can check the code out in its entirety?

Also, you mean this cron.lua library?
https://github.com/kikito/cron.lua

Re: No libraries are working for me :/

Posted: Wed Aug 24, 2022 8:52 pm
by ReFreezed
There must be a name collision. Don't use the 'cron' variable for the created timer objects. Look at the examples again.