Agnot2006 Posted June 1, 2009 Share Posted June 1, 2009 Can anyone help with a quick script to turn a Radio on at about 10AM and off at Midnight? I am trying to make a mod where the space seems more occupied i.e. the NPCs turn off the radio when they go to sleep. Link to comment Share on other sites More sharing options...
Agnot2006 Posted June 2, 2009 Author Share Posted June 2, 2009 This is my idea to make put the radio in my cell off between midnight and 10am, I know it wont work like this.I am looking for help to make a script like this work please scn RadioOntimescript short RadioOn Begin GameModeIf RadioOn ==1 if GameHour <= 10 DeActivate ; I want to switch the radio off here Set RadioOn to 0 Else Activate ; I want to turn the radio on hereEndIfEnd Link to comment Share on other sites More sharing options...
BadPenney Posted June 2, 2009 Share Posted June 2, 2009 Do you want players to be able to turn the radio off and on too, or will it be only automatic and out of reach? Link to comment Share on other sites More sharing options...
Agnot2006 Posted June 2, 2009 Author Share Posted June 2, 2009 I think Automatic would be easier, but if the Player turned it off when it should be on - if the script just used activate everything would be reversed?Is there a way to tell if its on or not, then if the player activates it, a timer would revert it to what it should be? I dont know if its possible or easy. As I said just automatic would be fine if the other is a lot of work? Link to comment Share on other sites More sharing options...
BadPenney Posted June 2, 2009 Share Posted June 2, 2009 I tested this script and it worked for me. It is intended to work with a radio with which a player can interact, but would work without player interference as well. You will have to create a unique radio to attach it to, of course. I used a Vintage Radio with GNR. Should work with any station. scn 0001SSVintageRadioSCRIPT short IsOnshort initref mySelf ;********************************** Begin onLoad set mySelf to getSelfEnd ;********************************** Begin GameMode if ( GetCurrentTime < 6 ) set init to 0 elseif ( GetCurrentTime >= 6 ) set init to 1 endifEnd ;********************************** Begin GameMode if ( init == 1 ) && ( IsOn == 0 ) ; Automatic On @ 0600 Activate mySelf Set IsOn to 1 elseif ( init == 0 ) && ( IsOn == 1 ) ; Automatic Off @ 0000 Activate mySelf Set IsOn to 0 elseif ( init == 1 ) && ( IsOn == 2 ) ; Reset On schedule after player activate between 0000 - 0600 Set IsOn to 1 elseif ( init == 0 ) && ( IsOn == 3 ) ; Reset Off schedule after player activate between 0600 -0000 Set IsOn to 0 endifEnd ;********************************** Begin OnActivate if ( IsActionRef Player == 1 ) && ( init == 1 ) && ( IsOn == 1 ) Activate Set IsOn to 3 elseif ( IsActionRef Player == 1 ) && ( init == 0 ) && ( IsOn == 0 ) Activate Set IsOn to 2 elseif ( IsActionRef Player == 1 ) && ( init == 1 ) && ( IsOn == 3 ) Activate Set IsOn to 1 elseif ( IsActionRef Player == 1 ) && ( init == 0 ) && ( IsOn == 2 ) Activate Set IsOn to 0 endifEnd ;********************************** I think that I'll incorporate it into my own mod under a different scriptname if you don't mind. Let me know if it won't work for you. I didn't test it after adding the explanations behind semicolons. They shouldn't be a problem, but if the script doesn't work try removing them first. Cheers. EDIT: Oops, got the time wrong at first, changed it from 0600 to 1000 as per your schedule. Link to comment Share on other sites More sharing options...
BadPenney Posted June 3, 2009 Share Posted June 3, 2009 It occurred to me that my earlier script could still cause the play schedule to flip-flop if a player were to activate the radio more than once, so I modified the OnActivate portion to compensate for that. See above. Link to comment Share on other sites More sharing options...
Agnot2006 Posted June 3, 2009 Author Share Posted June 3, 2009 That looks absolutely fantastic. I will give it a go as soon as I get home.I just gone through the script and Is that the only change I need to make? Begin GameMode if ( GetCurrentTime < 10 )set init to 0elseif ( GetCurrentTime >= 9 )set init to 1endifEnd Thank You Link to comment Share on other sites More sharing options...
Agnot2006 Posted June 3, 2009 Author Share Posted June 3, 2009 I just had a thought for the future; we could use the init variable to enable AI packages so NPC’s could congregate around the radio etc. All things to make the NPC’s act more natural.Just thinking out loud. It could be used to increase a person’s sneak capability if the radio is on. If the player turned the radio on at night it could wake all the NPCs in the cell. There are a lot of possibilities. Link to comment Share on other sites More sharing options...
BadPenney Posted June 3, 2009 Share Posted June 3, 2009 if ( GetCurrentTime < 10 )set init to 0elseif ( GetCurrentTime >= 9 )set init to 1 The overlapping times in the above argument would cause a conflict. They should be the same number, in this case. As in: scn 0001SSVintageRadioSCRIPT short IsOnshort initref mySelf ;********************************** Begin onLoadset mySelf to getSelfEnd ;********************************** Begin GameMode if ( GetCurrentTime < 10 )set init to 0elseif ( GetCurrentTime >= 10 )set init to 1endifEnd ;********************************** Begin GameMode if ( init == 1 ) && ( IsOn == 0 ) ; Automatic On @ 1000Activate mySelfSet IsOn to 1elseif ( init == 0 ) && ( IsOn == 1 ) ; Automatic Off @ 0000Activate mySelfSet IsOn to 0elseif ( init == 1 ) && ( IsOn == 2 ) ; Reset On schedule after player activate between 0000 - 1000Set IsOn to 1elseif ( init == 0 ) && ( IsOn == 3 ) ; Reset Off schedule after player activate between 1000 - 0000Set IsOn to 0endifEnd ;********************************** Begin OnActivate if ( IsActionRef Player == 1 ) && ( init == 1 ) && ( IsOn == 1 )ActivateSet IsOn to 3elseif ( IsActionRef Player == 1 ) && ( init == 0 ) && ( IsOn == 0 )ActivateSet IsOn to 2elseif ( IsActionRef Player == 1 ) && ( init == 1 ) && ( IsOn == 3 )ActivateSet IsOn to 1elseif ( IsActionRef Player == 1 ) && ( init == 0 ) && ( IsOn == 2 )ActivateSet IsOn to 0endifEnd ;********************************** I thought that I had edited the times to work at 10, but apparently the edit didn't take for some reason. Trying to correct it again. If you copy and paste the script within the quotes then it should work. The "init" variable is just shorthand in this script to prevent the repetition of GetCurrentTime arguments for certain time periods. If you established an "init" sort of variable in a quest script then it would be easy to access as a GetQuestVariable condition if you chose to. Link to comment Share on other sites More sharing options...
Agnot2006 Posted June 3, 2009 Author Share Posted June 3, 2009 Thanks again, I wish I could get the hang of thisSo what would happen if the GetCurrentTime = 10 ? its not < or > ?I just realised it's >= sorry Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.