Possible bug in createThread in lib.lua?

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Possible bug in createThread in lib.lua?

#1 Post by dx876234 » Tue Apr 16, 2013 8:08 am

When wrapping the thread function in createThread it seems to me the possible arguments are lost and not transfered to the thread function, I suspect the:

Code: Select all

	local wrapped = function (...) coroutine.yield(); func(); end;

	local co = coroutine.create(wrapped);

	local status, err = coroutine.resume(co, ...);
In reality should be as follows to pass arguments to the given function?

Code: Select all

	local wrapped = function (...) coroutine.yield(); func(...); end;  -- NOTE: "..." in func argument

	local co = coroutine.create(wrapped);

	local status, err = coroutine.resume(co, ...);
-dx

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

Re: Possible bug in createThread in lib.lua?

#2 Post by Administrator » Tue Apr 16, 2013 1:45 pm

I think you're right. I guess something must have changed somewhere with the update to Lua 5.2 as it used to work.

Thanks for letting me know.

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Possible bug in createThread in lib.lua?

#3 Post by dx876234 » Thu Jun 27, 2013 3:41 am

Upgraded to 1.03, seems this bug is present there, must have leaked between releases :)

best regards
DX

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

Re: Possible bug in createThread in lib.lua?

#4 Post by Administrator » Mon Jul 01, 2013 11:53 am

Are you sure you updated lib.lua? Seems to work for me.

Code: Select all

local function thread(num)
  for i = 1,10 do
    print("Test: ", num);
    coroutine.yield();
  end
end
 
createThread("test2", thread, 1234);
-- Creates a thread that will continually print out "Test: 1234" 10 times then kill itself.

function main()
	while(true) do
		yrest(1);
	end
end
startMacro(main, true);
Edit: This hasn't actually been officially released. It's in the changelog for 1.04, which has a number of improvements but is still far off from a release.

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests