Jump to content

if (blah == blah blah) Item1.getAngle Item2.setAngle elseif (blah blah


Launius

Recommended Posts

Having trouble making a code work. I know the problem lies in the angX and angY section, because the code works if I just give z a position. I'm just not sure if I could use a different choice of coding to achieve the same goal. I need Activator01 to be lowered depending on the angle of ContainerRef. Any thoughts? BTW, if anyone knows of a good place to learn scripting syntax, throw me a link. Sometimes the TES wiki doesn't make things very clear. Anyhow, the code:

 

Begin OnAdd ContainerRef
if (ContainerRef.GetItemCount Item01 == 1)
	Activator01.disable

    		Activator01.moveTo ContainerRef

    		set pos to ContainerRef.getPos y
    		Activator01.setPos y pos

	set pos to ContainerRef.getPos x
	Activator01.setPos x pos

    		set angX to ContainerRef.getAngle X
	set angY to ContainerRef.getAngle Y
			if ((angX <= 5 && angX >= -5) || (angY <= 5 && angY >= -5))
					set pos to ContainerRef.getPos z
    						Activator01.setPos z pos
			elseif ((angX <= 15 && angX > 5 && angX >= -15 && angX < -5) || (angY <= 15 && angY > 5 && angY >= -15 && angY < -5))
					set pos to ContainerRef.getPos z - 15
    						Activator01.setPos z pos
			elseif ((angX > 15 && angX < -15) || (angY > 15 && angY < -15))
					set pos to ContainerRef.getPos z - 20
    						Activator01.setPos z pos
			endif

		ContainerRef.disable

		Activator01.enable
endif
End

Link to comment
Share on other sites

Lol. This is top secret stuff, buddy. The script works in conjunction with two other scripts.

 

Basically what it does is: A script attached to a weapon causes a container (ContainerRef) to spawn whenever that weapon is equipped and the player is attacking. When a certain item (Item01) is placed inside ContainerRef another script cues it to wait 1 game day, then upon completion of that game day Item01 is replaced with Item02, which kicks off the OnAdd block, causing ContainerRef to disappear and an activator to be placed in its position. The problem is if said ContainerRef is not placed on a level surface, the activator may not look so aesthetically pleasing as intended. To compensate for that, the angX and angY determine the angle of the ground by determining the angle of ContainerRef. Then, the steeper the angle of the ground, the more the activator is lowered to avoid a gap between the activator base and the ground where it is placed.

 

What's wrong: For some reason the OnAdd block will not read anything pertaining to the set angX and angY functions and thus will not adjust the z position accordingly. You advised that I compare a "getAngle z" instead, but unless I'm confused about which plane is which, getting the z angle would only determine which direction the object was facing. I need to determine how tilted it is.

 

Thanks for reading, lol.

Link to comment
Share on other sites

Sorry, I have no idea why

 

                set angX to ContainerRef.getAngle X
               set angY to ContainerRef.getAngle Y

does not work.

 

But I can say that these lines

 

                set pos to ContainerRef.getPos y
               Activator01.setPos y pos

               set pos to ContainerRef.getPos x
               Activator01.setPos x pos

are superfluous because that's already covered when you use the MoveTo function.

 

Also, for this part

 

elseif ((angX <= 15 && angX > 5 && angX >= -15 && angX < -5) || (angY <= 15 && angY > 5 && angY >= -15 && angY < -5))

you need to replace some of those "&&" with "||".

Link to comment
Share on other sites

I figured that some of that code was not needed, but I wasn't ready to remove it because the code was working, lol. I figured I'd make the code do what I wanted it to, then clean it up where I could. I see my mistake in that last line of code, I'll fix that. I won't get my hopes up, but maybe for some unknown reason that will fix the code, ha.

 

HA! It worked. Thanks for pointing that out fg!

Edited by Launius
Link to comment
Share on other sites

Also this line:

 

elseif ((angX > 15 && angX < -15) || (angY > 15 && angY < -15))

 

That will never evaluate as true. It is impossible for either angX or angY to simultaneously be both greater than 15 AND less than -15.

You likely just want this:

 

elseif (angX > 15 || angX < -15 || angY > 15 || angY < -15)

 

However, that is just a reworking of your existing logical construction.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...