While Loop within Background

43 views
Skip to first unread message

Levi Trammell

unread,
Apr 11, 2012, 9:55:20 PM4/11/12
to iPhone Wax
I'm trying to call a function I call "script" within a Lua script.
This code is started in the init: function of a class, named "Event",
that I've made. I create an NSMutableArray that contains multiple
Events. It does work when only one of the Events has any functions
within it's script function. I have a feeling that all of the Event's
scripts are all within the same thread accessing each others memory.

Here's a portion of my Event class

@implementation Event
-(id)init:(char*)script
{
......
wax_start(script, nil);
Class _eP = NSClassFromString(@"Test");
[_eP performSelectorInBackground:@selector(script:)
withObject:self];
}

Here's one of my Lua scripts

waxClass{"Test"}

function script(self,object)
while true do
object:step_withDirection(5,2)
object:step_withDirection(5,1)
end
end

Levi Trammell

unread,
Apr 11, 2012, 11:16:41 PM4/11/12
to iPhone Wax
My question is : Why is it that if I have multiple script functions
running, it always gives me this error?

*** Assertion failure in -[CCActionManager addAction:target:paused:], /
CCActionManager.m:187
Lua panicked and quit: Error calling 'script:' on 'Test'
scripts/Test.lua:5: Error calling 'script:' on 'Test2'
scripts/Test2.lua:5: Error invoking method 'step:withDirection:' on
'Event' because runAction: Action already running
stack traceback:
[C]: ?
[C]: in function 'step_withDirection'
scripts/Test2.lua:5: in function <scripts/Test2.lua:3>
[C]: in function 'step_withDirection'
scripts/Test.lua:5: in function <scripts/Test.lua:3>
stack traceback:
[C]: ?
[C]: in function 'step_withDirection'
scripts/Test.lua:5: in function <scripts/Test.lua:3>
Reply all
Reply to author
Forward
0 new messages