Register    Login    Forum    FAQ    PinSimDB.org

Board index » Future Pinball » Tables WIP




Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: FPx Table Template
 Post Posted: Sun Mar 12, 2017 4:52 pm 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
NOTE: I have been creating my own template system, but I have decided that everyone should be able to use this. This is still early days, and a first release is very down the road.

We all hate scripting. In fact most people (like 99.99 % of the entire planet) when they look at a bunch of code, find it so intimidating and complex that they won't even try. Others just don't even have the time to learn how to script, it's months of study and learning. The biggest problem with Future Pinball (and especially VPX now) is the scripting, it was always the scripting, and will be the scripting in the future.

The FPx template is designed to replace the stock New Table template in Future Pinball. This one will be aimed right at beginners, in fact, with luck, it may work exactly like the Pinball Construction set. This not only fixes the bugs and incompleteness of the New_table template, it also adds more features that every beginner would want, and then presents it in such a way to make it as easy to use as possible.

It is so easy to mess up a script, especially the high level code of a scoring and logic template. Even advanced coders can mess up pretty easily, because all the code is MIXED IN together. FPx divides the script in to 2 parts, with the first part a user section, and the second portion the actual engine. The engine contains "Hooks" to the user section, this allows just about everyone to make simple changes without needing to touch the engine at all, and yet be able to use one of the most powerful, full featured engines available for Future Pinball.

The FPx template is designed for those who want to get their feet wet with scripting, and yet has all the power and features for Intermediate coders to use.

Here's a list of features:
Code:
' 4 players support
' Bonus count up to 159, bonus multiplier up to 15x
' Replaced tilt system with a custom plumb bob tilt setup
' Added Variables for easy settings. balls per game, bonus, replay scoring etc
' ball save, extra ball, special and jackpot support
' Complete routines included for all aspects of arcade tables, from power up, light Attract mode to a match feature
' Initialization, Light Attract, Match routines all ready included
' easy control of lights for Light Attract and game play, no typing required
' Pause key plays tune
' 9 element x4 translight display, Hud display x2 A.N.D. (Alpha Numeric Display) to support up to Williams System 11
' HUD display can be hidden or shown using the default HUD key set in the editor (Usually the tithe key, just below the esc key)
' Pre-set unified Bally type scoring
' Debug system variable for code testing in place. press F9 key at editor. Also writes to text file during debug mode to track code
' Special HUD displays for debug mode, shows bonus etc
' Multiple sound system capability with background music support
' Solid State and A.N.D. support HUD display
' Preset feature scoring Extra ball/Special etc with just one line of code
' Easy Beginners Fail safe system. All access needed for easy modification of the engine in ONE place without needing to touch the engine code
'       You can add/remove/replace lights, sounds, change the display, adjust timers etc through this one setup
' Code is heavily remarked, and teachs you new methods as you work your way down the hit code
' Engine is fully automated as possible, so no need to touch the engine code, no rocket science degree needed.
' A brief tutorial is included in the script, at the very bottom


A Video of the latest build is available here: https://youtu.be/mpBp8gvqxD8
This demonstrates a few things, and also is shown with the built in Debug mode.

NOTE: Features list update as of 11/27/2017

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Last edited by blue on Mon Nov 27, 2017 7:15 am, edited 1 time in total.

Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Sun Mar 12, 2017 4:55 pm 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
This is the User portion script as it stands. A few things will change, but most people who even know the most basic scripting should be able to follow it very easily (and if you don't, let me know in the comments, I will change it then)
Code:
' *********************************************************************
'                                              fpx Engine
'                                                 by
'                                            (C) 2017 blue
' *********************************************************************
' fpx Engine Template by blue, is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
' All custom table graphics are completely redrawn work and not part of the orginal artwork
' All other copyrights held by the orginal holders
' Permissions may be sought at www.gopinball.com
' Additional Script components By popotte
' Additional Model componets by HappyCab, popotte, and Fransico             
' Future Pinball by Black
'
' Terms Of Use
' THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE").
' THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.
' ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
'
' Under the following conditions:
'
'    Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
'    Noncommercial — You may not use this work for commercial purposes.
'    No Derivative Works — You may not alter, transform, or build upon this work
'
' With the understanding that:
'
'    Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.
'
' *********************************************************************

' *** FIX  FIX  FIX  FIX  ****
' AddEvent New Ball - add setting for time to display Player(x) before the ball pops out? Just ignore this completely? Works fine either way.
' ballsaver needs completeing.(Does work, just needs to be turned off if ball saver made. a display routine would be nice as well I guess, oops)
' Move GameOver variable so flippers etc turn off at the start of a match, not at lightattract when game finished

' *** DOUBLE/TRIPLE CHECK  ****
' Bug, Light attract no longer works after coin in FIXED: NEEDS CHECKING
' Bug, Doesn't display message if no credits and player tries to start game FIXED: Just plays a sound
' Bug Line 408  cause error if match is 0. It shouldn't but it does.
' Maybe finally fixed the FP Tilt warning bug, by writing my own warning system and bypassing it. This needs to be checked!FIXED: NEEDS CHECKING
' New light Attract mode, runs entirely on LightSeq. The engine turns off all lights completely, so you need to set the lights bulbs etc for each new ball.
' Just set the bulbs/lights in the editor to their state you want for each new ball. Bulbs should be set to "BulbOn" or "BulbBlink" in the state puldown box.
' Sure beats a lot of typing.

' *********************************************************************

' *** EDITOR LAYERS  ****
' Layer 9 in the editor contains all the objects for the hit code. If you delete the objects, you also have to remove the hit events in the script
' Layer 0 IS ENGINE CODE. DO NOT DELETE ANYTHING IN LAYER 0
' All other layers can be deleted safely
' Layer 1 is the table build
' Layer 2 are lights and bulbs. These are for demo purposes, and all can be deleted
' layer 5 are the posts


Option Explicit            ' Force explicit variable declaration
LogDebugTextToDisk()       ' writes to a text file in the same location as this table. This only works with the F9 key to start a table.

' *** START HERE ***
'
' Change the settings to how you want, the engine was designed to be as adjustable as possible. Just work from top to bottom, till you get to the  *** END HERE *** part
'
' * Table adjustments
   ' name of your table for the config file for Load/save values.
   ' Make sure this name is unique so it doesn't actually overwrite someone elses table. Do not add spaces or special characters, keep this one single uninterupted word

   Const constTableName = "fpxTemplate"          ' Name of the Table. Make this unique
   Const constAuthorName = "by blue"             ' who made it, you can always just give me the credit if you want
   Const constMaxPlayers = 4                      ' Maximum number of players per game (between 1 and 4)
   Const constBallsInGame  = 1                  ' balls per game. Default=3, set to 5 if you want 5 balls per game
   Const constReplay1 = 320000                   ' First replay award
   Const constReplay2 = 500000                   ' Second Replay award
   Const constHighScore = 750000                ' High Score award default value. If the High Score is made, the new high score is saved.
   Const constMaxCredits =15                      ' Maximum amount of credits a game will set. usually 15 with Bally, but you can set it to any value

' * Tilt
   ' There's a bug in the tilt system,the amount of warnings sometimes don't count properly if you set them in the editor, so this is a workaround
   ' This is forced code. you will see the tilt system kicker and wall in the editor. It creates a ball, and everytime you nudge, the ball hits the wall
   ' and adds to the count. works like a plumb bob actually. This bypasses the FP system completely. Settings in the editor are ignored.

   Const constNudgeCount=5                       ' Sets total amount of nudges, usually 5. This is very forgiving, like a actual plumb bob sometimes
                                                ' You can adjust the WallTilt object at the bottom left of the table to make it easier/harder

' * Debug and menu
   Const constAddDebug = 1                      ' Switchable debug text to track things (0 = off 1 = On) You need to press the F9 key in the editor to start debug table view.

' * Ball saver adjustments
   Const constBallSaverTime = 0                   ' Set in ms for ballsaver time (1000 ms = 1 sec) "0"=Off

' * Bonus and multiplier settings
   'Const constMaxMultiplier = 5                  ' Defines the maximum bonus multiplier level ***NOT ACTIVE YET***

' * extra ball adjustments
   Const constMaxExtraBalls=1                   ' sets limit to amount of extra balls a player can earn per ball
   Const constMaxExtraBallAlternateScore=25000    ' Alternate score in points in case you max out the amount of extra balls with one ball

' * Audio settings
   ' This sets the master volume. It's scriptable for more powerful amplifiers in some computers, otherwise just leave it at 1.0
   Const constMaxMusicVolume = 1.                ' Changes the master volume level for music (0.0 to 1.0)

' * Sound Set System
   ' Among one of the cooler systems within this system is the ability to choose and play multiple sound sets if they are loaded within the table.
   ' You can play any "official" sound set with any table you want, so you can as a example play a EM table with the sounds from The Addams family.
   ' As each sound set becomes available, the engine is updated with all sounds and timer values etc. You can also easily add your own, and re-use them
   ' for other tables.
   ' These are the default sound sets loaded into the table, just change the number to what you want
   '      0 = Will turn off the system, you can add your own sounds as well here
   '      1 = Bally 76 Electronic Chimes (eight ball)
   '      2 = Bally 78 electronic sounds (Playboy, Star Trek)
   '      3 = Bally 80 electronic sounds (Centaur/Vector/Embryon sound set)
   Const constTableType=3

' * Jackpot
   Const constJackpotmin = 10000                ' minimum Jackpot a player can score (In points) To turn off Jackpot, set both min and max values to 0
   Const constJackpotmax = 250000                ' Maximum Jackpot a player can score (In points)



' *********************************************************************
' **                                                                 **
' **                     User Define Section                         **
' **                                                                 **
' *********************************************************************

' And the magic starts here.
' Everything in one place, what a concept....

'
' *** FOR BEGINNERS: EXPLAINING THE ADDEVENT SUBROUTINE ***
'
' The main engine code you can leave alone, all of the code you may even want to modify is pointed right here for modification.
' These are "Hooks" within the main code, and give you access without causing errors (even placing a line of code the wrong order
' can cause errors, you don't have to worry about it now, just keep your code here within this subroutine)
' With everything in one place, and set and called properly from within the engine, all you have to do is add your unique table (Or just leave it the way it is)
' All Display/LightSync/ music is tied into here, and will run off of just one timer, that you can set the interval time for, and then don't worry
' about anything else.
'
' From the very startup to the end, all the grunt work and engine stuff is done for you, just add anything special you want to it.
' Instead of having seperate subroutines for each portion, this uses the Case statements. It is a bit tricky sometimes for new coders to
' understand, but it's actually very easy to use. Each Case corresponds to a section of the script. You just need to add whatever code you want, or just
' leave it entirely alone. No matter what, you are still going to have to learn some scripting, but when you are ready, look at the FP manual, as it has
' some good examples.
' Most of the code is the same, and any changes here you can make are usually text messages, music, and timer intervals to set the amount of total time
' you want each case to play before it automatically switches off. It really is the easy way to do things.

' YOU DON'T HAVE TO CHANGE ANY OF THIS IF YOU DON'T WANT TO! These are just presets, if you like it the way it is, leave it alone. If you do want to experiment
' then this is a great place to do so, as since this is outside the main code, you have a safe place to learn without causing errors to the engine
' (And if you do, let me know)
'
' - This template uses the 'Light Sequencer' and preset codes. You need to put all the lights in the "Light List Manager" in the tables menu at the top of the page.
'       Open the manager, select "AllLights" and press edit. You can add and remove lights and bulbs, this is used for the Light Attract mode, tilt etc and is
'       run automatically
'       Manual pages : Table Components/Lights/Light Sequencer and  Managers/Light List Managers
'      This uses Blacks demo routine. You can change it in the sub SetupAttractMode()
'
' - Changing the sound: If you want to use your own music, load them into the Music Manager (Managers/Sound/Music Manager), make sure you have
'       Const constTableType=0 set at the top of this script. Then just type the name of that sound between the quotes
'       For example: Change
'            If constTableType=0 then PlayMusic 6, "Initialize",, constMaxMusicVolume
'       to
'           If constTableType=0 then PlayMusic 6, "MYSOUNDINSTEAD",, constMaxMusicVolume
'
' - Timers: You will see code like this in here: FirstBallDelayTimer.Interval = 1000, TimerSetEvent1.Interval = 1000
'       these set the amount of time you want things to display/blink/play, and once that time is over, the engine stops that code and then plays like normal
'       The amount of time is the number at the end in miliseconds, so for example 1000 is one second, 2500 is 2.5 seconds
'       If I change this, I usually set the interval time to the run time of the music file, so if I have a music file to play, and its 3.25 seconds, my interval is

'             TimerSetEvent1.Interval = 3250

'       The TimerSetEvent1 is the main timer used here. Once this timer stops playing, it usually executes additional code, so I moved it out of view, but more advanced coders
'       may want to run additional code. I used the SetEventNum variable for this, to prevent errors, but I also marked each case so it's pretty easy to follow. This timer
'       points to vital engine code, so if you don't know what you are doing, leave this alone
'
' - Display Message: Everything is automated, it can be tricky to use because of the math, so it is out of sight to beginners. The display will flash/show/scroll
'       messages instead of the score (i.e. Making a Extra Ball) but you can change the actual message you want. Just keep the message inside the quotes. As a example
'       when the table starts up, you see "FPX TEMPLATE" (Case "START_GAME"). you only have 9 digits per message to work with, but you can change the message
'       Example: Change

'             Message(1)= "FPE   " ' note the spaces so this is centered in the display
'            Message(2)= "TEMPLATE"

'       to

'            Message(1)= "MY GREAT"
'            Message(2)= "TABLE   "

' - Tilt: Just pointing this one out, Case "Tilt" contains all the code you want to happen when the game is tilted. No scoring, flippers turn off, slings
'       turn off etc. If you add flippers etc, this is where you put all the code. I left all the "turn off" code in this case setting, if you remove it, then it's
'       still active even in tilt state. Just add your stuff, everything else is automatic so don't worry about it.

'       Most of the tilt code is in fact in the Hit() subroutines(Below this)for the table objects, usually if you follow this method, it works fine and easier
'       Here is a simple example:

'            sub Bumper1_Hit()                ' * The ball hits the bumper *
'               If (fpTilted = False) Then      ' * IF the table IS NOT tilted THEN only execute this code *
'                  AddScore(10)               ' * WE are not tilted, so add 10 points *
'               End If                        ' * Okay we are done, so goto the next line of code *
'            End sub                           ' * Nothing more to do, so this sub is done *
'
' KEY CASE SECTIONS
' These are noted as these are sections you will need for your code
' - Case "NEW_BALL" - This is where you add your code for the start of each new ball.
'      No need to dip in the engine, just put your routines like resetting target banks, clearing variables etc right here
' - Case "TILT" - If you don't use the above hit event method, or need to turn off flippers etc, this is the place to add your code.

' Lets begin.
Sub AddEvent (SetEvent)
' *** Engine Code DO NOT CHANGE ***
      IF constAddDebug = 1 THEN AddDebugText "AddEvent "& (SetEvent) & " Active"
      SetEventNum=0 ' clear value just in case
      TimerSetEvent1.Enabled = FALSE      ' Stops timer, blanks displays, clear cache
      ' adds blank display for 50ms... looks better...
      For x = 1 to 4:Seg(x).QueueText "  ", seNone, 50, 0, FALSE, "":Next
      For x = 1 to 2:HSeg(x).QueueText "  ", seNone, 50, 0, FALSE, "":Next
      Dispcredit.Text = (nvCredits)      ' Since this rarely changes, update the credit box
' *** END ***

      Select Case SetEvent                        ' Sets case name. leave this alone

      ' *** Initialize *** When table is first started, this is the powerup effect
         Case "INITIALIZE"

            ' Power up effect when table is first started. Insert any code you want here
            ' This automatically plays the Initialize sound if you set constTableType=0, and not use the other preset sound sets
            ' you will need to make and add your complete own sound set for that. and add them directly in the music editor.
            ' There is a stock EM sound already in the music editor. I left them in there after I tested them. If you like EM sounds, just keep them.

               If constTableType=0 then PlayMusic 6, "Initialize",, constMaxMusicVolume
               TimerSetEvent1.Interval = 2500
      ' *** Light Attract ***
         Case "LIGHTATTRACTSCORE"

            ' This uses the AddEventTimer, after the Power up event is done, it then points to this to start light Attract mode
            ' This will automatically switch off all lights in the AllLights collection in your LightList manager when the player starts a game.
            ' It will then restore any lights and bulbs based on the settings you place in the editor, for EACH new ball
            ' If you set BulbOn in the editor, that light will be on when the ball pops out, same for blink and off.
            ' You can add code here, maybe add background music etc.
            ' Put the lights/bulbs in the AllLights collection in the LightList Manager. (Hint: If you don't know what I am talking about, read the FP manual)
            ' The AllLights handles not just the light Attract, but In Game LightSeq and tilt as well
            ' Of course, you can manually type in each light to turn on and off manually, or just use Blacks lightsync example to do it all for you like I did

               SetupAttractMode()                        ' Calls the LightSeq routines. You can change this pretty easy


      ' *** COIN IN *** Player has added a credit.
         Case "COININ" ' Called in FuturePinball_KeyPressed(ByVal KeyCode) subroutine

            ' Most of the code here is for the display, it's tricky to modify, so I left it away from your hands. This is hard coded for your protection
            ' But if you really want to change it, then you will find it just above the AddEvent "COININ" code if you do a search for it

            ' random blinking of lights for visual cue. Lights can be added in the Table/LightList manager/"AllLights"
            ' Use the FP manual for other codes and examples, this just blinks lights rapidly on and off

               LightSeq1.StopPlay()                        ' Stops any LightSeq, restores lights to state in editor
               LightSeq1.Play SeqRandom, 40, ,2000         ' Flash AllLights for a brief time

            ' For your custom sound instead of the stock sound sets included.
               If constTableType=0 then PlayMusic 6, "coin_in",, constMaxMusicVolume

      ' *** No Credits *** Player tries to start game but has no credits. You can have fun with this one.  :)
         Case "NOCREDITS"

            ' Note: There is no soundsets coded support available for this, since this is a learning template, then it is time to teach you how to add your own sounds
            ' Make/add your file to the music manager, then just point to this file name between the quotes in the code.
            ' I just use one of the defaut sound set files. If you don't even want a sound, just delete the line of code

               PlayMusic 6, "3_tilt",, constMaxMusicVolume ' we don't need soundset support for this, this is a unique music/sound file

      ' * Before the first ball pops out when a game is started
         Case "START_GAME" ' Called From ResetForNewGame()

            ' Sets the text you want for the display. Note the spaces at the end of each message. This just centers the text in the display
            ' I use the table name, split into 2 displays as it's more than 9 characters long. There are 2 places for you to input your message here
            ' Message(1) will display in the player 1 display, and the first HUD display, Message(2) will display in the player2 display in the translite
            ' and the 2nd HUD display. Everything else is handled by the engine

               Message(1)= "FPE   " ' note the spaces so this is centered in the display
               Message(2)= "TEMPLATE"

            ' And now the music, exactly the same as before, but one difference. Since this plays a opening tune BEFORE the first ball pops out
            ' You need to set the amount of time you want for that tune before the ball becomes available. Since this needs it's own dedicated timer, you need
            ' to set the amount of time you need for that timer ( 1000 = 1 second, 2500 = 2.5 seconds etc)
            ' The best way to figure this out is to just use a audio program that displays the run time of the music, add a bit more for a nice pause,
            ' and change FirstBallDelayTimer.Interval to the the time you want. For example, one soundset is coded for a interval time of 3300,
            ' which is a 3.3 second delay between when the music starts playing, and when the first ball pops out

               If constTableType=0 then
                  PlayMusic 6, "game_start",, constMaxMusicVolume:FirstBallDelayTimer.Interval = 1000
               End If

      ' * Multiple players are added at start of game
         Case "PLAYER_ADDED" ' Called From GetKeyCode(StartGameKey)

            ' Add flashing lights from the Lights placed in Table/LightList Manager/AllLights"

               LightSeq1.StopPlay():LightSeq1.Play SeqBlinking, , 10,20
               If constTableType=0 then PlayMusic 6, "player_added",, constMaxMusicVolume

      ' * Code for start of each ball, and what the system does
         Case "NEW_BALL" ' Called From ResetForNewPlayerBall()

            ' NOTE for more advanced users: THIS CODE is used TWICE, so we put the code in it's own routine so you only have to modify this once.
            ' Search for NEW_BALL_HOOK_CODE() to modify this code
            ' This has special display settings for when a ball pops out, and only for multiplayer games

            If constTableType=0 then PlayMusic 6, "new_ball",, constMaxMusicVolume

            ' THIS IS WHERE YOU ADD YOUR CODE FOR THE START OF EACH BALL !!!!
            '    Use this to turn on any lights, reset any variables you use, popup targets etc.

      ' * Code for tilt state, and what the system does
         Case "TILT"

            If constTableType=0 then PlayMusic 6, "tilt",, constMaxMusicVolume

            ' THIS IS WHERE YOU ADD YOUR CODE FOR WHEN THE GAME TILTS !!!!
            ' Use this to turn off things, like the flippers below.
            ' ensure that the flippers are down (as the keys won't work from now on)

            LeftFlipper.SolenoidOff:RightFlipper.SolenoidOff

      ' * NOTE: This is forced code and sound in the engine and is used for the future Bonus count etc. This is very tricky stuff, and easy to mess up, so
      ' This is not active for now for your own protection. Any code in here will not work.
         Case "DRAINDELAY"

            ' Nothing goes here, I mean it! This is for down the road!

      ' * When very last ball is played, run this first and then start match      
         Case "LASTBALLPLAYED" ' Called from Sub LastBallPlayed()
            
            LightSeq1.Play SeqBlinking, , 25,30          ' Flash show

            ' Sets the text you want for the display to show instead of points.

            Message(1)= "MATCH" 'Player 1 display and HUD1
            Message(2)= "MATCH" ' Player 2 display and HUD2

            ' Custom sound settings

            If constTableType=0 then
               PlayMusic 6, "before_match",, constMaxMusicVolume
               ' sets time delay so the sound and display message will play before normal scoring resumes. You can change the interval time to what you want
               TimerSetEvent1.Interval = 3000
            End If

      ' * When very last ball is played, run this first and then start match
         Case "MATCH" 'Called from AddMatch() sub

            ' Sets the text you want for the display to show instead of "Match". Why you would want to change it is beyond me, but you can

            Message(1)= "MATCH " ' displays in player1, player2 and Hud

            If constTableType=0 then
               PlayMusic 6, "match",, constMaxMusicVolume
               ' sets time delay so your custom sound and display message will play before normal scoring resumes. You can change the interval time to what you want
               TimerSetEvent1.Interval = 2500
            End If

   ' * When all balls done, match over and the game is finished.
         Case "End_Game" 'Called from both EndGame() and TimerSetEvent1 to a single subroutine AddEndGame()

            ' Sets the text you want for the displays to show

            Message(1)= "GAME  " 'Player 1 and 2 display and HUD1
            Message(2)= "OVER  " ' Player 3 and 4 display and HUD2

            ' Custom sound settings

            If constTableType=0 then
               PlayMusic 6, "game_over",, constMaxMusicVolume
               ' sets time delay so the sound and display message will play before normal scoring resumes. You can change the interval time to what you want
               TimerSetEvent1.Interval = 3000
            End If

' *** HEY THE TABLE LOGIC PART IS DONE ***
' Pretty easy huh? Now, lets do the featured scoring, since it uses the same timer and system.

' For More advanced coders: This uses a variable called LockDisplay.
      ' LockDisplay is set to 1 to "freeze" the display. This will override any other message text triggered for the set time limit, or will
      ' not display or play sound if another display message routine is running. The first time a LockDisplay code is run will always have
      ' priority over any time another LockDisplay is called. TimerSetEvent1 (used for AddEvent) automatically sets LockDisplay back to off
      ' This is just for the display messages/lights/sound. All other code is still executed

   ' * Code for Extra Ball Made.
         Case "EXTRABALL" ' Called from AddExtraBall()

            LightSeq1.Play SeqBlinking, , 25,30

            ' Sets the text you want for the display to show instead of "Extra Ball"

            Message(1)= "EXTRA"
            Message(2)= "BALL"

            If constTableType=0 then
               PlayMusic 6, "extra_ball",, constMaxMusicVolume
               ' sets time delay so the sound and display message will play before normal scoring resumes. You can change the interval time to what you want
               TimerSetEvent1.Interval = 3000
            End If

   ' * Code for Shoot Again message when player earns extra ball
         Case "SHOOTAGAIN" ' Called from EndOfBallTimer_Expired()

            ' Player starts a extra ball instead of going to next players ball
            ' These values are passed back to EndOfBallTimer_Expired()
            
            LightSeq1.Play SeqBlinking, , 25,30 ' Flash show

            ' Sets the text you want for the display to show instead of points

            Message(1)= "SHOOT"
            Message(2)= "AGAIN"

            ' Custom sound settings
            If constTableType=0 then
               PlayMusic 6, "shoot_again",, constMaxMusicVolume
               ' sets time delay so the sound and display message will play before normal scoring resumes. You can change the interval time to what you want
               TimerSetEvent1.Interval = 3000
            End If

   ' * Adds a Free game
         Case "SPECIAL" ' Called from AddSpecial()

            LightSeq1.Play SeqBlinking, , 25,30 ' Flash show
            ' Sets the text you want for the display to show instead of points
            Message(1)= "SPECIAL"
            Message(2)= "SPECIAL"
            ' Custom sound settings
            If constTableType=0 then
               PlayMusic 6, "special",, constMaxMusicVolume
               ' sets time delay so the sound and display message will play before normal scoring resumes. You can change the interval time to what you want
               TimerSetEvent1.Interval = 3000
            End If

   ' * Scores the Jackpot.
         Case "JACKPOT" 'Called from Sub Jackpot()

            ' To add to Jackpot score, write the amount of points you wish to add between the brackets.
            ' AddJackpot(100) will add 100 points to the jackpot total
            'SetEventNum=11 ' sets case for TimerSetEvent1. This points to end of the routine, which calls CreateNewBall()

            LightSeq1.Play SeqBlinking, , 25,30 ' Flash show

            ' Sets the text you want for the display to show instead of points

            Message(1)= "JACKPOT"
            Message(2)= "JACKPOT"

            ' Custom sound settings

            If constTableType=0 then
               PlayMusic 6, "jackpot",, constMaxMusicVolume
               ' sets time delay so the sound and display message will play before normal scoring resumes. You can change the interval time to what you want
               TimerSetEvent1.Interval = 3000
            End If
      End Select
End sub

' *********************************************************************
' **                                                                 **
' **                     Table Object HIT Events                     **
' **                                                                 **
' *********************************************************************

' This is the basic code for the objects in the editor. You can change it, modify it, or add to it.
' If you are a beginner and just learning, make a backup of the code, so you can restore it if you need to. It's not tough
'
' This code is just for a playable table, and also has examples for extra ball etc.
' NOTE: NO need to add sounds, it is added "EM" style with the points. The code is incomplete, but it works.
' Next version you should have the option to use your own sounds instead like most tables since 1979

' Trigger above plunger. Not even needed unless you need it to play a sound, open a gate etc. The Arcade tables usually had one so the cpu would
' reconize that a ball was actually in play.
Sub PlungerLaneTrigger_Hit()
   IF constAddDebug = 1 THEN AddDebugText "PlungerLaneTrigger_Hit()"
End Sub

' The Left Slingshot has been Hit, Add Some Points and Flash the Slingshot Lights
Sub LeftSlingshotRubber_Hit()
   If (fpTilted = False) Then                              ' Make sure we are not in a tilted state
      AddScore(10)                                       ' Add some points We add the value in the brackets, in this case 10 points, to our score
      LeftSlingshotBulb1.FlashForMs 100, 50, BulbOff      ' Flash the pf bulb lights in side the slingshot, not really needed, just looks pretty
      LeftSlingshotBulb2.FlashForMs 100, 50, BulbOff
   End If
End Sub


' The Right Slingshot has been Hit, Add Some Points and Flash the Slingshot Lights
Sub RightSlingshotRubber_Hit()
   If (fpTilted = False) Then                              ' Make sure we are not in a tilted state
      AddScore(10)                                       ' Add some points. We add the value in the brackets, in this case 10 points, to our score
      RightSlingshotBulb1.FlashForMs 100, 50, BulbOff      ' Flash the pf bulb lights in side the slingshot, not really needed, just looks pretty
      RightSlingshotBulb2.FlashForMs 100, 50, BulbOff
   End If
End Sub

' The Left InLane trigger has been Hit
Sub LeftInLaneTrigger_Hit()
   If (fpTilted = False) Then                              ' Look to see if you haven't tilted the table, if you haven't then...   
      AddScore(500)                                       ' add some points
      AddJackpot(100)                                     ' Adds to Jackpot total
   End If                                                ' You have to close a If statement with a End If
   set LastSwitchHit = LeftInLaneTrigger                   ' remember last trigger hit by the ball, it's good coding, but actually pretty useless at the moment
End Sub

' The Right InLane trigger has been Hit
Sub RightInLaneTrigger_Hit()
   If (fpTilted = False) Then                              ' Look to see if you haven't tilted the table, if you haven't then...
      AddScore(500)                                       ' add some points
      AddJackpot(100)                                     ' Adds to Jackpot total
   End If                                                ' You have to close a If statement with a End If
   set LastSwitchHit = RightInLaneTrigger                  ' remember last trigger hit by the ball, it's good coding, but actually pretty useless at the moment
End Sub

' The Left OutLane trigger has been Hit
Sub LeftOutLaneTrigger_Hit()
   If (fpTilted = False) Then   
      AddScore(1000)                                       ' add some points
      AddJackpot(1000)                                     ' Adds to Jackpot total
   End If
   set LastSwitchHit = LeftOutLaneTrigger
End Sub

' The Right OutLane trigger has been Hit
Sub RightOutLaneTrigger_Hit()
   If (fpTilted = False) Then
      AddScore(1000)                                       ' add some points
      AddJackpot(1000)                                     ' Adds to Jackpot total
   End If
   set LastSwitchHit = RightOutLaneTrigger               ' remember last trigger hit by the ball
End Sub

' Top triggers
Sub Trigger1_Hit()
   IF constAddDebug = 1 THEN AddDebugText "Trigger1 "      ' For testing
   If (fpTilted = False) Then
      AddScore(1000)                                       ' add some points
      AddJackpot(1000)                                     ' Adds to Jackpot total
   End If
   set LastSwitchHit = Trigger1                           ' remember last trigger hit by the ball
End Sub

Sub Trigger2_Hit()
   IF constAddDebug = 1 THEN AddDebugText "Trigger2 "      ' for testing
   If (fpTilted = False) Then
      AddScore(1000)                                       ' add some points
      AddJackpot(1000)                                     ' Adds to Jackpot total
   End If
   set LastSwitchHit = Trigger2                           ' remember last trigger hit by the ball
End Sub

Sub Trigger3_Hit()
   IF constAddDebug = 1 THEN AddDebugText "Trigger3 "
   If (fpTilted = False) Then
      AddScore(1000)                                       ' add some points
      AddJackpot(1000)                                     ' Adds to Jackpot total
   End If
   set LastSwitchHit = Trigger3                           ' remember last trigger hit by the ball
End Sub

Sub Trigger4_Hit()
   IF constAddDebug = 1 THEN AddDebugText "Trigger4 "
   If (fpTilted = False) Then
      AddScore(1000)                                       ' add some points
      AddJackpot(1000)                                     ' Adds to Jackpot total
   End If   
   set LastSwitchHit = Trigger4                           ' remember last trigger hit by the ball
End Sub

' Button targets, used as examples to demo the AddEvent routines. Yes, it is just one line of code to score these features.
'
' Awards Extra Ball
Sub EBTarget1_Hit()
   IF constAddDebug = 1 THEN AddDebugText "Target Extra Ball "
   If (fpTilted = False) Then
      AddExtraBall()                                       ' Automatically Awards Extra Ball. You can change some settings in AddEvent case EXTRABALL
   End If
   set LastSwitchHit = EBTarget1
End Sub

' Awards Special
Sub SpecialTarget1_Hit()
   IF constAddDebug = 1 THEN AddDebugText "Target special "
   If (fpTilted = False) Then
      AddSpecial()                                       ' Automatically Awards Special. You can change some settings in AddEvent case SPECIAL
   End If
   ' remember last trigger hit by the ball
   set LastSwitchHit = SpecialTarget1
End Sub

' Awards Jackpot
Sub JackpotTarget1_Hit()
   IF constAddDebug = 1 THEN AddDebugText "Target special "
   If (fpTilted = False) Then
      Jackpot()                                          ' Automatically Awards Jackpot. You can change some settings in AddEvent case JACKPOT
   End If
   ' remember last trigger hit by the ball
   set LastSwitchHit = JackpotTarget1
End Sub

' Bumper
sub Bumper1_Hit()
   If (fpTilted = False) Then
      AddScore(10)
   End If
   IF constAddDebug = 1 THEN AddDebugText "bumper hit"
End sub
'
' *********************************************************************
' **                                                                 **
' **                          OPTIONAL SECTION                       **
' **                                                                 **
'
' Things you may want to change, but don't have to
'
' This is black's lightSeq demo for the light Attract. You can change this as you want, pretty easy to follow and is marked to tell you which effect it is
' Use ONLY LightSeq code, as it is also used for all efects, tilt etc.


NOTE: Due to this websites set size, just copy and paste the code into wordpad or a text editor. Makes it a lot easier to read and understand...

To be honest, it's about 4 times the size just explaining the code than the actual code itself.
But that's all most of you would have to do, you don't even need to touch it if you don't want to, other than add hit code. The AddEvent sub looks complecated, but it's not. It's just to add/change sound, lightSeq, display messages, and add code for target resets etc for new balls, tilts directly to the engine instead of having to go through 1,000s of lines of code. The vast majority will just leave it alone anyway.

The objective is to make this as easy to use as possible, and to let as many people as possible make their own tables, just like FP was designed to do from the start.

Any comments or suggestions are appreciated, especially if I can make the template even easier to use.

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Sun Mar 12, 2017 7:30 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2125
Location: Ontario, Canada
Very cool Blue !!!
Thank you so much for doing this!!


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Sun Mar 12, 2017 7:57 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1699
Location: Arkansas, USA
Miownkhan showed me some simple script to make the HUD toggle work and also be able to change the default as to whether the HUD displays on start up of the game or not. It is pretty simple. There are just 3 sections of script. You need to replace Overlay1, DMD1 and SegDisp in the code with the names of the overlay(s), DMD(s) and Segmented Display(s) that are located on the HUD of the table. If your table does not have a segmented display just, delete the "SegDisp.FadeIn" and "SegDisp.FadeOut". Likewise with the Overlay and DMD items.

This adds some nice functionality but it's simple enough that even I can do it

Code:
' Miownkhan HUD Mod Start (Part 1 of 3, add to the section with constants and dims)
Dim SeeHUD
SeeHUD = 1                           ' This changes the default HUD setting. 0 = Won't see HUD when game starts, 1 = Will see HUD when game starts
' Miownkhan HUD Mod Part 1 Ends


Code:
   '  Miownkhan HUD Mod Start (Part 2 of 3, add this below section Sub FuturePinball_BeginPlay)
   '  Define Hud State (On\Off) during Startup
   If SeeHUD = 1 Then Overlay1.FadeIn: DMD1.FadeIn: SegDisp.FadeIn
   If SeeHUD = 0 Then Overlay1.FadeOut: DMD1.FadeOut: SegDisp.FadeOut
   ' Miownkhan HUD Mod Part 2 Ends


Code:
   '  Miownkhan HUD Mod Start (Part 3 of 3, add this below section Sub FuturePinball_KeyPressed(ByVal KeyCode))
   If KeyCode = GetKeyCode(ToggleHudKey) Then               ' Toggles HUD on and off using the key on the keyboard while playing the game.
      If SeeHUD = 0 Then
         SeeHUD = 1: Overlay1.FadeIn: DMD1.FadeIn: SegDisp.FadeIn
      Else
         SeeHUD = 0: Overlay1.FadeOut: DMD1.FadeOut: SegDisp.FadeOut
      End If
   End If
   ' Miownkhan HUD Mod Part 3 Ends


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Sun Mar 12, 2017 10:47 pm 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
It is, I've done it a couple times myself. It's planned, but there is a specific roadmap here, based on what I feel most people want now. This is the next few weeks of work that I will be doing...

- Fix all bugs, polish remaining routines
- finish the coding for features already in place e.g. Ballsaver
- Bonus feature, including Bonus count and bonus multiplier
- Add any special scoring features for Bonus (Bonus hold-over)
- Update sound/music system with new features, and add sound support to other items and features
- Begin work on Multiball

I do appreciate it though, this is exactly what I wanted, and it's very useful to me. Anything like this makes it far easier for me when it comes time, and it's great if it's in one place as well. The roadmap above are things that I have to do first before anything else is all. I have done several engines like this for the pinball community over the last 15 years, so this time I decided to be more organized.

The intention is to release a Build after the bonus system is in place, get what is in there tested, and hopefully some basic tables built, to see how the scripting environment works for people.

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Wed Jun 28, 2017 1:48 am 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
been a while. Real life, got burned out with scripting etc. I took a break and worked on a side project for a while, a original table called Jungle Girl (First original in 14 years!) using popotte's script, but then I got to thinking the best way to build the FPX script is to have a real table also included. So, decided that this was the best way.

Since I am in a creative mood, working on the art. Got the bottom third almost done, but since both the table and the template are alpha and not even close to finished, I'm running it through my Facebook page with updates. Still, I will include a screenshot of the pf art I have finished here so everyone here knows I haven't died and is actually productive.

The template itself will also include Jungle Girl code, but the entire concept is to reuse scoring code as well, so I am rewriting my rules, so the inline targets will be from Paragon, Triggers from Playboy, Multiball from Xenon, etc.

These will all be set up by the user with one line of code pointing to the routine you want, and as more tables are done, the more routines can be added to the script. Think of it as a smorgasbord of premade code snippets. A little of this, a little of that. :)

I decided bonus scoring/multipliers etc will be through the display, and not lights on a playfield like most EM/Solid State tables, but I decided to have a second system setup using lights on the playfield, so there will be 2 bonus systems you can have separate or tied together.

I also will be adding Player memory as well, which is a very simple system that holds and remembers values from ball to ball, even with multiple players. I've used this for many years, pretty fool proof, and will tie in very nicely with the template's features already in.

Updates every once in a while at my Facebook page, it's set to public, until it's done enough for a formal W.I.P. here.


You do not have the required permissions to view the files attached to this post.

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Wed Jun 28, 2017 3:38 am 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1699
Location: Arkansas, USA
This sounds cool blue. I have always found it helpful to look at an actual table to see how to code something. I have done a few script mods that I am pleased with but I'm really not all that great at it so your template sounds like it would be of a lot of help.

George


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Wed Jun 28, 2017 5:25 am 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
Thanks. The structure itself will be very different than normal, as the entire idea is to have as little scripting experience as possible. The engine itself is automated, you just need to change the dim statements for amount of balls etc, change sounds/lightSeq etc if you want to, and add simple hit code to the script that usually requires one line to point to a major scoring feature. I decided to name that line by the arcade table the code snippet is based on, so here's a example.
Code:
Sub TargetBank1_Hit()
       DropTargetBank "JungleGirl"
End Sub


This will be built into the script, and will be usable for every table that uses FPX. Say someone does xenon using the FPX template.
Code:
Sub TargetBank1_Hit()
       DropTargetBank "Xenon"
End Sub


What this will do is point to the code so your targets will score like Xenon (2x,4x,25k,extra ball, special)

They can write the code themselves, then submit it to me to add to the main script in a next update, then everyone can use it for their tables, or even change a existing table already out there. Say you don't like a target bank scoring, then all you have to do is find where the code is in the script with a simple search, and just type in the new name (If it's supported in the script that is) and create any objects like lights, and done. It may even be easier than that. The problem is time with me, but I will get there.

A early version was released privately to Facebook friends, but no one said anything, so assuming it's fine. :)

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Wed Jun 28, 2017 1:55 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2125
Location: Ontario, Canada
I thought this was you under a diiferent alias
http://www.pinsimdb.org/pinball/table-2 ... te_starter

Quote:
also will be adding Player memory as well, which is a very simple system that holds and remembers values from ball to ball, even with multiple players. I've used this for many years, pretty fool proof, and will tie in very nicely with the template's features already in.


I would love to see your mp system...


Top 
 Profile  
 
 Post subject: Re: FPx Table Template
 Post Posted: Wed Jun 28, 2017 2:01 pm 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
Nope not me. :)
Nice little template though, didn't even know it was out. Have to take a look at that one.

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 36 posts ]  Go to page 1, 2, 3, 4  Next

Board index » Future Pinball » Tables WIP


Who is online

Users browsing this forum: No registered users and 8 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to: