Author Topic: How my coding has improved....  (Read 6471 times)

0 Members and 1 Guest are viewing this topic.

Online Itchigo

  • Victory is mine!!
  • Administrator
  • Pinball Wizard
  • *****
  • Posts: 1,407
  • Country: us
  • Karma: +10/-0
How my coding has improved....
« on: April 08, 2013, 07:52:20 PM »
As my coding has improved I've gone back into my old games and recoded them much more efficiently. What has surprised  me is the number of lines I have been able to eliminate. So far I've been averaging taking out about 300 lines or so. It's almost become a game to see how few lines I can use. I have Olympics down to 500 lines, but that's not the best...
Distant World, my new wip was started some time ago. I went through it and started out with 2,250 lines. I got it down to 1,670 lines. Whoa.
Tremble in fear! Behold my Bankai!


Offline yogiholzer

  • Oldie
  • Newbie
  • *
  • Posts: 48
  • Karma: +0/-0
    • http://yogiholzer.bplaced.net/
Re: How my coding has improved....
« Reply #1 on: April 09, 2013, 12:34:11 PM »
It's because you just put the content from several lines into one, or?  :tongue:

I couldn't even manage that.  :grin:


Offline faralos

  • Full Member
  • ***
  • Posts: 235
  • Karma: +1/-0
Re: How my coding has improved....
« Reply #2 on: April 09, 2013, 01:08:53 PM »
it's probably from collections
 writing a collection takes about ten lines or so
 but to do the coding without collections may take up to thirty lines of script
 for that same routine
I am never wrong Once I thought I was
 but I was merely mistaken

Offline yogiholzer

  • Oldie
  • Newbie
  • *
  • Posts: 48
  • Karma: +0/-0
    • http://yogiholzer.bplaced.net/
Re: How my coding has improved....
« Reply #3 on: April 09, 2013, 02:41:34 PM »
Probably. I just wanted to joke a little.

Online Itchigo

  • Victory is mine!!
  • Administrator
  • Pinball Wizard
  • *****
  • Posts: 1,407
  • Country: us
  • Karma: +10/-0
Re: How my coding has improved....
« Reply #4 on: April 09, 2013, 07:54:42 PM »
Mainly collections. Some doubles, and not written out well. Knowing what I know now.... I'm surprised it worked at all. :whistle: I wasn't tooting my own horn I was just surprised at how much was eliminated. Just when I thought I couldn't find more, I am down to 1620. I'm shooting for 1500- ish, lol. Just for grins. :cheers: I remember Cowboys and Indians I thought was done so well, I had 9 collections. The Tomb has 49!  :smiley-computer012:

Here's an example.

 Sub C1_Hit()                         'If the DropTarget C1 is hit...
 If  Tilt= False Then                 'If the game isn't tilted.
     PlaySound"DTDrop"                'Play the sound.
     PlaySound"Nuke1"                 'Play the sound.
     AddScore 500                     'Add the score.
 CALL AddBonus(1000) 'Add bonus. Copy and paste this line to add Bonus with any event (Bonus is in increments of 1000).
     C1.IsDropped=True                'Drop the target C1.
 End If
 End Sub

 Sub C2_Hit()                         'If the DropTarget C2 is hit...
 If  Tilt= False Then                 'If the game isn't tilted.
     PlaySound"DTDrop"                'Play the sound.
     PlaySound"Nuke1"                 'Play the sound.
     AddScore 500                     'Add the score.
 CALL AddBonus(1000) 'Add bonus. Copy and paste this line to add Bonus with any event (Bonus is in increments of 1000).
     C2.IsDropped=True                'Drop the target C2.
 End If
 End Sub
 
 Sub C3_Hit()                         'If the DropTarget C3 is hit...
 If  Tilt= False Then                 'If the game isn't tilted.
     PlaySound"DTDrop"                'Play the sound.
     PlaySound"Nuke1"                 'Play the sound.
     AddScore 500                     'Add the score.
 CALL AddBonus(1000) 'Add bonus. Copy and paste this line to add Bonus with any event (Bonus is in increments of 1000).       
     C3.IsDropped=True                'Drop the target C3.
 End If
 End Sub

 Sub C4_Hit()                         'If the DropTarget C4 is hit...
 If  Tilt= False Then                 'If the game isn't tilted.
     PlaySound"DTDrop"                'Play the sound.
     PlaySound"Nuke1"                 'Play the sound.
     AddScore 500                     'Add the score.
 CALL AddBonus(1000) 'Add bonus. Copy and paste this line to add Bonus with any event (Bonus is in increments of 1000).       
     C4.IsDropped=True                'Drop the target C4. 
     Lock1.State=2                 
 End If
 If  Savelock1.State=1 Then
     Kicker2CTimer.Enabled=True 
 End If
 End Sub

Has become...

 Sub CTargets_Hit(x)                  'If target is hit...
 If  Tilt= False Then                 'If the game isn't tilted.
     PlaySound"DTDrop"                'Play the sound.
     PlaySound"Nuke1"                 'Play the sound.
     AddScore 500                     'Add the score.
 CALL AddBonus(1000) 'Add bonus. Copy and paste this line to add Bonus with any event (Bonus is in increments of 1000).
     CTargets(x).IsDropped=True       'Drop the target.
 End If
 If  C4.Isdropped=True Then
     Lock1.State=2
 If  Savelock1.State=1 Then
     Kicker2CTimer.Enabled=True 
 End If
 End If
 End Sub

Or this:

 '******************** Triggers *******************************************************************************************
 
 Sub LeftInlane_Hit()                 'Left Inlane has been hit.
 If  Tilt= False Then                 'If the game isn't tilted.
     Playsound"Inlane"                'Play the sound.
     Wall180.IsDropped=True           'Drop the rollover switch.
     AddScore 1000                     'Add the score.
 End If
 End Sub

 Sub LeftInlane_UnHit()
     Wall180.IsDropped=False          'Raise the rollover switch.
 End Sub
'UnHit means when the ball leaves the switch. The sound doesn't play when you hit it, but when the ball leaves the switch.
 Sub RightInlane_Hit()                'Right Inlane has been hit.
 If  Tilt= False Then                 'If the game isn't tilted.
     Playsound"Inlane"                'Play the sound.
     Wall446.IsDropped=True           'Drop the rollover switch.
     AddScore 1000                     'Add the score.
 End If
 End Sub

 Sub RightInlane_UnHit()
     Wall446.IsDropped=False          'Raise the rollover switch.
 End Sub
 'UnHit means when the ball leaves the switch. The sound doesn't play when you hit it, but when the ball leaves the switch.
 Sub Rightoutlane_Hit()               'Right outlane has been hit.
 If  RSpecial.State=1 Then            'If the Right special light is on...
     PlaySound"Knocker"               'Play the sound.
     PlaySound "Replay"               'Play the sound.
     AddScore 5000                    'Add the score.
     Wall449.IsDropped=True           'Drop the rollover switch.
     Credits=Credits+1                'Add a credit.
     EMReel3.SetValue(Credits)         'Update credit display.
     'Controller.B2SSetscore 6,Credits
 Else                                 'If the right special light is not on.
     Playsound"Smartbomb"             'Play the sound.
     AddScore 5000                    'Add the score.
     Wall449.IsDropped=True           'Drop the rollover switch.
 End If
 End Sub

 Sub Rightoutlane_UnHit()
     Wall449.IsDropped=False          'Raise the rollover switch.
 End Sub
 'UnHit means when the ball leaves the switch. The sound doesn't play when you hit it, but when the ball leaves the switch.
 Sub Leftoutlane_Hit()                'Left outlane has been hit.
 If  LSpecial.State=1 Then            'If the Left special light is on...
     PlaySound"Knocker"               'Play the sound.
     PlaySound "Replay"               'Play the sound.
     AddScore 5000                    'Add the score.
     Wall452.IsDropped=True           'Drop the rollover switch.
     Credits=Credits+1                'Add a credit.
     EMReel3.SetValue(Credits)         'Update credit display.
     GI1Timer.Enabled=True
     'Controller.B2SSetscore 6,Credits
 Else                                 'If the left special light is not on.
     Playsound"Smartbomb"             'Play the sound.
     AddScore 5000                    'Add the score.
     Wall452.IsDropped=True           'Drop the rollover switch.
 End If
 End Sub

 Sub Leftoutlane_UnHit()
     Wall452.IsDropped=False          'Raise the rollover switch.
 End Sub

Has become:

 Sub Inlanes_Hit(x)                   'Inlane has been hit.
 If  Tilt= False Then                 'If the game isn't tilted.
     Playsound"Inlane"                'Play the sound.
     InlaneSwitches(x).IsDropped=True 'Drop the rollover switch.
     AddScore 1000                    'Add the score.
 End If
 End Sub

 Sub Inlanes_UnHit()
     InlaneSwitches(x).IsDropped=False'Raise the rollover switch.
 End Sub

 Sub Outlanes_Hit(x)                  'Outlane has been hit.
 If  LSpecial.State=1 Then            'If the special light is on...
     PlaySound"Knocker"               'Play the sound.
     PlaySound "Replay"               'Play the sound.
     AddScore 5000                    'Add the score.
     OutlaneSwitches(x).IsDropped=True'Drop the rollover switch.
     Credits=Credits+1                'Add a credit.
     EMReel3.SetValue(Credits)         'Update credit display.
     GI1Timer.Enabled=True
     'Controller.B2SSetscore 6,Credits
 Else                                 'If the left special light is not on.
     Playsound"Smartbomb"             'Play the sound.
     AddScore 5000                    'Add the score.
     OutlaneSwitches(x).IsDropped=True'Drop the rollover switch.
 End If
 End Sub

 Sub Outlanes_UnHit(x)
     OutlaneSwitches(x).IsDropped=False'Raise the rollover switch.
 End Sub
« Last Edit: April 09, 2013, 08:09:10 PM by Itchigo »
Tremble in fear! Behold my Bankai!


Offline yogiholzer

  • Oldie
  • Newbie
  • *
  • Posts: 48
  • Karma: +0/-0
    • http://yogiholzer.bplaced.net/
Re: How my coding has improved....
« Reply #5 on: April 10, 2013, 04:55:08 PM »
Please repeat, but all in German please. That are "hieroglyphics" for me.

Offline faralos

  • Full Member
  • ***
  • Posts: 235
  • Karma: +1/-0
Re: How my coding has improved....
« Reply #6 on: April 11, 2013, 12:44:04 PM »
what you did is still far beyond anything I understand
 so I guess I'll still have tons of coding in my pins
 except for maybe collections instead of writing it out longhand
I am never wrong Once I thought I was
 but I was merely mistaken

Online Itchigo

  • Victory is mine!!
  • Administrator
  • Pinball Wizard
  • *****
  • Posts: 1,407
  • Country: us
  • Karma: +10/-0
Re: How my coding has improved....
« Reply #7 on: April 11, 2013, 05:09:46 PM »
Here's one example. Say you have 3 toplanes, 3 switches, and 3 toplane lights.

Toplanes(x)_Hit()                  Toplanes is a collection, and whichever one is hit will register because of the (X)

Toplane switches(x).Isdropped=True      Here's the beautiful part. Whichever toplane was hit, the corresponding switch will drop. Why is this? It's because the order it was put in the collection. The same goes for the lights. It's all in the order it was put into the collection. This assumes this:

Toplanes collection:
Toplane1
Toplane2
Toplane3

Toplaneswitch collection
Toplaneswitch1
Toplaneswitch2
Toplaneswitch3

Toplanelightscollection
Toplanelight1
Toplanelight2
Toplanelight3

Assuming they were put into the collection, in this correct order, when toplane 1 is hit, Toplaneswitch1 will go down, and Toplanelight1 will go on.

I can't take credit for this, Koadic taught me this, and we all know how smart he is. I'm just beating it into the ground like a dead .... where's my dead horse emote? :whiteflag:
« Last Edit: April 11, 2013, 05:12:11 PM by Itchigo »
Tremble in fear! Behold my Bankai!


Offline faralos

  • Full Member
  • ***
  • Posts: 235
  • Karma: +1/-0
Re: How my coding has improved....
« Reply #8 on: April 12, 2013, 09:47:26 AM »
Beating a dead horse image
I am never wrong Once I thought I was
 but I was merely mistaken