Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
R2card

Need help with understanding GetLineActivation!

Recommended Posts

I'm trying to understand why this isn't working for me! I've done a few smaller scripts already but this one is giving me a hard time!
(I'm in Doom 2 Hexen format, idk if that's helpful)

 

https://zdoom.org/wiki/GetLineActivation

 

I don't understand if I'm supposed to replace "int id" with anything, and what line ID am I meant to use, just for the overall linedef, or the front or back sidedef.

 

Also I'm not sure what "&" means!

 

I'm very new to this scripting thing, I thought I was getting the grasp of it, but this is just killing me!

Share this post


Link to post

The LineID is basically like a tag. You assign one to the linedef you want to check in your map editor.

 

GetLineActivation() is a function that returns a bitfield of all activation flags that the specified linedef has, and those flag values are added together so it will return a single value. It's up to you to parse that return value for the information that is relevant to you.

 

For example GetLineActivation() might return a value of 5, which would indicate that it contains SPAC_Cross (a value of 1) and SPAC_MCross (a value of 4). So for example, to check if a linedef with a LineID of 15 can be activated by a monster crossing it, we have to use the bitwise AND operator (&) to filter out what flags we don't care about:

(GetLineActivation(15) & SPAC_MCross)

...will return true if a monster can activate it.

 

You can check for multiple flags too, using the bitwise OR operator (|) in conjunction with the & operator:

(GetLineActivation(lineid) & (flag1 | flag2 | flag3))

...will return true if GetLineActivation() contains flag1 or flag2 or flag3.

 

Might I ask, what are you specifically trying to do?

Share this post


Link to post

@EarthQuake In this case it seems I might be using the wrong function here, I want to check when the player presses a switch, and something I didn't ask because I think I have the proper code for it is setting a generic line to a switch.

 

I have 8 switches that are activated in a clock-wise pattern, and as each switch is pressed the wall in front of the next is lowered. Currently I can press the switch though the wall, so I wanted to get around that by removing the switch until it's needed and adding it back in with code.

 

This whole coding thing goes a lot deeper than I expected!

Share this post


Link to post

You definitely can do that.

 

Give each of your switches a line ID. Don't give them a special (other than Line_SetIdentification to give them the ID, since you're using Hexen format). Make scripts that lower the wall and activate the next switch with SetLineSpecial. This way, until the wall is lowered, the line has no effect and cannot be used by the player.

Share this post


Link to post
4 hours ago, Gez said:

Make scripts that lower the wall and activate the next switch with SetLineSpecial.

 

The only problem I seem to be facing now is how to detect when the player pushes the first switch.

Script 2 (int id)

{
	SetLineActivation(8, "SPAC_Use")
	
	if (GetLineActivation(8) & "SPAC_Use")
	{
		Floor_LowerToLowest(19, 32);
		
		SetLineSpecial(1, 21, 20, 32, 0, 0, 0)
	}
	
}

This is what I have right now, but it seems like it won't do what I want because it would perform the action as soon as the player enters(or would it?). (It's also throwing errors up on the if line and I'm not sure why. I forgot semi-colons!)

 

I'm still also not sure if I'm to replace the int id part next to the script with anything.

 

(P.S. I'm sorry for my stupidity, this is probably super simple)

Edited by R2card

Share this post


Link to post

Here's a very simple example. You're spawned in a tiny room with a numbered switch on all four sides. You cannot use switches 2, 3 and 4 at startup. When you use switch 1, you enable switch 2. When you use switch 2, you enable switch 3. When you use switch 3, you enable switch 4. When you use switch 4, you exit the level.

scriptedswitch.zip

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×