Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting an on/off radio
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#11
RE: Scripting an on/off radio

(05-04-2013, 08:36 PM)Mr Credits Wrote: Wouldn't it also be necessary to increment/decrement the Radio variable in the case that the radio sound was to be toggled? Unless I had misinterpreted and this is not what the OP specified.

Yyy, you're right Big Grin
In the case of the code above, it would be:

PHP Code: (Select All)
if(GetLocalVarInt("Radio") == 0)   // 0 means "currently off" - so turn it on
{
    
PlaySoundAtEntity("id.sound.radio""radio.snt""radioarea"0.0false);  // 0.0 - fade in time
    
SetLocalVarInt("Radio"1);   // set it to "currently on"

else  
// local var "Radio" is 1, that is: "currently on" - so turn it off
{
    
StopSound("id.sound.radio"0.5f); //Change 0.5f to how long you want the sound to fade out.
    
SetLocalVarInt("Radio"0);   // set it to "currently off"


Also, the way the code is setup, it should start with:
PHP Code: (Select All)
void OnStart()
{
    
SetLocalVarInt("Radio"0);   // 0 instead of 1
    // etc... 
(This post was last modified: 05-04-2013, 10:13 PM by TheGreatCthulhu.)
05-04-2013, 10:11 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#12
RE: Scripting an on/off radio

(05-04-2013, 11:37 AM)TheGreatCthulhu Wrote: there's really no way for the script to detect a click on an inventory item. So, I guess you'd have to work something out using those.
That's what i didn't want to hear.
I just wanted the player to use the cellphone to stop the music.
I'm not giving up, i'm having it done somehow. hehe.

05-04-2013, 10:56 PM
Find
Kalidus Offline
Junior Member

Posts: 5
Threads: 1
Joined: Apr 2013
Reputation: 0
#13
RE: Scripting an on/off radio

(05-04-2013, 10:11 PM)TheGreatCthulhu Wrote:
(05-04-2013, 08:36 PM)Mr Credits Wrote: Wouldn't it also be necessary to increment/decrement the Radio variable in the case that the radio sound was to be toggled? Unless I had misinterpreted and this is not what the OP specified.

Yyy, you're right Big Grin
In the case of the code above, it would be:

PHP Code: (Select All)
if(GetLocalVarInt("Radio") == 0)   // 0 means "currently off" - so turn it on
{
    
PlaySoundAtEntity("id.sound.radio""radio.snt""radioarea"0.0false);  // 0.0 - fade in time
    
SetLocalVarInt("Radio"1);   // set it to "currently on"

else  
// local var "Radio" is 1, that is: "currently on" - so turn it off
{
    
StopSound("id.sound.radio"0.5f); //Change 0.5f to how long you want the sound to fade out.
    
SetLocalVarInt("Radio"0);   // set it to "currently off"


Also, the way the code is setup, it should start with:
PHP Code: (Select All)
void OnStart()
{
    
SetLocalVarInt("Radio"0);   // 0 instead of 1
    // etc... 

Awesome, that last code did the trick and it now works as intended! Big Grin

Thanks a lot guys, you will get a place in the credits at the end of my mod. Smile
05-04-2013, 10:57 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#14
RE: Scripting an on/off radio

@Amn: You know what you could try? You could create one huge script area that encompasses entire level, and then add a use item callback on that - if it's possible to do when you're standing inside the script area itself (didn't test). The player experience would be: use the cellphone to interact with "the air". If it's possible, than it would work out rather nicely, for what you want to do, I think.
05-04-2013, 11:59 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#15
RE: Scripting an on/off radio

(05-04-2013, 11:59 PM)TheGreatCthulhu Wrote: @Amn: You know what you could try? You could create one huge script area that encompasses entire level, and then add a use item callback on that - if it's possible to do when you're standing inside the script area itself (didn't test). The player experience would be: use the cellphone to interact with "the air". If it's possible, than it would work out rather nicely, for what you want to do, I think.

Good idea. But even if that worked, how could the player still interact with other things having that permanent area around?
I'll test it out in a sec.

edit2: didn't work very well. You can use the item "with the air" but in this area you can't pick up items or interact with things. So, not good. But i won't give up.

(This post was last modified: 05-05-2013, 05:53 AM by Daemian.)
05-05-2013, 05:10 AM
Find




Users browsing this thread: 3 Guest(s)