Jump to content

Need help with an activator script


TheRealNachoNinjaGnome

Recommended Posts

Howdy all,

 

I'm just getting back into modding with Fallout and Elder Scrolls games and am trying to learn whatever programming language this is they use in their scripts. I'm currently trying to figure out how to make a radio in FO3 that can change stations, but all the activators have that function built into their edit window, thus circumventing the display of the command used in a script. Is there anyone around who might be able to tell me how I can view the game's source code so that I can study that? I think that would be infinitely helpful. Barring that, does anyone know the command I'm looking for to produce this particular function?

Link to comment
Share on other sites

Well first thing to mention is , when attaching a script to an activator object ... it disables the normal default activation call it is hard coded with. So with any script attachment , you must put a line of "Activate" within the script , for it to then proceed to its normal activation. Like this.

 

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

Begin OnActivate

 

; Do something here

Activate

 

End

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

 

For changing radio stations on an object , the only way to do that looks to be with an NPC acting like a radio.

So the easy way in my thinking would be to just have multiple radio's stacked upon each other , each assigned to a radio station on their Base Object window , with only 1 Ref at a time enabled , all of them flagged on their Ref window as ...

Persistent Reference

Initially disabled

On By Default

... except the first one that would start out enabled and Off by default , only flagged as Persistent Reference.

 

And the easiest way I can think to have more than 2 radio stations would be with a "ShowMessage" in the scripts bringing up button choices , then utilizing this function ...

https://geckwiki.com/index.php/GetButtonPressed

 

So in their script example there at the lines of ... ; choice 1 , choice 2 , choice 3

 

You would put in something like this for the Off button ...

 

RadioOffRef.Enable

RadioGnrRef.Disable

RadioEncRef.Disable

RadioCustomRef.Disable

 

Then something like this for the GNR button ...

 

RadioGnrRef.Enable

RadioOffRef.Disable

RadioEncRef.Disable

RadioCustomRef.Disable

 

And so on with each button ...

 

You can get more tricky with it , making it play animations , but that is just the basics as I see it to get you started.

Hope that helps.

Link to comment
Share on other sites

Lol... I literally just figured it out for myself last night before taking a break and, subsequently, going to bed. Was just coming back on here to post my own solution, which is, pretty much, the same solution you posted. Had I noticed that your reply was here, I could have saved myself a couple of hours. *Sigh* Ah well... can't monitor the forums all hours of every day. :p Thanks for the response though.

Link to comment
Share on other sites

Now, with my code, I just used the multiple radios and a simple "cycling" series of the disable, enable and activate functions. In a previous mod (made years ago), that I can't seem to open anymore to reference what I had done, I DID do the whole message with options to switch on or off and select which station to change it to. I could not, however, figure out how to do this without declaration of new global variables for the radio, which seems a bit unnecessary. Is there a function that can reference the refID from the Message Dialog Box without having to declare a global variable?

Link to comment
Share on other sites

Not sure what you mean about the refID from the message dialogue box.

 

A message has a form ID which is neither a base form nor a Reference form. And the buttons have indices starting at 0.

Variables cannot be stored in a message form , nor can a message hold a script. It can just hold script like conditions , which turn the buttons on or off to be shown with a "ShowMessage" call.

 

So if variables are needed , you must store them in a script which could be on all the radio's or one of the radio's.

Or in a quest script that would act like a global for all the radio's.

Or a global , which imo , is the easier method. Because then you don't need to make an object to hold the script that declares and stores the value of the variable.

 

So to answer your question about is there a function to get a variable external to a script , which is not a global.

2 functions do this ...

GetQuestVariable http://geck.bethsoft.com/index.php?title=GetQuestVariable

&

GetScriptVariable http://geck.bethsoft.com/index.php?title=GetScriptVariable

 

But both of those require more set up than a global.

 

On a side note , not that it is easier , just more options.

You could use a Perk >Entrypoint>OnActivate ... to give a built in second choice at activation.

Which if wanting more than just changing between 2 stations. Could have that second choice bring up button messages.

And then leaving the regular activation of turning on/off in place.

 

And yet one more option , could be to have it bring up a terminal ... which you can do lots of things there.

 

Add edit : I guess nevermind the terminal if need be done without an actual terminal activator.

For some reason I thought there was a way to bring up a sub terminal that has no world model .

But looks like there is no function for it.

Dang , there goes my idea I had for one of my mods.

 

However I would like to say , I have used invisible activators placed in front of objects.

And you can make them fairly small , so that you can have multiple ones for different OnActivate calls.

Link to comment
Share on other sites

What I was trying to ask, in less words, was... is there a function, in the Item Conditions that can check to see if an instance of an object is activated without making a global variable that keeps track of whether the radio is on or off, or to check what station it is on without another global variable keeping track of that? Basically, if I was going to go through the whole message box for the radio, I would want the "Turn On" button to not show when it is on and the "Turn Off" button to not show when it is off. Additionally, I would like to remove the option for the station it is currently on. The only way I know how to do this is with Global or Quest variables, though I am not yet well versed in Quests or Quest Variables, so yeah, Global Variables seems like it would be easier.

 

And I have thought about using a terminal to control a sort of PA system that would play radios throughout a house. But, I would also need to use Global Variables there to keep track of which speakers are on and what station they are playing so that I could add and remove options as needed. It just looks much cleaner when you don't have that "Turn On" option when it's on.

Link to comment
Share on other sites

Oic ... you want a script command to check if the radio is on/off ... and it appears there is not one for those like there is for doors of "GetOpenState"

 

Although I thought there was something not mentioned in the regular functions for checking flags or the init state.

I wouldn't know where to find that. But you would be checking for the flag on the Ref-ID of "On by Default"

Or some how its current state ???

 

And to tell what station is playing ... since each radio only plays one station ... you just check which one is enabled with the function of "GetDisabled" Therefore ...

Getdisabled != 1 ... means it is enabled .

 

But still this is why I mentioned having 1 radio to represent the radio in it's off state , and I guess I forgot to mention , it having no radio station. And when the radio (activator) has a script attached , then no call in the script of "Activate"

It will not turn on or off , never changing the state you set it in the editor. It just becomes disabled or enabled.

Therefore the On/Off buttons in the message do not actually change the state of any one activator.

However ... if you want the sound and activation to play , then in the scripts you pop in and fade out , a special radio for that purpose with an activate call.

Err at least I think that would work.

 

Let me know what you think and your direction your wanting ... plus the terminal if you want to go that route.

Then I'll run some testing myself to smooth it out and dial it in. Cuz so far I'm just giving advice from past experience , and some hands on will help that out. But does need fairly good clarity from you , to be of better use.

Link to comment
Share on other sites

I don't know why I didn't think of the GetDisabled function... pfft. That will definitely work for keeping track of the station considering I'm using different radios for each station.

 

Going the terminal route, I'm pretty sure I have everything I need to get that working.

 

And yeah, the station-less radio is what I have for now, but it just cycles through each possible state with each activation. It's for that "dummy radio" method that I would need to check to see if it is active if I used the messages to allow players to choose what they wanted to do, rather than just activate it until it reaches the desired state. But, if there is no function to check an object's activation, then a global variable it will have to be.

 

Also, I DO use an Activate function for the "dummy radio" as when you turn it on, it lights up. I then activate it again at the end of the cycle so it isn't lit up when nothing is playing.

Here's the script I have for the cycling radio:

 

 

scn aaaStationChangeScript
int State
int DoOnce
Begin OnActivate
set State to State +1
If State == 1
StationChangeREFActivator.activate
StationChangeREFGalaxy.enable
StationChangeREFGalaxy.activate
ElseIf State == 2
StationChangeREFGalaxy.activate
StationChangeREFGalaxy.disable
StationChangeREFEnclave.enable
StationChangeREFEnclave.activate
ElseIf State == 3
StationChangeREFEnclave.activate
StationChangeREFEnclave.disable
StationChangeREFAgatha.enable
StationChangeREFAgatha.activate
ElseIf State == 4
StationChangeREFAgatha.activate
StationChangeREFAgatha.disable
StationChangeREFActivator.activate
set State to 0
EndIf
End

 

I toyed around with other methods of activating the "station radios" because the attached "STARTON" scripts don't run for disabled objects OnLoad, nor do they run when you enable the radios, so I had to activate them upon enabling them. I'm sure there's another way to do it, but this just seemed easier than doing any more testing.

Link to comment
Share on other sites

I don't know why I didn't think of the GetDisabled function... pfft. That will definitely work for keeping track of the station considering I'm using different radios for each station.

 

It's because it is counter intuitive with checking if it is disabled instead of enabled ... no worries it's not just you.

But logically , there is no reason to have an opposite check since the comparison of != exists , and checking disabled would yield a smaller list than enabled.

 

Going the terminal route, I'm pretty sure I have everything I need to get that working.

 

Cool :wink:

 

And yeah, the station-less radio is what I have for now, but it just cycles through each possible state with each activation. It's for that "dummy radio" method that I would need to check to see if it is active if I used the messages to allow players to choose what they wanted to do, rather than just activate it until it reaches the desired state. But, if there is no function to check an object's activation, then a global variable it will have to be.

 

If that method is yielding the desired result at least within acceptable parameters , and the work is done. No reason not to go with that.

Plus it makes sense with only one player input , to just cycle the on , then stations , then off.

 

Also, I DO use an Activate function for the "dummy radio" as when you turn it on, it lights up. I then activate it again at the end of the cycle so it isn't lit up when nothing is playing.

 

Just a mention for future use , but there is no problems with how you did it.

When a script is attached to an object , it becomes an implicit reference in the scripting , therefore no need to use it's ID in the script with a command. In this case simply "Activate" will do the same thing.

 

Here's the script I have for the cycling radio:

 

I made some suggestive changes to your script. Notably a playsound call , but also removed unnecessary code imo , and then will explain below your last comment portion.

 

 

scn aaaStationChangeScript
int State
;int DoOnce ; this appears to not be used
Begin OnActivate
set State to State +1 ; I like this method , don't know why I didn't think about originally
If State == 1
Activate ; lights up dummy radio
StationChangeREFGalaxy.enable
PlaySound OBJRadioKnobTurnOn ; this plays a sound like changing the station
ElseIf State == 2
StationChangeREFGalaxy.disable 1 ; this flag will fade out the station to help the change station imo
StationChangeREFEnclave.enable ; with no flag here the default is fade in , just a mention
PlaySound OBJRadioKnobTurnOn
ElseIf State == 3
StationChangeREFEnclave.disable 1
StationChangeREFAgatha.enable
PlaySound OBJRadioKnobTurnOn
ElseIf State == 4
StationChangeREFAgatha.disable
Activate ; turns off dummy radio lights
set State to 0
EndIf
End

 

I toyed around with other methods of activating the "station radios" because the attached "STARTON" scripts don't run for disabled objects OnLoad, nor do they run when you enable the radios, so I had to activate them upon enabling them. I'm sure there's another way to do it, but this just seemed easier than doing any more testing.

 

You mean this script "scn VintageRadioStartOnSCRIPT" ? Just remove that script from the drop downs , and flag the ref's as "On By Default" They work fine that way , at least in my testing. Also it's worth mentioning I think ... that flag does not show on the Reference window , unless the base ID has a radio station selected. Otherwise it just shows as "Open by default" which I did test , and does toggle the light on/off for the dummy radio.

 

Also something to mention from my testing in case you're not doing it. Leaving the dummy radio full size , then shrink all the other radio's that have the stations to .4 on the "Scale" field of the Reference window. That way their antenna do not stick through the top of the dummy radio box. And safely hidden to never cause texture flashing or their activate mouse over to possibly show up.

 

But to sum up all that , my point was to just help clarify your understandings for future use.

If it's working how you want it , I wholeheartedly agree to just roll with it. Since mods are usually a conglomeration of many compromises we have made through multiple test and fix. So ya gots to draw the line some where :whistling: before you end up :wacko:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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