Jump to content

Need Help with Lightswitch Script


Artecus

Recommended Posts

So, I'm trying to add a light switch script to my mod on the Nexus.

 

I already tried getting this script to work in the normal GECK and NVSE GECK.

And I really want a real person to help me with this, not GECK PowerUp.

 

(Just so you guys know this is what I was using.

)

 

So this script would go on the yellow light switch item that is in the game, but under a different editor ID of course.

I made Persistent REF ids for each light effect in the interior (which you will see in the script).

When I try to save this script, it says "Do you want to save the Current Script? Current = ForestHutInteriorLightScript" and it gives me "Yes or No". When I click "Yes" I just get sent back to the script (can't exit script editor with script saved).

 

 

ScriptName ForestHutInteriorLightScript

Short LightsOn

Begin OnActivate

If LightsOn != 1

ForestHutLight01REF.Enable
ForestHutLight02REF.Enable
ForestHutLight03REF.Enable
ForestHutLight04REF.Enable
ForestHutLight05REF.Enable
ForestHutLight06REF.Enable
ForestHutLight07REF.Enable
ForestHutLight08REF.Enable
ForestHutLight09REF.Enable
ForestHutLight10REF.Enable
ForestHutLight11REF.Enable
ForestHutLight12REF.Enable
ElseIf LightsOn == 1
ForestHutLight01REF.Disable
ForestHutLight02REF.Disable
ForestHutLight03REF.Disable
ForestHutLight04REF.Disable
ForestHutLight05REF.Disable
ForestHutLight06REF.Disable
ForestHutLight07REF.Disable
ForestHutLight08REF.Disable
ForestHutLight09REF.Disable
ForestHutLight10REF.Disable
ForestHutLight11REF.Disable
ForestHutLight12REF.Disable
Set LightsOn to 0
Return
EndIf

End

 

 

What am I doing wrong? Should the references not be persistent ids? Am I too much of an amateur to understand proper script language? Please, if anyone has even the slightest of info, I need it. I've been almost pulling my hair out over this one script.

Edited by Artecus
Link to comment
Share on other sites

Here is what I'm using in a mod for an activator to act as the on off switch.

This is so you can use the same activator twice ... instead of 2 activators , with one disabling itself , then enabling the second.

 

Light objects themselves are not objects that can be made to show the mouse over activate (pressing E key)

 

~~~~~~~~~~~~

 

Scn UmBathLampScript
Short On
Begin OnActivate Player
If On == 0
WcellHouseBathLighting01ref.enable ; this is the ref-id of your light object
Set On to 1
elseIf On == 1
WcellHouseBathLighting01ref.disable
Set On to 0
endif
End
Edited by Mktavish
Link to comment
Share on other sites

At a glance, I can't see anything wrong with the original script. I'm not sure if there's any benefit to using return at the end of an OnActivate block, but I doubt it would hurt anything.

 

One thing I did notice is that without setting 'lightson' to one at the end of the first if, you won't be able to run the second if to turn them off. That won't make it fail to compile though.

 

My best guess is that there's a typo somewhere in there, possibly a misspelling on one of the refIDs (maybe even when you named one of the light refs itself, because they all look to be the same in the script.

 

I know you don't want to hear it, but GECK PU would be able to point you straight to the line the problem is on and either save you the time it takes to ask for help, or at least let you know what part is keeping it from compiling.

 

On a little bit of a tangent, while I can verify that MkT's example will work properly, I've since started doubting 'OnActivate Player''s ability to keep the block from running when activated by an NPC. Using 'if isactionref player == 1' in a normal OnActivate block is much more effective.

Edited by uhmattbravo
Link to comment
Share on other sites

At a glance, I can't see anything wrong with the original script. I'm not sure if there's any benefit to using return at the end of an OnActivate block, but I doubt it would hurt anything.

 

One thing I did notice is that without setting 'lightson' to one at the end of the first if, you won't be able to run the second if to turn them off. That won't make it fail to compile though.

 

My best guess is that there's a typo somewhere in there, possibly a misspelling on one of the refIDs (maybe even when you named one of the light refs itself, because they all look to be the same in the script.

 

I know you don't want to hear it, but GECK PU would be able to point you straight to the line the problem is on and either save you the time it takes to ask for help, or at least let you know what part is keeping it from compiling.

 

On a little bit of a tangent, while I can verify that MkT's example will work properly, I've since started doubting 'OnActivate Player''s ability to keep the block from running when activated by an NPC. Using 'if isactionref player == 1' in a normal OnActivate block is much more effective.

I rarely misspell things without noticing, and by rarely I mean maybe once every 4 months. But goddamnit, I had to mispell something on something like this. One of the REF's for the actual lights was "ForetHutLight04REF" instead of "ForestHutLight04REF". That'll teach me to make long REF id's that's for sure. Man, I hope it didn't take you a while to write that post. Thank you both; Mktavish, I'll be sure to keep that script in mind.

 

But, if you guys still want to help, I need to somehow make the static light "sources" appear off. Any ideas on where to start?

Edited by Artecus
Link to comment
Share on other sites

Uh Oh ... I been busted ... The script I posted is uhmattbravo's content. For a mod he helped me out with.

Specifically so I didn't have to use two activators ... disabling one and enabling another.

So if it seems odd to you Um ...uh ... don't know what to tell ya.

Edited by Mktavish
Link to comment
Share on other sites

I'm not sure if there's any benefit to using return at the end of an OnActivate block, but I doubt it would hurt anything.

 

 

On the contrary ... I think a Return could jack up an "OnActivate" block

 

The block is designed to only run once ... that seems it could put a hang in the execution ?

Link to comment
Share on other sites

@Artecus

 

That's probably a bit more complicated and likely will require a bit of Nifskope work. The lazy method would be to open the mesh in Nifskope, find the material property for the glowing part, set it's emmisive value to 0, save it as a new file, add it as a static in game, place one at each of the light refs, give all the light refs unique RefIDs and add them in to enable/disable where appropriate in the script.

 

Pixelhate made an excellent tutorial on material and texture animation that I think (read: I only skimmed through enough to make animated textures because I'm lazy) covers a better way to do it:

 

https://www.nexusmods.com/fallout3/mods/20383/?

 

As a warning, I consider it an advanced topic, but the guide is well written and thorough enough that anyone (with a better attention span than me) should be able to follow it enough to make something cool.

 

 

@MkT

 

TBH I've probably only ever used return in a MenuMode block for message boxes, so I can't say for sure how it behaves in an OnActivate, now that I think about it.

Edited by uhmattbravo
Link to comment
Share on other sites

Gonna get rid of "return", the switch could be activated but the lights remained on. I'll edit this with an update

Also I think for turning the actual light "sources" off I could probably just enable "opposite of parent" or something like that... but yeah, like I said I'll get back to you

 

Getting rid of "return" did nothing. Since my mod isn't exactly popular I'll just wait until I feel like it and then test your script, Mktavish.

Edited by Artecus
Link to comment
Share on other sites

Seems I remember not being able to save a script , even though I knew it worked , because I just copy pasted it from something else. Until I installed Geck power up.

 

The only difference beside that return and "Player" added to the OnActivate ... between the 2 scripts.

Is where you use "If LightsOn != 1" instead of "== 0"

Which there may be an issue of "!=" having a problem because it needs a non zero value ... ^shrug^

 

However I wouldn't think that would cause a problem in saving the script.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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