(SOLVED) LineSide condition won't break out of loop?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
R4L
Global Moderator
Posts: 426
Joined: Fri Mar 03, 2017 9:53 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Pro
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

(SOLVED) LineSide condition won't break out of loop?

Post by R4L »

Posted this in Discord, but maybe this is a better place for it.

In Dreadnought, I'm making a morph ball tunnel that changes the player camera to an aiming camera when the player enters the tunnel. This works fine and activates the script every time. The problem is, the camera also pans its height to match the player's height in the tunnel, and adding a LINE_BACK condition in a loop isn't breaking out:

Code: Select all

script "Camera_On" (void)
{

int playerz; //store player's z value for the camera

//When LineSide() == LINE_BACK this will break (or not)
	while ((LineSide() == LINE_FRONT) == TRUE)
	{

	TakeInventory("PlayerMorphCamera", 0X7FFFFFF);
	Thing_Activate(14);
	ChangeCamera(14,TRUE,FALSE);

	playerz = GetActorZ(PlayerNumber());
	Log(f:playerz);

	SetActorPosition(14,GetActorX(14),GetActorY(14),playerz,FALSE);
	Delay(1);
	}

	//Reset camera
	GiveInventory("PlayerMorphCamera", 1);
	Thing_Deactivate(14);
	ChangeCamera(0,TRUE,FALSE);
	ACS_ExecuteAlways(587,0,90,4);
}
Here's a video to demonstrate what I'm actually doing if its not immediately clear: https://streamable.com/suv5f

Also, my activation lines are all set to be doublesided, activated when player walks over, and repeatable. I feel like I'm just missing something simple but I'm running out of ideas.
Last edited by R4L on Sun Dec 01, 2019 1:23 pm, 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: LineSide condition won't break out of loop?

Post by Graf Zahl »

LineSide() denotes which side a linedef was activated from. This will never change during the script's execution, and since your script loops it will never pick up any subsequent activations.
User avatar
R4L
Global Moderator
Posts: 426
Joined: Fri Mar 03, 2017 9:53 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Pro
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: LineSide condition won't break out of loop?

Post by R4L »

Ah, that explains it then. Thanks, I'll have to figure it out a different way.

EDIT: I figured it out.

Made two lines, each one triggers a certain script:

Code: Select all

script "Camera_On" (void)
{
		//Reset camera
		ACS_NamedTerminate("Camera_Pan", 0);
		GiveInventory("PlayerMorphCamera", 1);
		Thing_Deactivate(14);
		ChangeCamera(0,TRUE,FALSE);
		SetActorPosition(14,GetActorX(14),GetActorY(14),10,FALSE);
		ACS_ExecuteAlways(587,0,90,4);
		terminate;
}

script "Camera_Pan" (void)
{
		int playerz;
		TakeInventory("PlayerMorphCamera", 0X7FFFFFF);
		Thing_Activate(14);
		ChangeCamera(14,TRUE,FALSE);

		playerz = GetActorZ(PlayerNumber());
		Log(f:playerz);

		SetActorPosition(14,GetActorX(14),GetActorY(14),playerz,FALSE);
		Delay(1);
		restart;
}
Works pretty good now: https://streamable.com/l3sgd
Post Reply

Return to “Scripting”