[User error] Programmatically Spawning Moving Things

Moderator: GZDoom Developers

Programmatically Spawning Moving Things

Postby SPZ1 » Mon May 09, 2022 3:41 pm

I just found out that this code to move some things does not work:

Code: Select allExpand view
script 10 (void){
   Thing_SpawnFacing(9, 230, TRUE, 50);
   Thing_SpawnFacing(10, 231, TRUE, 51);
   Thing_SpawnFacing(11, 232, TRUE, 52);
   Thing_SpawnFacing(12, 233, TRUE, 53);
   Thing_SpawnFacing(13, 234, TRUE, 54);
   Thing_SpawnFacing(14, 235, TRUE, 55);
   Thing_SpawnFacing(15, 236, TRUE, 56);
   Thing_SpawnFacing(16, 237, TRUE, 57);

   Thing_SpawnNoFog(17, 9074, 0, 58);
   SetThingSpecial(58, 0, 1, 0, 3, 50);
   Thing_SpawnNoFog(18, 9074, 0, 59);
   SetThingSpecial(59, 0, 2, 0, 3, 51);
   Thing_SpawnNoFog(19, 9074, 0, 60);
   SetThingSpecial(60, 0, 3, 0, 3, 52);
   Thing_SpawnNoFog(20, 9074, 0, 61);
   SetThingSpecial(61, 0, 4, 0, 3, 53);
   Thing_SpawnNoFog(21, 9074, 0, 62);
   SetThingSpecial(62, 0, 5, 0, 3, 54);
   Thing_SpawnNoFog(22, 9074, 0, 63);
   SetThingSpecial(63, 0, 6, 0, 3, 55);
   Thing_SpawnNoFog(23, 9074, 0, 64);
   SetThingSpecial(64, 0, 7, 0, 3, 56);
   Thing_SpawnNoFog(24, 9074, 0, 65);
   SetThingSpecial(65, 0, 8, 0, 3, 57);

   Thing_Activate(58);
   Thing_Activate(59);
   Thing_Activate(60);
   Thing_Activate(61);
   Thing_Activate(62);
   Thing_Activate(63);
   Thing_Activate(64);
   Thing_Activate(65);
}
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

Re: Programmatically Spawning Moving Things

Postby Graf Zahl » Mon May 09, 2022 3:59 pm

In what way does thus not work? What are you trying to do here?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Programmatically Spawning Moving Things

Postby SPZ1 » Mon May 09, 2022 5:07 pm

I'm trying to code a shooting gallery where the targets move around in a circle. I made this .WAD quickly to demonstrate. Just use "Puke 10" in the console.
You do not have the required permissions to view the files attached to this post.
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

Re: Programmatically Spawning Moving Things

Postby Graf Zahl » Tue May 10, 2022 12:31 am

Let me get this straight: You are trying to spawn some ActorMovers by calling Thing_SpawnNoFog with an EDITOR NUMBER as second parameter?
Well, that cannot work - you need to pass a spawn ID.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Programmatically Spawning Moving Things

Postby SPZ1 » Tue May 10, 2022 7:36 am

Sorry about that...
:bang: :bang: :bang:
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

Re: Programmatically Spawning Moving Things

Postby Enjay » Tue May 10, 2022 8:54 am

Graf is, of course, correct. However, for your case, might you be able to use one of the spawn functions ( Spawn, SpawnSpot, SpawnSpotFacing, SpawnForced, SpawnSpotForced, SpawnSpotFacingForced or maybe even SpawnProjectile )?

It's likely that one of them will suit your needs and they don't even need a spawn id (which I'm not even sure that ActorMover class had by default). You simply pass the class name as a string to the spawn function.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Programmatically Spawning Moving Things

Postby SPZ1 » Tue May 10, 2022 9:15 am

I got the code to work but I noticed something strange. If I "puke 10" this code without the Delay(1); then I have to "puke 10" twice instead of once and I don't know why.


Code: Select allExpand view
script 10 (void){
   Thing_SpawnFacing(9, 230, TRUE, 50);
   Thing_SpawnFacing(10, 231, TRUE, 51);
   Thing_SpawnFacing(11, 232, TRUE, 52);
   Thing_SpawnFacing(12, 233, TRUE, 53);
   Thing_SpawnFacing(13, 234, TRUE, 54);
   Thing_SpawnFacing(14, 235, TRUE, 55);
   Thing_SpawnFacing(15, 236, TRUE, 56);
   Thing_SpawnFacing(16, 237, TRUE, 57);

   //Delay(1);

   Thing_SpawnNoFog(17, 238, 0, 58);
   SetThingSpecial(58, 0, 1, 0, 3, 50);
   Thing_SpawnNoFog(18, 238, 0, 59);
   SetThingSpecial(59, 0, 2, 0, 3, 51);
   Thing_SpawnNoFog(19, 238, 0, 60);
   SetThingSpecial(60, 0, 3, 0, 3, 52);
   Thing_SpawnNoFog(20, 238, 0, 61);
   SetThingSpecial(61, 0, 4, 0, 3, 53);
   Thing_SpawnNoFog(21, 238, 0, 62);
   SetThingSpecial(62, 0, 5, 0, 3, 54);
   Thing_SpawnNoFog(22, 238, 0, 63);
   SetThingSpecial(63, 0, 6, 0, 3, 55);
   Thing_SpawnNoFog(23, 238, 0, 64);
   SetThingSpecial(64, 0, 7, 0, 3, 56);
   Thing_SpawnNoFog(24, 238, 0, 65);
   SetThingSpecial(65, 0, 8, 0, 3, 57);

   //Delay(1);

   Thing_Activate(58);
   Thing_Activate(59);
   Thing_Activate(60);
   Thing_Activate(61);
   Thing_Activate(62);
   Thing_Activate(63);
   Thing_Activate(64);
   Thing_Activate(65);
}


Also:

Code: Select allExpand view
ACTOR NewActorMover : ActorMover { SpawnID 238 }
User avatar
SPZ1
 
Joined: 02 Aug 2017
Location: Illinois

Re: Programmatically Spawning Moving Things

Postby Graf Zahl » Tue May 10, 2022 11:30 am

You need the delay so that the ActorMover setup is only done when the stuff you spawned first with Thing_SpawnFacing has been fully initialized.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest