Oni Central Forum

A forum for the Oni community

You are not logged in.

#1 04/01/12 10:04

paradox-01
Member
From: Germany
Registered: 01/14/07

BSL riddle: count function stops working after 4 cycles

I'm currently trying to get a simple counting function.
First example: it uses a lot of dmsg to see where the count stop. It never pass the 4th cycle.

var int numberZ = 0;

func count10
{
	numberZ = numberZ + 1;
	sleep 30

	if (numberZ eq 1)
	{
		dmsg "1"
		count10
	}
	if (numberZ eq 2)
	{
		dmsg "2"
		count10
	}
	if (numberZ eq 3)
	{
		dmsg "3"
		count10
	}
	if (numberZ eq 4)
	{
		dmsg "4"
		count10
	}
	if (numberZ eq 5)
	{
		dmsg "5"
		count10
	}
	if (numberZ eq 6)
	{
		dmsg "6"
		count10
	}
	if (numberZ eq 7)
	{
		dmsg "7"
		count10
	}
	if (numberZ eq 8)
	{
		dmsg "8"
		count10
	}
	if (numberZ eq 9)
	{
		dmsg "9"
		count10
	}
	if (numberZ eq 10)
	{
		dmsg "stop"
	}
}

Another variant. This will also only work with 4 cycles.

var int numberX = 0;

func count5
{
	numberX = numberX + 1;

	if (numberX eq 5)
	{
		dmsg "5"
	}

	count5
}

Any ideas what could be wrong?

Offline

#2 04/01/12 10:04

Lukas Kreator
Member
Registered: 05/07/10

Re: BSL riddle: count function stops working after 4 cycles

You could try using "fork count5" instead of just "count5". Also, I do not advise you to use the first example. When you call the "count10" method inside the 'if', it will be called, and then the code will continue from there and there could be a lot of messages about the same numbers.

EDIT: Actually, your second example works for me. You should call it from "main" using "fork count5", not just "count5".

Last edited by Lukas Kreator (04/01/12 10:04)

Offline

#3 04/01/12 11:04

paradox-01
Member
From: Germany
Registered: 01/14/07

Re: BSL riddle: count function stops working after 4 cycles

Thanks Lukas, it works now with fork. big_smile
The stange thing is that in addition the function must be called from bsl file, the console won't do it.

Offline

#4 04/01/12 12:04

berry
Member
From: Singapore
Registered: 03/15/12

Re: BSL riddle: count function stops working after 4 cycles

Wow looks so complicated hmm


Hmm...

Offline

#5 04/01/12 13:04

paradox-01
Member
From: Germany
Registered: 01/14/07

Re: BSL riddle: count function stops working after 4 cycles

Oni's soundtracks are cut into several pieces and have also an intro and outro part.
If you use the sound_music_stop command on them they will pretty much fade out because the outro part which can be played from any main piece.

Soundtracks that aren't subundivided can only be interrupted or to be made decay within (max.) one sec.
I wanted a function that can decay undivided soundtracks over a bit longer time. That's the story of this counter.

Btw, now there's also an excel macro for undivided soundtracks. Don't worry, I will not spam you with more of those. wink

Offline

#6 04/02/12 14:04

Loser
Member
From: somewhere in da Czech Republic
Registered: 01/14/07

Re: BSL riddle: count function stops working after 4 cycles

Hi paradox-01,
what you described is yet another funny thing in Oni BSL. You can call a function recursively, but only up to about four times, then the script execution stucks for some reason (maybe intentional to prevent endless loops?).

Use "fork" in conjunction with "sleep" to ensure that there is always only one running copy of the function. And remember to design the code so it cannot create two copies of the function running in parallel. When that happens, the desired loop effect is usually broken and "echos" start to apprear.


"I am just a mere reflection of what I would be."

Offline

#7 04/03/12 14:04

paradox-01
Member
From: Germany
Registered: 01/14/07

Re: BSL riddle: count function stops working after 4 cycles

Thanks for the help, guys. I will try to keep your tips in mind. smile

Offline

Board footer

Powered by FluxBB