antstubell Posted September 30, 2019 Share Posted September 30, 2019 I am parsing a line wrong, I know, but can't figure it out. Script runs on a lever. Script checks for 2 things.1- Has the power line been fixed? All this does is check a global in order to set a different global so that if player tries to fix a live power line (BatteryState =3) = dead.2- In which position is the lever, pulled or pushed. Pulled = Power On (True). Pushed = Power Off. (False). If player realises that going to work on a power line they have just turned on is a bad idea, they can go back to the lever and turn it off. This sets BatteryState to 2 = battery is charged but power is not being sent. GlobalVariable Property CheckCableFix AutoGlobalVariable Property BatteryState AutoInt Property StageToSet AutoObjectReference Property HouseDoor AutoObjectReference Property LiftPower AutoQuest Property MyQuest Auto; this script will only be available when battery is fully charged value 2bool property isInPullPosition = True Autoauto state waitingEvent OnActivate(ObjectReference akActionRef)GotoState("Busy"); prevents re-activation; send current and open doorsIf CheckCableFix.GetValue() == 1; cable is fixedisInPullPosition = False; lever has moved to pushed positionDebug.Notification("Pushed On")BatteryState.SetValue(3); set to 3 cable is now liveHouseDoor.enable()LiftPower.enable()MyQuest.Setstage(StageToSet); stage only set if cable is fixedEndIf; send current even though cable is not fixed – don’t open doorsif CheckCableFix.GetValue() != 1; cable is not fixed, current will be sent regardless; because cable is not fixed house door and lift will not have power but cable is liveBatteryState.SetValue(3); set to 3 cable is now liveEndIf; turn off currentif (isInPullPosition) = False; power is on lever is PushedisInPullPosition = True; lever moved to default Pulled positionBatteryState.SetValue(2); set to 2 battery charged but power is not being sentDebug.Notification("Pulled Off")EndifGotoState("Waiting"); return to a reactivation stateEndeventEndStateState BusyEvent OnActivate(ObjectReference akActionRef);Do Nothing.EndEventEndState (37,22): required (...)+ loop did not match anything at input '=' Link to comment Share on other sites More sharing options...
ReDragon2013 Posted September 30, 2019 Share Posted September 30, 2019 (edited) your code if (isInPullPosition) = False; power is on lever is Pushedshould be changed to this if (isInPullPosition == False) ; power is on lever is Pushedor this if ( !isInPullPosition ) ; power is on lever is Pushedor this if ( isInPullPosition ) ; power is on lever is Pushed elselearning by doing.. Scriptname antLeverActivationScript extends ObjectReference GlobalVariable PROPERTY CheckCableFix auto GlobalVariable PROPERTY BatteryState auto ; this script will only be available when battery is fully charged value 2 Quest PROPERTY MyQuest auto Int PROPERTY StageToSet auto ObjectReference PROPERTY HouseDoor auto ObjectReference PROPERTY LiftPower auto Bool PROPERTY isInPullPosition = TRUE auto ; -- EVENTs -- ;=============================== state Busy ;========= endState ;=============================== auto state Waiting ;================= EVENT OnActivate(ObjectReference akActionRef) gotoState("Busy") ; ### STATE ### prevents activation while busy BatteryState.SetValue(3) ; set to 3 cable is now live ; send current and open doors IF (CheckCableFix.GetValue() == 1) ; cable is fixed isInPullPosition = False ; lever has moved to pushed position Debug.Notification("Pushed On") ; debug info! HouseDoor.Enable() LiftPower.Enable() MyQuest.setStage(StageToSet) ; stage only set if cable is fixed ; send current even though cable is not fixed - don’t open doors ;;; ELSE ; cable is not fixed, current will be sent regardless ; because cable is not fixed house door and lift will not have power but cable is live ENDIF ; turn off current IF ( isInPullPosition ) ELSE ; power is on lever is Pushed isInPullPosition = TRUE ; lever moved to default Pulled position BatteryState.SetValue(2) ; set to 2 battery charged but power is not being sent Debug.Notification("Pulled Off") ; debug info! ENDIF gotoState("Waiting") ; ### STATE ### give next activation a try ENDEVENT ;======= endState Edited September 30, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
antstubell Posted October 1, 2019 Author Share Posted October 1, 2019 I've used all of your suggestions and scripts but have the problem that the power won't turn off. The player needs to be aware that working on a live power line = death, either by actually dying and realising "You know what, I should turn off the power before I do that again" or before attempting to fix the power line player thinks "Good idea to turn off power before I do this." In both scenarios player must be able to turn off the power. In essence once the lever is activated from Pulled to Pushed, setting the global to 3 and making the cable LIVE, player needs that if the lever is activated again from Pushed to Pulled, the global is set to 2 cable is not live. And of course when player has done the repairs can again turn the power on. This is the script, seems logical to me but as I said power won't go off. GlobalVariable Property CheckCableFix AutoGlobalVariable Property BatteryState AutoInt Property StageToSet AutoObjectReference Property HouseDoor AutoObjectReference Property LiftPower AutoQuest Property MyQuest Auto; this script will only be available when battery is fully charged value 2bool property isInPullPosition = True Autoauto state waitingEvent OnActivate(ObjectReference akActionRef)GotoState("Busy"); prevents re-activation; send current and open doorsIf CheckCableFix.GetValue() == 1; cable is fixedisInPullPosition = True; lever is in position PulledDebug.Notification("Power Being Sent")BatteryState.SetValue(3); set to 3 cable is now liveHouseDoor.enable()LiftPower.enable()MyQuest.Setstage(StageToSet); stage only set if cable is fixedEndIf; send current even though cable is not fixed – don’t open doorsif CheckCableFix.GetValue() != 1; cable is not fixed, current will be sent regardless; because cable is not fixed house door and lift will not have power but cable is liveif (isInPullPosition == True); lever is in position PulledBatteryState.SetValue(3); set to 3 cable is now liveDebug.Notification("Power Being Sent DANGER"); if player attempts a cable repair now, they will dieEndIfEndIf; turn off currentif (isInPullPosition == False); power is on lever is in Pushed positionBatteryState.SetValue(2); on lever activate from the pushed position set global to 2 (pulled) battery charged but power is not being sentDebug.Notification("Power Off")EndifGotoState("Waiting"); return to a reactivation stateEndeventEndStateState BusyEvent OnActivate(ObjectReference akActionRef);Do Nothing.EndEventEndState Video showing global state...https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2151472&parId=B60C11D037429D8E%21191&o=OneUp Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 2, 2019 Share Posted October 2, 2019 Your bool isInPullPosition never has a value of False. It is defaulted to true and set to true but it never gets set to false. Thus the last block which depends upon it having a false value will never trigger. Link to comment Share on other sites More sharing options...
antstubell Posted October 2, 2019 Author Share Posted October 2, 2019 So the lever never has a True or False value set when it is activated? A value that the script can 'read from'? So checking for if (isInPullPosition == True) or if (isInPullPosition == False) has no point? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 2, 2019 Share Posted October 2, 2019 The lever itself has no value on whether it has been pulled or not. You have to track that via script. Sorry. Decide the starting state of the lever (pulled or pushed) and assign the bool variable the corresponding value.Then before running any conditions that check for that value use the following to toggle the bool variable with each use of the lever. If isInPullPosition == true isInPullPosition = false Else isInPullPosition = true EndIf You will probably want to make sure that the GoToState("Busy") is before it in order to help eliminate getting out of sync. Link to comment Share on other sites More sharing options...
antstubell Posted October 3, 2019 Author Share Posted October 3, 2019 This is where everything went wrong. I assumed the lever would return a value, True, False or Pulled, Pushed that the script could work off.At least with a pull chain and button it is either activated or not.Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts