Am i able to..

You may request or share scripts for MicroMacro in this forum.
Post Reply
Message
Author
User avatar
droppen
Posts: 179
Joined: Mon Aug 03, 2009 10:32 pm

Am i able to..

#1 Post by droppen » Sun Nov 15, 2009 3:00 am

i want to run 2 instances of a script inside one lua file kind of like javascript does. Is this possible?

Code: Select all

 
function main()
	printf("\n\nInitializing..");

	function test()
	    while( not keyPressed(key.VK_F5) ) do

	        print("test1");
		rest(50);
	    end
 	end
	registerTimer("test", secondsToTimer(2), test);

	-- Main loop
	while( not keyPressed(key.VK_F5) ) do

	        print("test2");
		rest(50);
	end

end

main();
I would like to have to output look like this:

Code: Select all

Initializing..
test1
test2
test1
test2
test1
test2
test1
test2
test1
test2
BTW, I haven't been able to see any documentation of starMacro or registerTimer functions

Edit: maybe this belongs to the help & support section

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Am i able to..

#2 Post by Administrator » Sun Nov 15, 2009 6:45 am

You should look at using coroutines to run two "threads" at the same time.

startMacro() and registerTimer() will be listed under library functions in the manual.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests