DECORATE RepeatFunction

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: DECORATE RepeatFunction

Re: DECORATE RepeatFunction

by Nash » Sun Jul 24, 2016 10:30 pm

I've asked about it before. Please make it happen, Leonard! =D

Re: DECORATE RepeatFunction

by Graf Zahl » Sun Jul 24, 2016 4:41 pm

Leonard2 wrote:
Graf Zahl wrote:Maybe Randi can be convinced to add simple 'for' loops to DECORATE
Would a submission that implements for/while loops in decorate be accepted?
If done properly, yes. In that case I wouldn't wait for approval.

Re: DECORATE RepeatFunction

by Major Cooke » Sun Jul 24, 2016 4:27 pm

You might have to wait on randi to approve it, but otherwise there's no harm in trying! :D

Re: DECORATE RepeatFunction

by Leonard2 » Sun Jul 24, 2016 4:13 pm

Graf Zahl wrote:Maybe Randi can be convinced to add simple 'for' loops to DECORATE
Would a submission that implements for/while loops in decorate be accepted?

Re: DECORATE RepeatFunction

by Major Cooke » Sun Jul 24, 2016 1:28 pm

No, really, you did misunderstand what I was going for. I didn't want MULTIPLE functions, I wanted it for one SINGLE function.

But at any case, no point continuing this argument.

Re: DECORATE RepeatFunction

by NeuralStunner » Sun Jul 24, 2016 12:48 pm

Major Cooke wrote:You're all missing the point.
Except I actually didn't:
I wrote:It seems like what you'd really want is a for loop.
Nor did Monsterovich, for that matter:
Monsterovich wrote:Better do:
[Alternative syntax]
You need to read things a little closer before you dismiss them.

Re: DECORATE RepeatFunction

by Major Cooke » Sun Jul 24, 2016 10:32 am

Thought so.

Re: DECORATE RepeatFunction

by Graf Zahl » Sun Jul 24, 2016 10:31 am

Sorry, but this would turn the entire thing into a mess. Maybe Randi can be convinced to add simple 'for' loops to DECORATE but this suggestion as-is is a 'no'.

Re: DECORATE RepeatFunction

by Major Cooke » Sun Jul 24, 2016 10:25 am

You're all missing the point. The point is to avoid frame repetition.

Code: Select all

const int RepeatTimes = 11;
//...

States
{
Spawn:
	TNT1 A 0
	{
		if (user_z)
		{
			RepeatFunction(RepeatTimes,A_SpawnItemEx(...));
		}
		else
		{
			A_SetTics(1);
		}
	}
The intention is to avoid jumping and repeating the same frame over and over with TNT1 AAAAA 0. Rather just repeat the function call and keep it all compact.
The fewer frames processed, the better. Especially if a function needs calling several hundred times. Keeping track of several hundred frames especially can become daunting after a while.
And if I were to hazard a guess, my way should be easier to handle than a repeat of a frame state over and over again... but I'm not randi and so I'm only guessing.

Re: DECORATE RepeatFunction

by NeuralStunner » Sun Jul 24, 2016 9:44 am

There are still situations where frame-stacking is not a bad idea:

Code: Select all

TNT1 AAAAAAAAAAA 0 // 11 'A's. AAA indeed.
{
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
}
It seems like what you'd really want is a for loop... Which sounds super-WFDS.

Re: DECORATE RepeatFunction

by Monsterovich » Sun Jul 24, 2016 9:39 am

Better do:

Code: Select all

Repeat TNT1 A 10 // 10 times
{
A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
A_Something(...);
}
and

Code: Select all

Repeat TNT1 A 10 A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128)
or

Code: Select all

Repeat 10
{
    TNT1 A 0
    {
         A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
         A_Something(...);
    }
}

DECORATE RepeatFunction

by Major Cooke » Sun Jul 24, 2016 8:29 am

This most likely isn't doable, but oh well. Thought I'd ask anyway.

(A_)RepeatFunction(numberoftimes, function)

Basically, it's meant to replace:

Code: Select all

TNT1 A 0
{
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128);
	//...
}
with this:

Code: Select all

TNT1 A 0
{
	RepeatFunction(11,A_SpawnItemEx("BFGImpactVapor",3,0,0,frandom(-4,4),frandom(-4,4),frandom(-4,4),0,SXF_NOCHECKPOSITION,128));
}

Calls that same A_SpawnItemEx 11 times.

I can understand if this isn't doable considering decorate functions most likely don't have the power to call other decorate action functions... buuuut, if randi could get them to work inside of if statements, maybe this can work too, somewhere along the lines?

Top