I did not chane how table works. It is not about it.
I previous version real call to BAM look like this:
Code:
ExecuteGlobal LoadExternalScript("!BAM CREATEBALL 1 0 192 192 192 basket_452 basket_334 basket_334" )
This line orders BAM to create custom ball with params:
- Red color value for custom ball (used to detect it) = 1
- Index of ball used to store data about ball inside BAM = 0
- color red = 192
- color green = 192
- color blue = 192
- texture name for dirt = "basket_452"
- texture name for reflection = "basket_334"
- texture name for reflection in playfield = "basket_344"
All params and command is passed as text.
"!BAM" is only marker used in BAM to detect command.
Rest in script was only needed to build that text and make function look more friendly.
In BAM i have to intercept I/O operation, parse string and execute command.
I can't return any value.
I is slow.
I have to manage in VBScript BAM internal index of custom balls. (See: BAM_BallCounter). After every ball creation i execute:
Code:
BAM_BallCounter = BAM_BallCounter + 1
If BAM_BallCounter >= BAM_MAX_BALLS Then
BAM_BallCounter = 0
End If
I have to in VBScript calc color values passed to FP CreateBall, like this:
Code:
Red = BAM_BALL_RED_COLOR
Green = BAM_BallCounter Mod 256
Blue = BAM_BallCounter / 256
And finally i call FP Create ball function with caluclated values:
Code:
source.CreateBall Red Green Blue BallID
Now real call to BAM to do same thing:
Code:
Dim BallCreationRaport
Set BallCreationRaport = xBAM_CreateBall(192,192,192,"basket_452","basket_334","basket_334")
I don't send to BAM red color value used to mark it.
I don't send index of custom BAM. Now it is alway inside BAM.
In return i get structure with informations. So i don't have to calc params, i just call FP funtion:
Code:
Kicker.CreateBall BallCreationRaport.Red, BallCreationRaport.Blue, BallCreationRaport.Green BallID
Now i combine all above in to one single function to show where is differenct:
Old version:
Code:
Dim BallCounter
BallCounter = 0
Const BAM_BALL_RED_COLOR = 1
Sub BAM_CreateBall(Source, Red, Green, Blue, BallID, Dirt, Reflection, ReflectionInPlayfield)
Dim cr
cr = BAM_BALL_RED_COLOR
ExecuteGlobal LoadExternalScript("!BAM CREATEBALL 1 "&cr&" "&BAM_BallCounter&" "&Red&" "&Green&" "&Blue&" "&Dirt&" "&Reflection&" "&ReflectionInPlayfield)
Red = BAM_BALL_RED_COLOR
Green = BAM_BallCounter Mod 256
Blue = BAM_BallCounter / 256
BAM_BallCounter = BAM_BallCounter + 1
If BAM_BallCounter >= BAM_MAX_BALLS Then
BAM_BallCounter = 0
End If
Source.CreateBall Red, Green, Blue, BallID
Sub End
If you need in script index of custom ball (need as argument for BAM_UpdateBall) you have to red
BAM_BallCounter befor you call BAM_CreateBall
In new version
Code:
Sub BAM_CreateBall(Source, Red, Green, Blue, BallID, Dirt, Reflection, ReflectionInPlayfield)
Dim bi
Set bi = xBAM_CreateBall(Red, Green, Blue, BallID, Dirt, Reflection, ReflectionInPlayfield)
Source.CreateBall bi.Red, bi.Green, bi.Blue BallID
Sub End
again if you need in script index of custom ball, this time you read
xBAM_BallID.
Params for source.CreateBall are calculated inside BAM.
Here is what i can do now:
I can move whole custom ball managment from script to BAM. So all what will i left in script will look like this:
Code:
Dim BALL_A, BALL_B, BALL_C, BALL_D, BALL_E
BALL_A = BallManager.DefineCustomBall(192,192,192,"basket_452","basket_334","basket_334")
BALL_B = BallManager.DefineCustomBall(192, 1,192,"basket_452","basket_334","basket_334")
BALL_C = BallManager.DefineCustomBall(192,192,192,"anytexname","basket_334","basket_334")
BALL_D = BallManager.DefineCustomBall(192,192,192,"basket_452","basket_334","basket_334")
BALL_E = BallManager.DefineCustomBall(192,192,192,"basket_452","basket_334","basket_334")
Dim TransformationForKickier2
Set TransformationForKickier2 = BallManager.CreateTransformation
TransformationForKickier2.AddRule(BALL_A, BALL_B)
TransformationForKickier2.AddRule(BALL_B, BALL_C)
TransformationForKickier2.AddRule(BALL_C, BALL_D)
TransformationForKickier2.AddRule(BALL_D, BALL_E)
TransformationForKickier2.AddRule(BALL_E, BALL_A)
Sub NewCreateBall(source, ballName)
Dim bi
Set bi = BallManager.CreateBall(ballName)
source.CreateBall bi.Red, bi.Blue, bi.Green, bi.BallNumber
Sub End
Sub Kicker1_Hit()
BallManager.UpdateBall(ballID, BALL_B)
Sub End
Sub Kicker2_Hit()
BallManager.UseTranformation(ballID, TransformationForKickier2)
Sub End
See?
BallManager will be like built in FP object.
Only restriction will be same as in previous version. Red color of normal/standard ball can't be =1
If you give me time, i will put it in next BAM today.