Page 1 of 1

Troublesome luacontroller loop

PostPosted: Sun Nov 24, 2013 23:12
by Quackor
I'm trying to have one of my outputs send a signal for half a second every 5 seconds or so... this code runs but slowly gets crazier and crazier (as in the port outputs more often, until it overheats... am I missing something fundamental here?)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
interrupt(0.5, "loop")

if mem.count == nil then
  mem.count = 0
end

if event.iid == "loop" then
  mem.count = mem.count + 1
  if mem.count == 10 then
    port.c = true
    mem.count = 0
  else
    port.c = false
  end
end


Any help figuring this one out greatly appreciated!

PostPosted: Sun Nov 24, 2013 23:20
by PilzAdam
I guess this would fit better into the mesecons topic.

PostPosted: Sun Nov 24, 2013 23:24
by Quackor
PilzAdam wrote:I guess this would fit better into the mesecons topic.


Directing all mod-related questions into a single topic seems messy... maybe it would be useful to have a forum section dedicated to mod functionality? not sure :/ I'll respost this in the messecons topic just in case.