Hi there.
I'm trying to create a feature where I can push the switch to disable some object and vice versa - when I turn it on, the object will appear again.
Any help would be appreciated.
Thanks.
A.
Help with a simple script
Started by
Andyno
, May 23 2011 06:42 AM
16 replies to this topic
#1
Posted 23 May 2011 - 06:42 AM
#2
Posted 23 May 2011 - 06:55 AM
Sounds like a light switch. See the sample scripts
#3
Posted 23 May 2011 - 07:39 AM
Thanks!
I'll try this right now...
#4
Posted 23 May 2011 - 11:16 AM
I did something wrong because the object disappear along with the switch...
#5
Posted 23 May 2011 - 12:18 PM
Well you did something right too! The glass is half-full 
It's sometimes hard spotting the silly mistakes and typo's in your own code.
Don't struggle alone for too long. Post the code here within [ code ] [ /code ] tags and explain your objects.
Someone here will normally put you right in no time.
It's sometimes hard spotting the silly mistakes and typo's in your own code.
Don't struggle alone for too long. Post the code here within [ code ] [ /code ] tags and explain your objects.
Someone here will normally put you right in no time.
#6
Posted 23 May 2011 - 01:45 PM
Are you using the GECK 1.3 Power Up utility? It can help you find errors in your code but it does look like the GECK saved your script but even at that if you are not yet using this tool it can save lots of poor emoticons from bruising their little heads on brick walls on future script errors 
http://www.newvegasn...le.php?id=41642
http://www.newvegasn...le.php?id=41642
#7
Posted 23 May 2011 - 02:40 PM
sounds like you made the object the switches enable parent.I did something wrong because the object disappear along with the switch
don't. :-)
object is, if any, a linked ref (NOT enable parent) to the switch (or you can give it a unique refname and call that explicitely in your script instead of a linked ref). and it has to be a persistant ref in any case.
if you want another object to appear when the first one disappears, make object 1 it's enable parent (set to opposite in this case)
Edited by stevie70, 23 May 2011 - 02:41 PM.
#8
Posted 23 May 2011 - 02:43 PM
there is one finally?Are you using the GECK 1.3 Power Up utility?
*joy* :-)
#9
Posted 23 May 2011 - 03:57 PM
Thanks for all the replies guys. 
I think it's time to describe everything I did before I get stuck even more.
I didn't want to do this because one of you may be the future player of my mod and that would spoil all the feature...
What I exactly need to be done is to make a switch that turns off the water leak - to be more specific the waterfall that leaks through the pipe.
So I placed the both objects (switch+waterfall) to my cell and set the following options:
For the waterfall I gave it a unique reference ID (pump) and checked the "Persistent Reference".
For the switch I checked "Open By Deafault", attached the script and connected it with the waterfall by the "Enable Parent" option.
Here's the script...
I think it's time to describe everything I did before I get stuck even more.
I didn't want to do this because one of you may be the future player of my mod and that would spoil all the feature...
What I exactly need to be done is to make a switch that turns off the water leak - to be more specific the waterfall that leaks through the pipe.
So I placed the both objects (switch+waterfall) to my cell and set the following options:
For the waterfall I gave it a unique reference ID (pump) and checked the "Persistent Reference".
For the switch I checked "Open By Deafault", attached the script and connected it with the waterfall by the "Enable Parent" option.
Here's the script...
ScriptName BLPumpScript ref pump Begin OnActivate if pump == 0 set pump to GetLinkedRef endif if pump.GetDisabled pump.Enable else pump.Disable endif Activate End
#10
Posted 23 May 2011 - 04:58 PM
man, did you actally _read_ my last post or just thanked for it unread...? :-)So I placed the both objects (switch+waterfall) to my cell and set the following options:
For the waterfall I gave it a unique reference ID (pump) and checked the "Persistent Reference".
For the switch I checked "Open By Deafault", attached the script and connected it with the waterfall by the "Enable Parent" option.
like i said, the switch does NOT have the pump as a enabling parent, but as a (like it _says_ in the GetLinkedRef-part of your script) linked reference.
and for the script,
ScriptName BLPumpScript ref pump Begin OnActivate if pump == 0 set pump to GetLinkedRef endifi assume pump == 0 means the pump is not there and 1 is there?
so what's the if for, you'll need the linked ref anyway to check it's state
wouldn't do anything anyway, because you ask if pump is a numeric value (0), but you have pump set as a reference variable, that returns a string (the id of the linked object)
and i don't know if it's a good idea to give a ref-variable ("pump") exactly the same name the reference it asks for has ("pump" as well).
most people seem to tend to call their object references like objectREF, not necessary, but makes orientation easier.
if pump.GetDisabled pump.Enable else pump.Disable endifi'm quite sure there'd be problems with your naming, because "pump" (see above) is the name of your variable AND of your object, so basically, pump.getdisabled asks for the value of whatever the linked ref is AND the object pump, wether it's linked or not, and i'm pretty sure that's not a good thing. :-)
so first, rename your object. call it pumpREF or Maurice or whatever.
and then, your script could go about like this
scn BLPumpSCRIPT
ref pump
begin OnActivate
set pump to GetLinkedRef ; your pump has to be LINKED REF to the switch for this , NOT enable parent !!!!!
if pump.GetDisabled == 1
pump.enable
setopenstate 1 ; this sets the switch to "on" (i prefer that to activate, which can produce weird results with the switch state's appearance)
elseif pump.GetDisabled == 0
pump.disable
setopenstate 0
endif
end
hope i have no typo in there, not geck-checkedor if you have your pump a persistent ref and called it like pumpREF, you wouldn't need any linked refs, enabling parents or anything and just go with
scn BLPumpSCRIPT
begin OnActivate
if pumpREF.GetDisabled == 1
pumpREF.enable
setopenstate 1
elseif pumpREF.GetDisabled == 0
pumpREF.disable
setopenstate 0
endif
end
which is a bit shorter and doesn't require any linking of any stuff.



Sign In
Create Account
Back to top









