DECORATE RepeatFunction

Moderator: GZDoom Developers

Post Reply
User avatar
Major Cooke
Posts: 8214
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

DECORATE RepeatFunction

Post by Major Cooke »

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?
Monsterovich
Posts: 59
Joined: Sat Apr 12, 2014 11:10 am

Re: DECORATE RepeatFunction

Post by Monsterovich »

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(...);
    }
}
Last edited by Monsterovich on Sun Jul 24, 2016 9:54 am, edited 3 times in total.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: DECORATE RepeatFunction

Post by NeuralStunner »

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.
User avatar
Major Cooke
Posts: 8214
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: DECORATE RepeatFunction

Post by Major Cooke »

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.
Last edited by Major Cooke on Sun Jul 24, 2016 10:32 am, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: DECORATE RepeatFunction

Post by Graf Zahl »

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'.
User avatar
Major Cooke
Posts: 8214
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: DECORATE RepeatFunction

Post by Major Cooke »

Thought so.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: DECORATE RepeatFunction

Post by NeuralStunner »

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.
User avatar
Major Cooke
Posts: 8214
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: DECORATE RepeatFunction

Post by Major Cooke »

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.
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: DECORATE RepeatFunction

Post by Leonard2 »

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?
User avatar
Major Cooke
Posts: 8214
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: DECORATE RepeatFunction

Post by Major Cooke »

You might have to wait on randi to approve it, but otherwise there's no harm in trying! :D
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: DECORATE RepeatFunction

Post by Graf Zahl »

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.
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: DECORATE RepeatFunction

Post by Nash »

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

Return to “Closed Feature Suggestions [GZDoom]”