Jump to content



Photo
- - - - -

Visual PinMAME Scripting 105 - Shortcuts!


  • Please log in to reply
4 replies to this topic

#1 destruk

destruk

    VPF Veteran

  • VPF Staff
  • 6,307 posts
  • Location:Colorado Springs, CO

  • Flag: United States of America

  • Favorite Pinball: Ultrapin!



Posted 29 April 2010 - 08:31 PM

Visual PinMAME Scripting 105
--------------------------------------------------------------
I suspect this tutorial will be short. smile.gif

After scripting 100 tables or so, you'll come up with your own timesavers. Here are a few standard ones I have run across over the years, as well as basic ones outlined in vbsdoc.html. Most of these techniques are a 'doh, why didn't I think of that'.

To begin, vbsdoc.html lists a few nifty timesavers in it. vpmMapLights is a favorite of mine.
Basically, drop a light object on the table, click options, go down to TimerInterval in the "MISC" section, and change the 100 to the lamp number vpm uses for that light. I usually press TAB whenever I make a change to an object to make sure visual pinball saves the change. When all the lights in your game have their number in the timer interval field, create a collection of lights in table/collection manager at the top. You can either do this by selecting all the lights on the table and clicking "Create from Selection", or you can click new, and group select with the shift key all the lights from the list on the left and click the right arrow to put them into the collection.

The order makes no difference. If you have two or more lights with the same timer interval it is ok too.
In your script - preferably in table_init after the rom starts running, add
vpmMapLights Collection1 'Where collection1 is the name of your light collection you created

Now all the lights will be running just as if you had typed
set lights(1)=Light1
for each light.

If you give your light objects meaningful names, so the interval and name match in some regard, it is easy to troubleshoot, easy to modify, and easy to work with. If you require fading effects or special circumstances, leave them out of the collection and handle it manually like you have been.

Another timesaver built into the vbs scripts is "vpmCreateEvents CollectionName"
This one works nearly the same as vpmMapLights but it is more enhanced for more object types.
If you are dealing with triggers, spinners, bumpers, and slingshots, CreateEvents will handle those routines for you provided the switch number is in the timer interval field for the object, and the object is added to another collection. For slingshots to work, the has hit event CAN NOT be checked. If Has Hit Event is checked, then the wall, and not the slingshot, will be used for the switch number.

vpmCreateEvents will create, at runtime, the _hit, _unhit, _slingshot, and _spin events for you - leaving your script to concentrate on more important routines. Again, if you need customization, leave your object out of the collection, or just code it manually. Customization scripting would include, animated rollover triggers, animated custom slingshots, emreel animations, etc etc.

Most of the class objects in the vbs scripts have their own CreateEvents method available to them. The Drop Target class will automatically handle the hit events for your drop target bank. The magnet CreateEvents will handle the Hit/unhit stuff, as well as the On and Off states for your magnet if the solenoid number is specified. Turntable will handle the affectball, as well as the hit and unhit events. CaptiveBall will handle the hit, unhit, etc etc. Basically the CreateEvents property is simply a timesaver for doing the most standard operations, so you don't have to. Peruse the vbsdoc file for more information on this - I use CreateEvents occasionally in my own scripts, even to this day.

Beware that any use of CreateEvents will replace your existing subroutine code if the name is the same. It is one or the other - do not manually code a drop target hit event in the script if you are using createevents for the drop target bank that target belongs to.



Some of my own timesavers/cheats are as follows.
If I need to script a drop target bank, I open a table with a drop target bank in it already, and I copy the script for it and paste it into my current project. Then I just need to change the names, verify the targets have "Can Drop" checked, and the switches are correct and it's good to go. I do the same for ballstacks, the basic loading script, playfield toys, captive balls, visible ball locks, etc. Now that I think about it - I do that with most of my new games. I rarely have to code very much - most is copy and paste these days. If you can avoid it, don't reinvent the wheel without good reason. If something worked before, it will (99% of the time) work again with minor, if any, modifications.

To change properties of an object, when it is behind a bunch of other objects you don't want to modify, drop a timer on the table, then select the object name from the index list, or from the script editor dropdown list of objects in the top left corner. Hold down the shift key and click the timer so they are both selected in the editor. Then you can right click the timer, and any change you select will apply to both objects. When you're done feel free to delete the timer.

If you want to make changes to a group of objects, or you have thousands of ramps and the object name begins with an S - and you can't easily select it, create a collection with a name beginning with A and 'drop' the objects into the collection. Then you can select all the objects by clicking the collection name.

To make multiple walls rotate on a pivot - the default rotation setting is the middle of the object. Click the control point you want to pivot on and write down the X and Y location value of that control point. When you right click the object and select rotate, enter the X and Y value into the "center" fields and it will be rotated on that point.

To join ramps mathematically seamlessly, right click the end point of each ramp and uncheck "smooth". Now add two points fairly close to the end of each ramp and again, uncheck "Smooth". Now subtract the X and Y locations of the two points on ramp 1 to figure out the distance from X to X and Y to Y. Compute the same distance for the second point on ramp 2. Now there is no way the ramps would not be absolutely perfect at the connection.

The smaller a wall or custom light is, the more likely you will be able to move control points at maximum zoom level.

If you want to move a lot of objects except one, it is much more accurate to lock the object you don't want to move, group select everything, and drag them where you want them to go. I find most times when left clicking an object to deselect it, the mouse cursor will move ever so slightly - if it is locked, it won't matter if that happens.

To quickly add timer intervals to lights - provided they are named in some form of alphabetical sequence (Light1, light2, or L2, L2, or whatever) - open the script editor. Move the script editor aside from the main visual pinball editor window. Open properties and the MISC section after clicking on a light. In the script editor object dropdown - the top left one, click something. You can use the cursor keys and it'll autopopulate the properties for the current selected object. It is a simple thing to scroll through lights to make sure the timer intervals are correct and make changes when needed that way.

As usual, I hope these ideas help with your projects.

Build a fire, vipers love the heat.


#2 wtiger

wtiger

    Pinball Fan

  • VIP
  • 1,148 posts
  • Location:Los Angeles, CA

  • Flag: United States of America

  • Favorite Pinball: Junkyard



Contributor

Posted 30 April 2010 - 03:40 AM

As always, thanks Destruk!

#3 The Trout

The Trout

    Enthusiast

  • Members
  • PipPipPip
  • 396 posts
  • Location:Phoenix, AZ

  • Flag: United States of America

  • Favorite Pinball: Who Dunnit

Posted 30 April 2010 - 04:10 AM

Just gotta say that I LOVE this topics. They're gonna help a ton when I man up and actually make a table from scratch.
Mary Elizabeth's Sock
It's About A Girl. And Crime. But Mostly About A Girl.

#4 destruk

destruk

    VPF Veteran

  • VPF Staff
  • 6,307 posts
  • Location:Colorado Springs, CO

  • Flag: United States of America

  • Favorite Pinball: Ultrapin!



Posted 30 April 2010 - 04:15 AM

Well, I think we need a few general debugging/bug testing threads here too. So I'll be working on that, but I think I'll need help. Is anyone out there confident enough to write up a script debugger, layout troubleshooter, and bug testing section for a table?

Build a fire, vipers love the heat.


#5 Noah Fentz

Noah Fentz

    'Rasslin' Fan

  • VPF Administrator
  • 12,191 posts
  • Location:South Lyon, MI

  • Flag: United States of America

  • Favorite Pinball: Whitewater

  • PS3 Gamer Tag: noahfentz


Contributor

Posted 02 May 2010 - 05:18 PM

QUOTE (destruk @ Apr 29 2010, 04:31 PM) <{POST_SNAPBACK}>
...I usually press TAB whenever I make a change to an object to make sure visual pinball saves the change...


You can reach him from where you are?!

laugh.gif

Thanks for all your great tutorials, destruk. I hope those wanting to build VPM recreations are reading these!

tup.gif

IdleReel.gif RumbleDMD.jpg HS2-DMD.jpg SBM.jpg ww_logo.jpg EK.jpg

 
T2.jpg Sorcerer.jpg Breakshot.jpg Firepower.jpg GorGar.jpg StarTrek.jpg


My Photobucket Resources
Whether You Believe You Can, Or You Can't, You Are Right." - Henry Ford
The future of pinball lives, it just needs to be nurtured!
If you're here to stab me in the back, you're going to have to get in line.