Calling on a Bool that was set in another script - only Fals

Post » Sat Nov 17, 2012 11:14 pm

Two scripts: one "places an object", the other does an action if the player is within a trigger box & the object has been placed. Seems simple. The scripts look right, they compile okay, but it only works when the initial value on the Bool is false and the second script checks for a false (it needs to check for a positive).

Here they are in order:





Scriptname AzurasStarDisplayClickTrigger extends ObjectReference
;This script checks to see if the player has Azura's Star in inventory. If it finds it, it removes it and enables a Ref of it. It also activates a new activator which will give it back and disable the Ref.
Bool Property StarPlaced = False Auto
SoulGem Property Star Auto
;defined as Azura's Star
ObjectReference Property StarActivator Auto
;nearly identically scripted activator used to "pick up" (give back) azuras star after it has been placed. Not efficient, I know.
ObjectReference Property StarBarrier Auto
;static collision barrier used to prevent player from picking up the azura's star objectreference, and from Fus Ro Da-ing it across the room
ObjectReference Property StarRef Auto
;The visual indicator that the player has "placed" azuras star on it's display

EVENT OnActivate(ObjectReference TriggerRef)
If (Game.GetPlayer().GetItemCount (Star) >= 1)
Game.GetPlayer().RemoveItem (Star)
StarActivator.Enable()
StarBarrier.Enable()
StarRef.Enable()
Self.Disable()
StarPlaced = !StarPlaced
;flips the "StarPlaced" bool to TRUE for the next script to read. I have alternatively used "StarPlaced = TRUE" with the same result.
Endif
endEVENT







Scriptname AzurasStarEnchBoostBox extends ObjectReference
;this script checks to see if the player has activated the AzurasStarDisplayClickTrigger and is entering a trigger box. If true, then it does an action.
AzurasStarDisplayClickTrigger Property Star auto
;This defines the AzurasStarDisplayClickTrigger script (above) as a property called Star.
ObjectReference Property Candlestick Auto
;A nearby candlestick that will be enabled as a test action.

EVENT OnTriggerEnter(ObjectReference akActionRef)
If akActionRef == (Game.GetPlayer() && Star.StarPlaced == True)
;we are pulling the StarPlaced property out of the script that has been defined as Star for THIS script. Check to see if it is positve.
Candlestick.Enable()
Else
;if StarPlaced is not positve, then do nothing
Endif
ENDEVENT






It does work if the second script looks for a FALSE, so it must be searching the first script okay. I thought maybe the second script seems to just look at what the initial value of the Bool is, but when the initial value is set to True and the second script searches for a True, it doesn't work. Where did I go wrong?

Your help is much appreciated.
User avatar
Carolyne Bolt
 
Posts: 3401
Joined: Mon Jul 10, 2006 4:56 am

Post » Sun Nov 18, 2012 6:18 am

Two things I can think of:

1. The brackets on the if statement are incorrect, but that may be a copy-paste error
2. Are you really sure the "AzurasStarDisplayClickTrigger Property Star auto" is correctly filled. I would suspect that if this was not the case it would end up returning false.
Easiest way to check everything is working is adding some debug.trace messages to both scripts and looking in your papyrus log.
User avatar
FLYBOYLEAK
 
Posts: 3440
Joined: Tue Oct 30, 2007 6:41 am

Post » Sun Nov 18, 2012 2:36 am

1) The brackets on the if statement are as they are in script. How should they be?

2) I'm not sure that the "AzurasStarDisplayClickTrigger Property Star auto" is correctly filled. It is currently default. If I try to edit it, it acts as though the property is an object ref property.
User avatar
Brιonα Renae
 
Posts: 3430
Joined: Mon Oct 22, 2007 3:10 am

Post » Sat Nov 17, 2012 8:13 pm

Are you sure it's the right star? Might wanna use a FormList.

Try, perhaps:
Spoiler
ScriptName AzurasStarDisplayClickTrigger Extends ObjectReferenceActor Property PlayerREF Auto ; Leagues faster than Game.GetPlayer()Bool Property StarPlaced Auto ; Is 'False' by default provided the check box is not tickedFormList Property AzuraStarsFLST Auto ; DA01SoulGemAzurasStar + DA01SoulGemBlackStar;ObjectReference Property StarActivator Auto ;ObjectReference Property StarBarrier Auto ;ObjectReference Property StarRef Auto Event OnActivate(ObjectReference akActionRef)	If PlayerREF.GetItemCount(AzuraStarsFLST) ; >= 1		PlayerREF.RemoveItem(AzuraStarsFLST)		StarPlaced = True ; Should not matter, but...		;StarActivator.Enable()		;StarBarrier.Enable()		;StarRef.Enable()		Disable() ; Implicit / Other refs have this as enable parent w/ "Set enable state to opposite of parent" flags ticked	EndIfEndEvent
ScriptName AzurasStarEnchBoostBox Extends ObjectReferenceActor Property PlayerREF AutoAzurasStarDisplayClickTrigger Property Star AutoObjectReference Property Candlestick AutoEvent OnTriggerEnter(ObjectReference akActionRef)	If akActionRef == PlayerREF		If Star.StarPlaced ; == True			Candlestick.Enable()		EndIf	EndifEndEvent

Edit: Parenthesis
If akActionRef == (Game.GetPlayer() && Star.StarPlaced == True)

If (akActionRef == Game.GetPlayer()) && Star.StarPlaced ; == True
Good luck :)
User avatar
Amy Siebenhaar
 
Posts: 3426
Joined: Fri Aug 10, 2007 1:51 am

Post » Sat Nov 17, 2012 11:25 pm

@1:
I would do this: (akActionRef == Game.GetPlayer()) && (Star.StarPlaced)
you compared the akActionRef to (Game.GetPlayer() && Star.placed == True), which seems a bit odd

@2:
Try setting it to the appropriate ref; Check in your script (use some debug trace statements) that the ref is not None and that it is in fact pointing to the correct item

Once you get the script working you can (and probably should) always remove the debug messages.
User avatar
Samantha hulme
 
Posts: 3373
Joined: Wed Jun 21, 2006 4:22 pm

Post » Sun Nov 18, 2012 8:01 am

Thanks for the feedback. Looks much more concise. I will be editing my other scripts with some of these suggestions in mind.

However, the problem still persists. I've re-written the scripts exactly as you've suggested, tested, then mixed and matched both of your suggestions.
The second script still will only see the Bool as False.
The piece of script I'm using to call the Bool: "If Star.StarPlaced == True" is from the wiki. I can't post the link. They use an Integer in the example.

As I mentioned, if I try to edit the property "Star", it expects it to be an object reference instead of a script, so I've left it at "default". This may be part of the problem.
Is there any other way to check a Bool value from outside it's script?

Thank you for all your help.
User avatar
Vicki Gunn
 
Posts: 3397
Joined: Thu Nov 23, 2006 9:59 am

Post » Sun Nov 18, 2012 5:43 am

SOLVED

Just for the heck of it, I decided to play along with the CK and define the "Star" property as an object reference the way it wanted me to. I used the activator item in which the script is contained and the Bool is located. Guess what. It works perfectly now!

I can't believe I spent so much time trying to figure this out. At least I got some good tips from it. Thank you very much. I will be using the PlayerRef property over Game.GetPlayer() from now on.
User avatar
Charlotte Lloyd-Jones
 
Posts: 3345
Joined: Fri Jun 30, 2006 4:53 pm

Post » Sun Nov 18, 2012 1:24 am

The Star (script) property is aptly looking for an ObjectReference as AzurasStarDisplayClickTrigger is an ObjectReference script. You might want to detach/reattach the scripts on both ObjectReferences to ensure the properties are all straight. Sometimes, inexplicable stuff like this gets solved by wiping the slate clean and setting up the scripts from scratch.

Edit: Too late, NM, and congrats!
User avatar
SWagg KId
 
Posts: 3488
Joined: Sat Nov 17, 2007 8:26 am


Return to V - Skyrim