- View New Content
-
Getting Started
-
Tutorials
Tutorial Categories
Tutorials Main Page Installation and Setup Downloadable TutorialsROM Adjustments
Number of Balls Adjustments Volume Adjustments
-
Visual Pinball Tables
VP 8 Desktop Tables
All VPM Recreations VP Recreations VP/VPM MODs VP Originals ROMsVP 9 Desktop Tables
All VPM Recreations VP Recreations VP/VPM MODs VP Originals ROMsVP9 Cabinet Tables
All Full Screen Cabinet Full Screen B2S Cabinet Spanned Cabinet Tables Media Packs ROMsVPX Tables
All VPinMAME Recreations VPX- - /VPinMAME - MOD Tables VPX Recreations VPX Originals Media Packs ROMs VR
-
Frontend Media & Backglass
Media Packs
Complete Media Packs Wheel Logos VideosBackglasses
dB2S Animated Backglasses UVP Animated Backglasses Topper Images
- Future Pinball Tables
-
Design Resources
Main Resources
Table Templates Playfield Images Image Library Sound Library Key CodesVP Guides
VP8 Guide - English VP8 Guide - Deutsch VP9 Guide - English VP9.1.x Guide - English VP Object Guide VPM DocumentationFuture Pinball Resources
Playfield Images 3D Model LibraryFuture Pinball Guides
FP Script Guide Big Draco Script Guide FP Table Design Guide FP DMD Guide
- Other Features
- Bug Tracker
- Image Gallery
- Blogs
-
More
Script Guide ?
Started By
STAT
, Apr 20 2015 03:39 PM
20 replies to this topic
#1
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 ...
is there anything for Scripting also ?
I mean where i can follow what is, example, Ball.X or Parameters for PlaySound ... and and ...
#3
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)
#4
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
Posted 20 April 2015 - 05:56 PM
And why doesnt this work everytime ?
Set BallPos = ActiveBall
Info.Text = BallPos.X
First yes, later "Error"
![]()
Edited by STAT, 20 April 2015 - 05:57 PM.
#6
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"
Any chance the activeball is gone/drained/destroyed?
#7
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
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
#9
Posted 21 April 2015 - 05:08 AM
Thank you very much, all right now ![]()
#10
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 ... (?)
#12
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.
#14
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
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.
#16
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
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
#19
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
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





Top

Contributor















are all trademarks of VPFORUMS.