Rayek Posted February 6, 2017 Share Posted February 6, 2017 (edited) Trying to make a cooking pot and accessories toggle able with and Enable/Disable script. (i.e. click on pot...it disappears and re-appears over the now lit embers) The script returns no errors and the initial Enable/Disable works...but I can't toggle it back and forth. What am I missing? Wrong type of script for this? Scriptname RE_CookingPotScript extends ObjectReference ObjectReference Property BurningEmber Auto ObjectReference Property DousedEmber Auto ObjectReference Property FireLight Auto ObjectReference Property CookingPotOn Auto ObjectReference Property CookingPotOff Auto Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() BurningEmber.Enable() DousedEmber.Disable() FireLight.Enable() CookingPotOn.Enable() CookingPotOff.Disable() Else BurningEmber.Disable() DousedEmber.Enable() FireLight.Disable() CookingPotOn.Disable() CookingPotOff.Enable() EndIf EndEventThis being my 2nd script attempt...any help is appreciated. Edited February 7, 2017 by Rayek Link to comment Share on other sites More sharing options...
Di0nysys Posted February 6, 2017 Share Posted February 6, 2017 (edited) Try this. Scriptname RE_CookingPotScript extends ObjectReference ObjectReference Property BurningEmber AutoObjectReference Property DousedEmber AutoObjectReference Property FireLight AutoObjectReference Property CookingPotOn AutoObjectReference Property CookingPotOff AutoActor Property PlayerREF AutoInt IsOn Event OnActivate(ObjectReference akActionRef) If (akActionRef == PlayerREF) TurnOnFire() EndIfEndEvent Function TurnOnFire() If (IsOn == 0) IsOn = 1 BurningEmber.Enable() DousedEmber.Disable() FireLight.Enable() CookingPotOn.Enable() CookingPotOff.Disable() Elseif (IsOn == 1) IsOn = 0 BurningEmber.Disable() DousedEmber.Enable() FireLight.Disable() CookingPotOn.Disable() CookingPotOff.Enable() EndifEndFunction Edited February 6, 2017 by Di0nysys Link to comment Share on other sites More sharing options...
Masterofnet Posted February 6, 2017 Share Posted February 6, 2017 (edited) Please post your scripts like this. You were right about getting the playerref at run time, but your script has no way of telling if the pot is on or off. Since this is only yes or no use a bool and there is no reason to check of the bool is true because if it is not false it would have to be true. Scriptname RE_CookingPotScript extends ObjectReference ObjectReference Property BurningEmber Auto ObjectReference Property DousedEmber Auto ObjectReference Property FireLight Auto ObjectReference Property CookingPotOn Auto ObjectReference Property CookingPotOff Auto Bool On Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() Else Return EndIf If On BurningEmber.Disable() DousedEmber.Enable() FireLight.Disable() CookingPotOn.Disable() CookingPotOff.Enable() On = False Return EndIf BurningEmber.Enable() DousedEmber.Disable() FireLight.Enable() CookingPotOn.Enable() CookingPotOff.Disable() On = True EndEvent Edited February 9, 2017 by Masterofnet Link to comment Share on other sites More sharing options...
Rayek Posted February 6, 2017 Author Share Posted February 6, 2017 Thanks you two. Understand now that it didn't have a way of knowing if it was in a on/off state. Will also post further scripts in the format mentioned. Link to comment Share on other sites More sharing options...
steve40 Posted February 7, 2017 Share Posted February 7, 2017 Scriptname RE_CookingPotScript extends ObjectReference ObjectReference Property BurningEmber Auto ObjectReference Property DousedEmber Auto ObjectReference Property FireLight Auto ObjectReference Property CookingPotOn Auto ObjectReference Property CookingPotOff Auto Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() If BurningEmber.IsDisabled() BurningEmber.Enable() DousedEmber.Disable() CookingPotOn.Enable() CookingPotOff.Disable() FireLight.Enable() Else FireLight.Disable() CookingPotOff.Enable() CookingPotOn.Disable() DousedEmber.Enable() BurningEmber.Disable() EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
PeterMartyr Posted February 7, 2017 Share Posted February 7, 2017 (edited) Scriptname RE_CookingPotScript extends ObjectReference ObjectReference Property BurningEmber Auto ObjectReference Property DousedEmber Auto ObjectReference Property FireLight Auto ObjectReference Property CookingPotOn Auto ObjectReference Property CookingPotOff Auto Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() If BurningEmber.IsDisabled() BurningEmber.Enable() DousedEmber.Disable() CookingPotOn.Enable() CookingPotOff.Disable() FireLight.Enable() Else FireLight.Disable() CookingPotOff.Enable() CookingPotOn.Disable() DousedEmber.Enable() BurningEmber.Disable() EndIf EndIf EndEvent @ Steve40 I try to write codes, that are has simple & to the point as yours. On reading it all I could think of was, don't use IsEnabled(), it's a function, use IsDisabled() or !IsDisabled() instead. Do you have any idea how long it take me to work stuff like that out, even though I know it? Yes I'm jealous. :laugh: Edited February 7, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
Rayek Posted February 9, 2017 Author Share Posted February 9, 2017 Thanks to steve40 as well. Link to comment Share on other sites More sharing options...
Lisselli Posted February 9, 2017 Share Posted February 9, 2017 Scriptname RE_CookingPotScript extends ObjectReference ObjectReference Property BurningEmber Auto ObjectReference Property DousedEmber Auto ObjectReference Property FireLight Auto ObjectReference Property CookingPotOn Auto ObjectReference Property CookingPotOff Auto Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() If BurningEmber.IsDisabled() BurningEmber.Enable() DousedEmber.Disable() CookingPotOn.Enable() CookingPotOff.Disable() FireLight.Enable() Else FireLight.Disable() CookingPotOff.Enable() CookingPotOn.Disable() DousedEmber.Enable() BurningEmber.Disable() EndIf EndIf EndEvent @ Steve40 I try to write codes, that are has simple & to the point as yours. On reading it all I could think of was, don't use IsEnabled(), it's a function, use IsDisabled() or !IsDisabled() instead. Do you have any idea how long it take me to work stuff like that out, even though I know it? Yes I'm jealous. :laugh: The difference between the two is that isDisabled is a native function and is faster than isEnabled(which just calls IsDisabled()). Indeed, always go with the native function where possible. I bang my head on the desk everytime someone uses GetActorRef. Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted February 9, 2017 Share Posted February 9, 2017 (edited) Myself I'd use parent and child done in the render window.Use 1 xMarker and all your items you want disabled or enabled you set the xMarker as the parent.Since you can set children to opposite states of the parent it works fast. Then with your activator you set a linked ref to the xmarker.In your activator script you can use GetLinkedRef() to query the state of the xmarker. No properties needed at all, as less properties is less save bloat.Also your script is faster over all since it only disables or enables 1 item. Scriptname RE_CookingPotScript extends ObjectReference ObjectReference xMarker Actor Player Event OnInit() Player = Game.GetPlayer() xMarker = Self.GetLinkedRef() EndEvent Event OnActivate(ObjectReference akActionRef) If akActionRef == Player If xMarker.IsDisabled() xMarker.Enable() Else xMarker.Disable() EndIf EndIf EndEvent Edited February 9, 2017 by sLoPpYdOtBiGhOlE Link to comment Share on other sites More sharing options...
Masterofnet Posted February 9, 2017 Share Posted February 9, 2017 (edited) Yes, When enabling or disabling several object-references using an xmarker is the way to go. In this case you could use one of the object references as the enable parent of the others. Also if I were checking multiple items enabled state I would use a bool. Unless they were linked as you are suggesting. Why are you using OnInit? Scriptname RE_CookingPot extends ObjectReference Event OnActivate(ObjectReference A) If A == Game.GetPlayer() Else Return EndIf ObjectReference x = GetLinkedRef() If x.IsDisabled() x.Enable() Return EndIf x.Disable() EndEvent Edited February 9, 2017 by Masterofnet Link to comment Share on other sites More sharing options...
Recommended Posts