5 posts
Posted 14 April 2012 - 09:34 AM
Hello
I am currently trying to make a system that toggles my lights. It has 3 settings, off, on and time-based. To do this, I use this setup:
function update()
pullevent and so...
update()
end
function step()
some other things
end
lanes.gen(update()) <--- error
while true do
step()
end
This gives me attempt to index ? ( a nil value)
why?
236 posts
Location
Germany
Posted 14 April 2012 - 10:29 AM
Hello
I am currently trying to make a system that toggles my lights. It has 3 settings, off, on and time-based. To do this, I use this setup:
function update()
os.pullevent
update()
end
function step()
end
lanes.gen(update()) <--- error
while true do
step()
end
This gives me attempt to index ? ( a nil value)
why?
u have to call os.pullEvent()
and declare it like this
arg, q1, q2, q3, q4, q5 = os.pullEvent()
and dunno waht lanes.gen is
5 posts
Posted 14 April 2012 - 10:41 AM
That os.pullEvent works, just to indicate it's there. It's a shame you can't copy your code form pc's ingame…
1111 posts
Location
Portland OR
Posted 14 April 2012 - 10:43 AM
What are you trying to do with the statement "lanes.gen(update())"
And the os.pullEvent should have ()'s at the end.
5 posts
Posted 14 April 2012 - 10:46 AM
That lanes.gen(update()) should create a thread that runs seperate from the while loop. That pullevent is just to indicate there is an os.pullEvent() with all coding around it in there that pauses the function update.
1111 posts
Location
Portland OR
Posted 14 April 2012 - 10:51 AM
ya in lua you will need the ()'s for it to work properly
There in no multi-threading in CC/Lua. You can try to run coroutines or use the parallel api to make the illusion of the system multitasking.
Coroutine help is
hereThere is more help further down the page.
And as for parallel, type help parallel from the terminal
5 posts
Posted 14 April 2012 - 10:54 AM
Okay, then I'll try to solve this with 2 computers.
2447 posts
Posted 14 April 2012 - 03:27 PM
That isn't necessary - the parallel API can help you there. While Lua doesn't have "true" multithreading, it does have a form of it. Dan has helpfully made this easier for most users, so just type "help parallel" to find out more information.
To help you out so you can paste it all, you can get your code from the computer easily. Go to "%appdata%.minecraftsavessavenamecomputercomputerid" and you will find all your files in there to be edited by notepad, or another text editor of your choice.