Jump to content

Scripting help please.


antstubell

Recommended Posts

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 Auto
GlobalVariable Property BatteryState Auto
Int Property StageToSet Auto
ObjectReference Property HouseDoor Auto
ObjectReference Property LiftPower Auto
Quest Property MyQuest Auto

; this script will only be available when battery is fully charged value 2

bool property isInPullPosition = True Auto

auto state waiting

Event OnActivate(ObjectReference akActionRef)

GotoState("Busy"); prevents re-activation

; send current and open doors
If CheckCableFix.GetValue() == 1; cable is fixed
isInPullPosition = False; lever has moved to pushed position
Debug.Notification("Pushed On")
BatteryState.SetValue(3); set to 3 cable is now live
HouseDoor.enable()
LiftPower.enable()
MyQuest.Setstage(StageToSet); stage only set if cable is fixed
EndIf

; send current even though cable is not fixed – don’t open doors
if 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 live
BatteryState.SetValue(3); set to 3 cable is now live
EndIf

; turn off current
if (isInPullPosition) = False; 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")
Endif

GotoState("Waiting"); return to a reactivation state
Endevent
EndState
State Busy
Event OnActivate(ObjectReference akActionRef)
;Do Nothing.
EndEvent
EndState

 

 

(37,22): required (...)+ loop did not match anything at input '='

 

Link to comment
Share on other sites

your code

if (isInPullPosition) = False; power is on lever is Pushed

should be changed to this

if (isInPullPosition == False)               ; power is on lever is Pushed

or this

if ( !isInPullPosition )                     ; power is on lever is Pushed

or this

if ( isInPullPosition )                     ; power is on lever is Pushed
else

learning 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 by ReDragon2013
Link to comment
Share on other sites

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 Auto
GlobalVariable Property BatteryState Auto
Int Property StageToSet Auto
ObjectReference Property HouseDoor Auto
ObjectReference Property LiftPower Auto
Quest Property MyQuest Auto

; this script will only be available when battery is fully charged value 2

bool property isInPullPosition = True Auto

auto state waiting

Event OnActivate(ObjectReference akActionRef)

GotoState("Busy"); prevents re-activation

; send current and open doors
If CheckCableFix.GetValue() == 1; cable is fixed
isInPullPosition = True; lever is in position Pulled
Debug.Notification("Power Being Sent")
BatteryState.SetValue(3); set to 3 cable is now live
HouseDoor.enable()
LiftPower.enable()
MyQuest.Setstage(StageToSet); stage only set if cable is fixed
EndIf

; send current even though cable is not fixed – don’t open doors
if 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 live
if (isInPullPosition == True); lever is in position Pulled
BatteryState.SetValue(3); set to 3 cable is now live
Debug.Notification("Power Being Sent DANGER"); if player attempts a cable repair now, they will die
EndIf
EndIf

; turn off current
if (isInPullPosition == False); power is on lever is in Pushed position
BatteryState.SetValue(2); on lever activate from the pushed position set global to 2 (pulled) battery charged but power is not being sent
Debug.Notification("Power Off")
Endif

GotoState("Waiting"); return to a reactivation state
Endevent
EndState
State Busy
Event OnActivate(ObjectReference akActionRef)
;Do Nothing.
EndEvent
EndState

 

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

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

  • Recently Browsing   0 members

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