Jump to content

quick script to turn a Radio on ?


Agnot2006

Recommended Posts

Posted

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.

Posted

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 GameMode

If 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 here

EndIf

End

Posted
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?
Posted

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?

Posted

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 IsOn

short init

ref mySelf

 

;**********************************

 

Begin onLoad

set mySelf to getSelf

End

 

;**********************************

 

Begin GameMode

 

if ( GetCurrentTime < 6 )

set init to 0

elseif ( GetCurrentTime >= 6 )

set init to 1

endif

End

 

;**********************************

 

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

endif

End

 

;**********************************

 

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

endif

End

 

;**********************************

 

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.

Posted
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.
Posted

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 0

elseif ( GetCurrentTime >= 9 )

set init to 1

endif

End

 

Thank You

Posted

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.

Posted
if ( GetCurrentTime < 10 )

set init to 0

elseif ( 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 IsOn

short init

ref mySelf

 

;**********************************

 

Begin onLoad

set mySelf to getSelf

End

 

;**********************************

 

Begin GameMode

 

if ( GetCurrentTime < 10 )

set init to 0

elseif ( GetCurrentTime >= 10 )

set init to 1

endif

End

 

;**********************************

 

Begin GameMode

 

if ( init == 1 ) && ( IsOn == 0 ) ; Automatic On @ 1000

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 - 1000

Set IsOn to 1

elseif ( init == 0 ) && ( IsOn == 3 ) ; Reset Off schedule after player activate between 1000 - 0000

Set IsOn to 0

endif

End

 

;**********************************

 

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

endif

End

 

;**********************************

 

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.

Posted

Thanks again, I wish I could get the hang of this

So what would happen if the GetCurrentTime = 10 ? its not < or > ?

I just realised it's >= sorry

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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