Hey!
Im a beginner at Livecode and my englisch is very bad so please dont judge me.
I have a big Problem: Ich just want to start two methods at the same time by clicking one Button. The Problem is that when i click the Button the first method starts, but the second doesn't start.
The code just looks like that:
on Mouseup
starter1
starter2
end Mouseup
start1 and start2 are the two Methods.
I hope someone knows a good way to fix my little Problem with Livecode.
Thanks Kiliaan
on beginn
go to card "game"
put 1 into stacky
put 0 into frager
put 4000 into timer
put 4500 into timer2.1
put 0 into score
put score into fld "lab"
wait 3 seconds
starter1
starter2
end beginn
###########################################################################################################
on starter1
put timer-100 into timer
put random(timer) into timer2
if timer2<300 then
put 300 into timer2
end if
wait timer2 milliseconds with messages
set backgroundcolor of grc "g1" to "green"
start1.1
end starter1
on start1.1
if stacky = 1 then
repeat with t = 1 to 11
if clicker1=1 then
put 0 into clicker1
set backgroundcolor of grc "g1" to "black"
put 0 into counter
add 1 to score
put score into fld "lab"
starter1
exit start1.1
else
add 1 to counter2
if counter2 = 10 then
put 0 into counter2
put 0 into score
put score into fld "lab"
set backgroundcolor of grc "g1" to "red"
wait 2 seconds
set backgroundcolor of grc "g1" to "black"
put 0 into stacky
go to card "menü"
exit start1.1
end if
end if
wait 120 milliseconds with messages
end repeat
end if
end start1.1
##########################################################################################################
on starter2
put timer2.1-100 into timer2.1
put random(timer) into timer2.2
if timer2.2<300 then
put 300 into timer2.2
end if
wait timer2.2 milliseconds with messages
set backgroundcolor of grc "g2" to "green"
start2.2
end starter2
on start2.2
if stacky = 1 then
repeat with t = 1 to 11
if clicker2=1 then
put 0 into clicker2
set backgroundcolor of grc "g2" to "black"
put 0 into counter
add 1 to score
put score into fld "lab"
starter2
exit start2.2
else
add 1 to counter
if counter = 10 then
put 0 into counter
put 0 into score
put score into fld "lab"
set backgroundcolor of grc "g2" to "red"
wait 2 seconds
set backgroundcolor of grc "g2" to "black"
put 0 into stacky
go to card "menü"
exit start2.2
end if
end if
wait 120 milliseconds with messages
end repeat
end if
end start2.2
Last edited by Kiliaan on Sun Jul 16, 2017 3:23 pm, edited 2 times in total.
Hi Kiliaan,
Welcome
I think you can not start two task exactly in the same time.
I believe there is a before and an after in LiveCode.
I'm surprised that your start2 message is not sent and you haven't got an error message
if there is not a start2 message.
Create one btn and one fld in a empty cd
put this script into your btn
on Mouseup
starter1
starter2
end Mouseup
on starter1
put "starter1" && the milliseconds into line 1 of fld 1
end starter1
on starter2
put "starter2" && the milliseconds into line 2 of fld 1
end starter2
Hey Thanks for your fast reply!
But unfortunately this doesnt work for my projekt, in which this problem occured.
I edited my first Question, I hope this helps to understand where my problem is.
Hope you can help me solving this problem.
Hi
I see "start1.1" in your script
The correct syntax should be "start1 1"
Message and space and params separate by comma. MyMessage param1,param2 etc...
you have to declare variable on top on script like that. If not, all variables aren't empty after "end beginn"
local stacky, frager, timer, timer2.1, score
on beginn
-- ...
put 1 into stacky
put 0 into frager
put 4000 into timer
put 4500 into timer2.1
put 0 into score
-- ...
end beginn
I left some Parts from my code out, to show you my Problem a bit better...
I decleared all Vars correctly, and changed the Syntax like you showed me....
But anyways, the same Problem
But Thanks for helping me trying to fix my Problem, i appreciate this alot
Like Python and some others, LiveCode is a single-threaded engine, so true parallelism is out. But unlike Python, LC has no explicit means of interleaving execution, so even concurrency is not LC's strong suit.
If this were a desktop app you could have both concurrency and parallelism using multiprocessing as opposed to multithreading. With the ability to spawn faceless processes easily, multiprocessing can be done very effectively in LC. I haven't tried multiprocessing on Android, howerver, so I have no sense of how useful it'll be for your app (and given RAM constraints on mobile devices may not be worth the effort).
If you provide more info on the specific task you're looking to achieve we may be able to provide more specific guidance.
Richard Gaskin LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
FourthWorld wrote:Like Python and some others, LiveCode is a single-threaded engine, so true parallelism is out. But unlike Python, LC has no explicit means of interleaving execution, so even concurrency is not LC's strong suit.
If this were a desktop app you could have both concurrency and parallelism using multiprocessing as opposed to multithreading. With the ability to spawn faceless processes easily, multiprocessing can be done very effectively in LC. I haven't tried multiprocessing on Android, howerver, so I have no sense of how useful it'll be for your app (and given RAM constraints on mobile devices may not be worth the effort).
If you provide more info on the specific task you're looking to achieve we may be able to provide more specific guidance.