Jump to content
Mattiewagg

[Student Thread] Paulibobo - Matthiaswagg

Recommended Posts

Ok, here is the Script I have made so far for the first right lever. What do you think? PMRightLever is the name of the script, the Global is OpenSesame. Tell me if I did anything wrong, but now I think what i have to do is make the second lever check if the Value of OpenSesame is 1 and if it is set it to 2, and the same for the thrid only it sets it from 2 to 3. Then I was thinking about putting a script on te gate so that if OpenSesame is 3 it opens, else you get hit by a spell. The wrong ones i'll just make the same script but with OpenSesame.SetValue(0.0) instead. Does this make any sense?

Scriptname PMRightLever extends ObjectReference

GlobalVariable Property OpenSesame auto

float OpenSesame

Event OnActivate (ObjectReference akActionRef)

OpenSesame.SetValue(1.0)

EndEvent

PS: I wanted to put the script in a spoiler but I don't know how, could you please explain that to me?

You've got the right idea, but the script itself is not quite right. For the Script on the right levers, you have a float variable. I'm not sure what you were using that for - the Global is all you were setting. Setting it to 1.0 doesn't require a variable. You can set to 1.0, 282991.00001, etc. Without a variable.

Now, if you don't care about the levers being pushed in the right order, then all you need to do is ADD to the global value and chdck when it is 3. So, youd make an ObjectReference property for your door, inside your lever script, and then put the following in your OnActivate:

IF OpenSesame.GetValue() == 3.0

MyDoor.Activate(Game.GetPlayer());or, you could use Unlock which I linked earlier if you were just trying to unlock the door, or Unlock and THEN activate

Else

OpenSesame.Mod(1.0)

EndIf

Then you'd have another script on your bad levers which would set the global to 0 and Cast (find it on the CK Wiki!) the spell on the player, with a Spell property.

If you want to have to activate the door before anything happens, then yes. You need a script on the door. I didn't realize that was what you wanted - usually you just have to pull the levers and the correct combination opens the door, the incorrect hurts you. Since you're not doing a combination, bad levers would be incorrect and good ones correct.

Spoiler tags:

;put your text inside

Code tags:
;put code in here


			
				

	Edited  by Matthiaswagg
	
	

			
		

Share this post


Link to post
Share on other sites

Ok, here's my second lever script:

Scriptname PMRightLever2 extends ObjectReference  

GlobalVariable Property OpenSesame auto
Event OnActivate (ObjectReference akActionRef)
if OpenSesame.GetValue() == 1.0
OpenSesame.Mod(1.0)
else
OpenSesame.SetValue(0.0)
EndIf
EndEvent
Edited by Paulibobo

Share this post


Link to post
Share on other sites

Here's what I figured out for the door script. Now only the wrong lever scripts are left to do, and that's the easy part.

Scriptname PMOpenDoor extends ObjectReference  
GlobalVariable Property OpenSesame auto
Spell Property FireSpell Auto
Actor Property PlayerREF Auto
ObjectReference property MyDoor auto
Event OnActivate (ObjectReference akActionRef)
if OpenSesame.GetValue() == 3.0
MyDoor.Activate(Game.GetPlayer())
else  
FireSpell.Cast(Self, PlayerREF)
EndIf

Share this post


Link to post
Share on other sites

Here's what I figured out for the door script. Now only the wrong lever scripts are left to do, and that's the easy part.

Scriptname PMOpenDoor extends ObjectReference  
GlobalVariable Property OpenSesame auto
Spell Property FireSpell Auto
Actor Property PlayerREF Auto
ObjectReference property MyDoor auto
Event OnActivate (ObjectReference akActionRef)
if OpenSesame.GetValue() == 3.0
MyDoor.Activate(Game.GetPlayer())
else  
FireSpell.Cast(Self, PlayerREF)
EndIf

Since you've defined PlayerREF, you should use PlayerREF instead of Game.GetPlayer().

You can use Self instead of defining a property for MyDoor.

Self is not a property, but sort of like a variable that will be the reference the script is on. So you can do:

Self.Activate(PlayerREF)
  • reaction_title_1 1

Share this post


Link to post
Share on other sites

The Script is working, after some minor changes. What's next?

Now I show you the streamlined version of the script and you try to understand it. ;)

GlobalVariable Property kCounter Auto
Int Property iExpectedValue Auto
ObjectReference Property kTarget Auto
Event OnActivate(ObjectReference akActionRef)
    Int iCounter = kCounter.GetValueInt()
    If(iCounter == iExpectedValue)
        kCounter.SetValue(iCounter + 1)
        If(kTarget != None)
            kTarget.Activate(akActionRef)
                        kTarget = None ;This is optional, but it stops the target from being activated again and should stop the target from being persistent
        EndIf
    Else
        kCounter.SetValue(0)
    EndIf
EndEvent 

This script is attached to each lever (create new the first time then Add and change properties for subsequent levers) and iExpectedValue is the zero-based index of the button in the order of buttons to press. So the first button's iExpectedValue is 0 and the 3nd button's is 2. The last button is the only one that should have the kTarget property filled - kTarget is the door to open. If a button is pressed in the wrong order, then the GlobalVariable is reset to 0 and the player has to start from the beginning.

Now that was the original script. To have it as you would've liked, needing to open the door, would've required two scripts, the abovel ike so:

GlobalVariable Property OpenSesame Auto
Int Property iExpectedValue Auto
Event OnActivate(ObjectReference akActionRef)
    Int iCounter = OpenSesame.GetValueInt();same as GetValue but in integer form
    If(iCounter == iExpectedValue)
        OpenSesame.Mod(1.0)
    Else
        OpenSesame.SetValue(0)
    EndIf
EndEvent 

And the door script is the same as the one you created before (you said you changed it, hence why I'm not using the one you used before). You would have the wrong lever script the same too - or you could add the above script and change the iExpectedValue property to an impossible number, which would be more efficient as you would keep only 2 scripts.

Do you understand the more streamlined script?

Edited by Matthiaswagg
  • reaction_title_1 1

Share this post


Link to post
Share on other sites

Ok, here is the Script I have made so far for the first right lever. What do you think? PMRightLever is the name of the script, the Global is OpenSesame. Tell me if I did anything wrong, but now I think what i have to do is make the second lever check if the Value of OpenSesame is 1 and if it is set it to 2, and the same for the thrid only it sets it from 2 to 3. Then I was thinking about putting a script on te gate so that if OpenSesame is 3 it opens, else you get hit by a spell. The wrong ones i'll just make the same script but with OpenSesame.SetValue(0.0) instead. Does this make any sense?

Scriptname PMRightLever extends ObjectReference

GlobalVariable Property OpenSesame auto

float OpenSesame

Event OnActivate (ObjectReference akActionRef)

OpenSesame.SetValue(1.0)

EndEvent

PS: I wanted to put the script in a spoiler but I don't know how, could you please explain that to me?

you start your quote with [spoil.er....] and end with [/...spoiler....]

Share this post


Link to post
Share on other sites

Oh I forot to explain myself.

Event onactivate(akActionRef )

if (akActionRef == lever01)

If (lever01== TRUE)

Levers = levers-1

Elseif (lever01 == FALSE)

Levers = levers+1

Elseif (akActionRef == lever02)

ETC ETC

Elseif (akActionRef == playerREF)

If (levers ==3)

"Activate door"

Elseif (levers != 3 )

"activate trap"

Here is levers an int for the right levers that have been pulled, lever01-03 worldobjects and bools that change from 0 to 1 if the lever hets pulled.

see what I mean?

Edited by magicspook

Share this post


Link to post
Share on other sites

Oh I forot to explain myself.

Event onactivate(akActionRef )

if (akActionRef == lever01)

If (lever01== TRUE)

Levers = levers-1

Elseif (lever01 == FALSE)

Levers = levers+1

Elseif (akActionRef == lever02)

ETC ETC

Elseif (akActionRef == playerREF)

If (levers ==3)

"Activate door"

Elseif (levers != 3 )

"activate trap"

see what I mean?

Not particularly, no. You don't have any properties or variables defined so I can't really see what you're attempting to do. And the lever doesn't activate the door. The player does. The lever is activated by the player but the lever cannot activate the door unless said to in the script on the lever, which would be required.

  • reaction_title_1 1

Share this post


Link to post
Share on other sites

The Script is working, after some minor changes. What's next?

Now I show you the streamlined version of the script and you try to understand it. ;)

GlobalVariable Property kCounter Auto
Int Property iExpectedValue Auto
ObjectReference Property kTarget Auto
Event OnActivate(ObjectReference akActionRef)
    Int iCounter = kCounter.GetValueInt()
    If(iCounter == iExpectedValue)
        kCounter.SetValue(iCounter + 1)
        If(kTarget != None)
            kTarget.Activate(akActionRef)
                        kTarget = None ;This is optional, but it stops the target from being activated again and should stop the target from being persistent
        EndIf
    Else
        kCounter.SetValue(0)
    EndIf
EndEvent 

This script is attached to each lever (create new the first time then Add and change properties for subsequent levers) and iExpectedValue is the zero-based index of the button in the order of buttons to press. So the first button's iExpectedValue is 0 and the 3nd button's is 2. The last button is the only one that should have the kTarget property filled - kTarget is the door to open. If a button is pressed in the wrong order, then the GlobalVariable is reset to 0 and the player has to start from the beginning.

Now that was the original script. To have it as you would've liked, needing to open the door, would've required two scripts, the abovel ike so:

GlobalVariable Property OpenSesame Auto
Int Property iExpectedValue Auto
Event OnActivate(ObjectReference akActionRef)
    Int iCounter = OpenSesame.GetValueInt();same as GetValue but in integer form
    If(iCounter == iExpectedValue)
        OpenSesame.Mod(1.0)
    Else
        OpenSesame.SetValue(0)
    EndIf
EndEvent 

And the door script is the same as the one you created before (you said you changed it, hence why I'm not using the one you used before). You would have the wrong lever script the same too - or you could add the above script and change the iExpectedValue property to an impossible number, which would be more efficient as you would keep only 2 scripts.

Do you understand the more streamlined script?

Yes, this makes sense to me, I just tought of it in a diferent way and ended up with a diferent script.  Is there any diference between the way that and mine work? The result is bound to be pretty much the same, no?

Share this post


Link to post
Share on other sites

The Script is working, after some minor changes. What's next?

Now I show you the streamlined version of the script and you try to understand it. ;)

GlobalVariable Property kCounter Auto
Int Property iExpectedValue Auto
ObjectReference Property kTarget Auto
Event OnActivate(ObjectReference akActionRef)
    Int iCounter = kCounter.GetValueInt()
    If(iCounter == iExpectedValue)
        kCounter.SetValue(iCounter + 1)
        If(kTarget != None)
            kTarget.Activate(akActionRef)
                        kTarget = None ;This is optional, but it stops the target from being activated again and should stop the target from being persistent
        EndIf
    Else
        kCounter.SetValue(0)
    EndIf
EndEvent 

This script is attached to each lever (create new the first time then Add and change properties for subsequent levers) and iExpectedValue is the zero-based index of the button in the order of buttons to press. So the first button's iExpectedValue is 0 and the 3nd button's is 2. The last button is the only one that should have the kTarget property filled - kTarget is the door to open. If a button is pressed in the wrong order, then the GlobalVariable is reset to 0 and the player has to start from the beginning.

Now that was the original script. To have it as you would've liked, needing to open the door, would've required two scripts, the abovel ike so:

GlobalVariable Property OpenSesame Auto
Int Property iExpectedValue Auto
Event OnActivate(ObjectReference akActionRef)
    Int iCounter = OpenSesame.GetValueInt();same as GetValue but in integer form
    If(iCounter == iExpectedValue)
        OpenSesame.Mod(1.0)
    Else
        OpenSesame.SetValue(0)
    EndIf
EndEvent 

And the door script is the same as the one you created before (you said you changed it, hence why I'm not using the one you used before). You would have the wrong lever script the same too - or you could add the above script and change the iExpectedValue property to an impossible number, which would be more efficient as you would keep only 2 scripts.

Do you understand the more streamlined script?

Yes, this makes sense to me, I just tought of it in a diferent way and ended up with a diferent script.  Is there any diference between the way that and mine work? The result is bound to be pretty much the same, no?

Yep, they work just about the same. However, yours requires multiple scripts - one for each lever. This one requires only 1 script for all the levers. Both ways work, but this one is more efficient and requires less work.

Share this post


Link to post
Share on other sites

Huh, this is weird. I decided to try to install Skyrim Script Editor again, you know, just seeing if it had decided to start working, and it did. Autocomplete's pretty cool, I might use this one from now on. What is the compile hotkey though?

Yeah, he's had about 100 updates since then. Big and small. That was an issue of the far past.

Ctrl+S

We'll be doing the advanced properties lesson next.

  • reaction_title_1 1

Share this post


Link to post
Share on other sites

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

×