Jump to content

Best way to set up a lamp that you can switch on and off?


Arkngt

Recommended Posts

I've turned lamps from statics into pickable and placeable lights, which works fine. The way I've set them up is via a short script (stolen from Placeable Lamps) which switches between two lamps that are identical, except one of them emits light. The issue is that you actually notice the switching, which is a bit "immersion breaking" and the switching can also cause the lamp to overturn or fall in certain conditions.

 

When I check how Portable Camp Stuff is set up, I notice that it is using FOSE scripting, i.e. something like:

If ( rLight.GetDisabled )
				rLight.Enable
			Else
				rLight.Disable
 

So the switching on and off is instantaneous and the lamp is also stable as it's the same lamp. So my question is: can something similar be achieved without FOSE? I don't have anything against FOSE, quite the opposite, but I've never used FOSE scripting so I know next to nothing about it (not that I know that much more about regular scripting). In short: should I switch to FOSE scripting or can the same thing be achieved without it, and if so, how?

Edited by Arkngt
Link to comment
Share on other sites

  • 3 weeks later...

I'd be much obliged if someone knowledgeable with scripting would help me out with this. I've replaced all the static Vacuum Tube Lights and Railway Lamps with pickable and placeable ones that you can turn on and turn off - and now I've also disabled all fake light by them. For this I copied how it's done in Placeable Lights but tweaked the scripts etc. a bit. It works perfectly (and I actually think the lighting is more "realistic" when removing the "fake lights" and have "real" lamps instead), but it's basically set up so there are two different objects/meshes that are replaced via the script - one is the lamp when lit, one is the lamp when unlit - and it's a bit "immersion breaking" that you actually notice that the lamp nifs get switched when turned on and off. Also, when the lamps are placed a bit unstable, they can turn over in the process.

So I thought that I'd have a script that rather adds a light to the item when lit and removes the light when turned off, but how would I do this?
As it is the scripts for the Railway Lamps look like this:
scn lowllamp01turnon

short iButton
short iButtonPressed
ref rMySelf

Begin onactivate Player
        set rMySelf to GetSelf
        ShowMessage lowlightoff    
        set iButtonPressed to 1
end

Begin GameMode

        if iButtonPressed == 1
                set iButton to GetButtonPressed
                if iButton > -1
                        set iButtonPressed to 0
  if iButton == 0 ; Enable ?
                                rMySelf.disable
                                rMySelf.PlaceAtMe lowllamp01
                                rMySelf.markfordelete
                        elseif iButton == 1     ;take ?
                                 rMySelf.disable
Player.Additem lowllamp01off 1
rMySelf.markfordelete
                         elseif iButton == 2     ;do nothing ?
endif
    endif
                endif
        endif

end

And

scn lowllamp01turnoff

short iButton
short iButtonPressed
ref rMySelf

Begin onactivate Player
        set rMySelf to GetSelf
        ShowMessage lowlighton  
        set iButtonPressed to 1
end

Begin GameMode

        if iButtonPressed == 1
                set iButton to GetButtonPressed
                if iButton > -1
                        set iButtonPressed to 0
  if iButton == 0 ;Disable  ?
                              rMySelf.disable
                              rMySelf.PlaceAtMe lowllamp01off              
                              rMySelf.markfordelete
                         elseif iButton == 1     ;take ?
rMySelf.disable
                                Player.Additem  lowllamp01off 1
rMySelf.markfordelete
                         elseif iButton == 2     ;do nothing ?
endif
    endif
                endif
        endif

end
Can I just create a light and then add it via a
rMySelf.PlaceAtMe lowllamplight
line? And how would I remove it when it's turned off? I guess it's (hopefully) rather simple, but I suck at scripting so I'm a bit lost on how to change the scripts so it works as I'd like. I'm also more than willing to use FOSE if it simplifies things.
Edited by Arkngt
Link to comment
Share on other sites

I don't know how your nif is build, but if the emit light is set inside the nif, there should be a way to make two sequences, one On, one Off and then trigger them by script.

(Probably a different approach)

 

Did you (or anyone else for that matter) have an idea about how this could be achieved?

 

EDIT: Nevermind, it was easily fixed by attaching a mesh with emitting light to the light (I checked how the lights are set up in Portable Camp Stuff FOSE).

Edited by Arkngt
Link to comment
Share on other sites

  • Recently Browsing   0 members

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