Jump to content

Recommended Posts

Posted

So, I set up a scene that has the player interact with a phone, then a 3 second delay happens and it plays a sound of a phone ringing, how can I set up so that the player uses the phone again and it stops the ringing and play another sound?

 

 

This is the flowgraph right now

 

post-13811-0-60758900-1422801493_thumb.png

 

This is the phone script

 

Script.ObjectDescription = "" --String "Object Description"
Script.DisplayTimeMax = 5000 --Int "Display time"
Script.Used = "0"
Script.DisplayTime = 0
Script.DisplayEnabled = false
local font1 = Font:Load("Fonts/True Lies.ttf", 20)
function Script:Use(context)
  self.Used = "1"
  self.CurrentTime = Time:GetCurrent()
  self.DisplayTime = Time:GetCurrent() + self.DisplayTimeMax
  self.component:CallOutputs("Use")  
end

function Script:PostRender(context)
  if self.Used == "1" then
	  App.context:SetBlendMode(Blend.Alpha)
	  App.context:SetFont(font1)
	  self.DisplayEnabled = true
			   if self.DisplayEnabled == true then
						    if self.DisplayTime > Time:GetCurrent() then
									 App.context:SetColor(255,255,255)
									 context:DrawText(self.ObjectDescription, 100, 600)
							 else
									 self.DisplayEnabled = false
									 self.Used = "0"
							 end
					   end
					   App.context:SetBlendMode(Blend.Solid)
			   end
end

 

The trigger delay and the noise script are the same with different properties.

 

So how can I pull this off? :P

Posted

hmm would say ringing need a

function Script:Stop() --in

 

then drag from phone to stop at use.

 

but why u not use one script for the phone?

PC : Win 10 Pro 64 Bit , 4x cores ~2 GHz , 8 GB RAM , AMD R7 265

2D : Photoline , Zooner Photo Studio 13 , Art Rage Studio 3.5.4 , Ashampoo Snap 7 , ...

3D : Shade 15 Basic , Carrara 8.5 & DAZ Studio 4.8 , Cheetah 3D 6.3.2 , Via Cad 8

Music : Samplitude Music Studio , Music Creator 7

IDE : Leadwerks Engine 3.x , Unity 5.x , (Unreal 4.8.x) , AGK v2.x , Construct 2 , (Clickteam Fusion 2.5) , ShiVa 1.9 , Game Maker Studio , MS Visual Studio .Net , Android Studio , Monkey , ...

Posted

hmm would say ringing need a

function Script:Stop() --in

 

then drag from phone to stop at use.

 

but why u not use one script for the phone?

 

I'm having a tough time understanding what you mean by this, I'm really bad at scripting, would you mind being a little bit more clear?

Posted

I have a modified sound script that stops when it is linked in the flow graph idk if this is help to you.

 

Script.soundfile=""--path "File" "Waveform Audio File Format (*.wav):wav|Sound"

Script.playing=true--bool "Playing"

Script.enabled=true--bool "Enabled"

Script.range=50--float "Range"

Script.volume=100--int "Volume"

Script.pitch=1.0--float "Pitch"

Script.loop=true--bool "Loop"

Script.volume1=0

 

function Script:Start()

self.source = Source:Create()

self.source:SetVolume(self.volume/100)

self.source:SetPitch(self.pitch)

self.source:SetLoopMode(self.loop)

self.source:SetRange(self.range)

self.source:SetPosition(self.entity:GetPosition(true))

local sound = Sound:Load(self.soundfile)

if sound~=nil then

self.source:SetSound(sound)

if self.playing==true and self.enabled==true then

self.source:Play()

end

sound:Release()

sound=nil

end

end

 

function Script:Play()--in

if self.enabled then

self.source:Play()

end

self.component:CallOutputs("Play")

 

end

 

 

 

function Script:Enable()--in

self.enabled=true

if self.enabled then

self.source:Stop()

end

 

end

 

function Script:Disable()--in

self.enabled=false

if self.source then

self.source:Stop()

end

end

 

function Script:Pause()

self.source:Pause()

end

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...