Jump to content



Photo
- - - - -

Script Guide ?


  • Please log in to reply
20 replies to this topic

#1 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 20 April 2015 - 03:39 PM

There is a Guide for Objects ( http://www.vpforums....ettings8_1.html ),
is there anything for Scripting also ?
 
I mean where i can follow what is, example, Ball.X or Parameters for PlaySound ... and and ...

#2 hmueck

hmueck

    MaX

  • VIP
  • 2,190 posts
  • Location:Hamburg

  • Flag: ---------

  • Favorite Pinball: IPDB Top 300



Contributor

Posted 20 April 2015 - 04:16 PM

You mean something like the vbsdoc.html in your Visual Pinball\Tables folder?

Or the VPinball.chm in the Visual Pinball\docs folder?

For "playsound" i only found the CommandReference.txt in the Visual Pinball folder.


VPX0beta tables: 29cff786951ed9c1a70fc1fa47f5e3c1.png 0cecd68ffa2537a7262337834a05bbbe.png Finish them if you like!

#3 allknowing2012

allknowing2012

    Pinball Fan

  • Members
  • PipPipPipPip
  • 1,948 posts
  • Location:Waterloo, ON

  • Flag: Canada

  • Favorite Pinball: bucaneer

Contributor

Posted 20 April 2015 - 04:44 PM

I usually just google and it comes to places like 

http://www.armuco.ch...ml/VPEditor.htm

 

But it seems some code like, playsound, which appear to have been tweaked in the 9.x versions, the only docs I could find were the readme notes.

 

for example 9.2.0 readme:

- add additional (optional) parameters to PlaySound to set the pan and/or randomize the pitch of the played sound effect: Instead of PlaySound "name",loopcount,volume one can now use PlaySound "name",loopcount,volume,pan,randompitch
pan ranges from -1.0 (left) over 0.0 (both) to 1.0 (right)


* I don't know everything - I just have no life *
testimageNL

 

 

 

#4 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 20 April 2015 - 05:06 PM

Thanks for the Infos. All about the Editor is ok for me.

 

Exactly what i want for now is (in Script only):

 

PlaySound "Name",1,x = Volume, x  between 0 and 1 ?

Parameter X:

is Ball.X the curr. Position of Ball at Pixel X on Playfield ?

or

VelX ... ? Whats max. and whats min. ?

No ? How can i read the Ball X/Y Position ? (50% solved)

 

There are no Docs about that or i cant find anything!


Edited by STAT, 20 April 2015 - 05:58 PM.


#5 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 20 April 2015 - 05:56 PM

And why doesnt this work everytime ?

Set BallPos = ActiveBall
Info.Text = BallPos.X

 

First yes, later "Error"

:throw:


Edited by STAT, 20 April 2015 - 05:57 PM.


#6 allknowing2012

allknowing2012

    Pinball Fan

  • Members
  • PipPipPipPip
  • 1,948 posts
  • Location:Waterloo, ON

  • Flag: Canada

  • Favorite Pinball: bucaneer

Contributor

Posted 20 April 2015 - 05:59 PM

Looking at the readme in the source code:

https://svn.code.sf....1/Changelog.txt

 

Playsound is a fraction of the recorded volume.

- add additional (optional) parameters to PlaySound to set the pan and/or randomize the pitch of the played sound effect: Instead of PlaySound "name",loopcount,volume one can now use PlaySound "name",loopcount,volume,pan,randompitch
pan ranges from -1.0 (left) over 0.0 (both) to 1.0 (right)
randompitch ranges from 0.0 (no randomization) to 1.0 (vary between half speed to double speed)
so f.e. PlaySound "FlipperUp",0,0.5,-1.0,1.0 would play the sound not looped (0), at half the volume (0.5), only on left speaker (-1.0), with varying pitch (1.0)
look at the built-in default table to get a feeling for the setup of these parameters

 

 

Ball.X is the x position - pixels .. so it should be no lower than 0 and no greater then tablewidth.

Sample code I see says this:

 
BallXPos = SoundBall.X
if BallXPos < 0 then BallXPos = 0 'boundary check
if BallXPos > TableWidth then BallXPos = Tablewidth
 

.Z is height - so if its greater than say 24, then its in the air since the ball is radius is 24.

 

I see this code in the ball rolling sounds demo code...


And why doesnt this work everytime ?

Set BallPos = ActiveBall
Info.Text = BallPos.X

 

First yes, later "Error"

:throw:

Any chance the activeball is gone/drained/destroyed?


* I don't know everything - I just have no life *
testimageNL

 

 

 

#7 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 20 April 2015 - 06:01 PM

Thanks allknowing, i had read this a bit before.

But as my Demo above, if i will always read the, example, X Pos from the Ball, that will not work



#8 allknowing2012

allknowing2012

    Pinball Fan

  • Members
  • PipPipPipPip
  • 1,948 posts
  • Location:Waterloo, ON

  • Flag: Canada

  • Favorite Pinball: bucaneer

Contributor

Posted 20 April 2015 - 06:38 PM

Attached is the ball rolling sounds demo table modified with 2 additional text boxes,  1 with the X pos, 1 with the Y pos and the existing one with the velocity.

 

Seems like it should work..

 

BallVel = SQR((SoundBall.velx^2) + (SoundBall.vely^2))  'calculating the speed vector within the X/Y plane only once per timer call
ScoreText.Text = cint(BallVel)
TextBox.Text = SoundBall.X
TextBox2.Text = SoundBall.Y

Attached Files


* I don't know everything - I just have no life *
testimageNL

 

 

 

#9 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 21 April 2015 - 05:08 AM

Thank you very much, all right now :tup:



#10 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 21 April 2015 - 03:47 PM

I am on some Sound Works now, sometimes or mostly, the StopSound "Blabla" dont work,
i can hear the Sound to the End ... (?)



#11 allknowing2012

allknowing2012

    Pinball Fan

  • Members
  • PipPipPipPip
  • 1,948 posts
  • Location:Waterloo, ON

  • Flag: Canada

  • Favorite Pinball: bucaneer

Contributor

Posted 21 April 2015 - 03:51 PM

I too have never had any success with the StopSound function.. 


* I don't know everything - I just have no life *
testimageNL

 

 

 

#12 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 22 April 2015 - 07:35 AM

That is very bad, i am working on a "Quick Ball Sound", and of course, should use StopSound also ...

I thought about a Volume Trick, but its not the right Way.

I do it write new for me, because i will learn more about the VP Scpripting, i think this is the Best Way ...

Yes, i know, there is a ready-to-use in Tutorials ... but i dont learn more with "Copy&paste" ;)

 

Can i change the Volume at a runing Sound, example End loud, beginning quiet ?


Edited by STAT, 22 April 2015 - 07:42 AM.


#13 Slydog43

Slydog43

    Pinball Wizard

  • Platinum Supporter
  • 3,008 posts
  • Location:Hackettstown, NJ

  • Flag: United States of America

  • Favorite Pinball: Addams Family, All Williams 90's Games

Posted 22 April 2015 - 11:40 AM

maybe stopsound should be placed in VP10 bugs?



#14 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 22 April 2015 - 12:48 PM

I thought it is avaiable at VP9 also (?) ... of course


Edited by STAT, 22 April 2015 - 12:48 PM.


#15 allknowing2012

allknowing2012

    Pinball Fan

  • Members
  • PipPipPipPip
  • 1,948 posts
  • Location:Waterloo, ON

  • Flag: Canada

  • Favorite Pinball: bucaneer

Contributor

Posted 22 April 2015 - 01:53 PM

The basic stopsound does work .. I reuploaded the above ball rolling sounds table. I added a buzz sound on the initialize. It stops when you press the left nudge. So it does indeed work.  So something causes it not to work correctly.

Can you modify the basic table with your sounds and some code to see if there is something in the coding? I know there is one table out there, cant recall which one, where the sound just plays and plays (loops) and it never stops until you stop the table. (there was a thread on that - perhaps with you & I?)

 

[update] may have found the bug .. if you call the playsound while its already playing,  you cant stop it. I tested by updating the right nudge to play the sound.

If I right nudge & play the sound while its already playing, I can no longer stop it.

 

So put a flag in the code that indicates the sound is active, then dont re-play the sound if it is active. I see the sound table has that in the code too "if SoundActive=0 then"


Edited by allknowing2012, 22 April 2015 - 02:00 PM.

* I don't know everything - I just have no life *
testimageNL

 

 

 

#16 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 22 April 2015 - 08:30 PM

Space Shuttle ?
 
What do you think about this Little but working Ball Sound, with Speakerout left/right:
(and you are right with the "Flag", i did it ... )

' Quick Ball Sound V0.1 by STAT
' -----------------------
Sub StartBall_Timer()
aX = int(SBall.VelX): aY = int(SBall.VelY)
sX = -1.0: If int(Sball.X)>500 Then sX = 1.0
If (aX>5 OR aY>5) AND Rsound = 0 Then
   RSound=int(RND*4)+1
   PlaySound "Roll "&RSound,0,1,sX,0 ' loop,vol,-left/right,pitch
Elseif (aX<6 OR aY<6) AND Rsound > 0 Then
   StopSound "Roll "&Rsound
   Rsound = 0
End If
End Sub

' -----------------------


Edited by STAT, 23 April 2015 - 09:42 PM.


#17 STAT

STAT

    Pinball and Arcade Freak

  • VIP
  • 4,983 posts
  • Location:Wels - Austria

  • Flag: Austria

  • Favorite Pinball: Twilight Zone

Posted 23 April 2015 - 09:42 PM

Sub StartBall_Timer()
  aX = int(SBall.VelX): aY = int(SBall.VelY)
  sX = -1.0: If int(Sball.X)>500 Then sX = 1.0
  If (aX>5 OR aY>5) AND Rsound = 0 Then
     RSound=int(RND*4)+1
     PlaySound "Roll "&RSound,0,0.9,sX,0.2' loop,vol,-left/right,pitch
  Elseif (aX<6 AND aY<6) AND Rsound > 0 Then
     StopSound "Roll "&Rsound
  Rsound = 0
  End If
End Sub



#18 Johan Brodd

Johan Brodd

    Hobbyist

  • Members
  • PipPip
  • 26 posts
  • Location:Stockholm, Sweden

  • Flag: Sweden

  • Favorite Pinball: Visual Pinball X

  • PS3 Gamer Tag: PS4 tag: jobromedia.

Posted 28 July 2016 - 04:48 AM

So how does the pan actually work? I'm using mono sounds, and they are mostly only played in the right channel. A playsound tutorial would become really really handy.



#19 nFozzy

nFozzy

    Pinball Fan

  • Members
  • PipPipPipPip
  • 553 posts

  • Flag: ---------

  • Favorite Pinball: Pinbot

Posted 28 July 2016 - 04:55 AM

So how does the pan actually work? I'm using mono sounds, and they are mostly only played in the right channel. A playsound tutorial would become really really handy.

0 is center. Negative values are left, positive values are right.

 

Playsound usage: name, loopcount, volume, pan, randompitch



#20 gigalula

gigalula

    Hummmm not sure yet :)

  • Platinum Supporter
  • 651 posts

  • Flag: Canada

  • Favorite Pinball: All of them from 70' to now. Even more with VP and FP :)

Posted 13 January 2017 - 03:05 PM

Tested Andromeda with VP993 and I got an error that use "Quick Ball Sound script code v1.1"

 

download link: http://www.vpforums....&showfile=12572

 

 

Script Error

Line: 76

 

76     aX = int(SBall.VelX): aY = int(SBall.VelY)

 

Work fine under VP992... Don't have any clue what can cause this error under VP993