bw logo

Chapter 4. Troubleshooting

4.1. My game's personality script takes a while to initialise

The application will call method setProgress until it reaches 100%. Once this value is reached, the personality script init method is called.

If you want to seamlessly incorporate the loading of the application with the loading of the personality script, then make your loading bar GUI script rescale the incoming values.

For example in fantasydemo/res/scripts/client/Helpers/ProgressBar.py, here are the code snippets that perform this task:

def setMinMax( self, min, max ):
    self.min = min
    self.max = max

def setProgress( self, value ):
    #remap value into the correct range
    range = self.max - self.min
    value = self.min + value*range
    self.component.bar.clipper.value = value

def onLoad( self, section ):
    self.phase1Ratio = section.readFloat( "phase1Ratio", self.phase1Ratio )

def startPhase( self, num ):
    if num == 1:
        self.setMinMax( 0.0, self.phase1Ratio )
    else:
        self.setMinMax( self.phase1Ratio, 1.0 )

Incorporating the loading of application with loading of personality script

FantasyDemo's loading bar loads a value from the .gui file called phase1ratio. This is set to 0.66, meaning that the application's initialisation goes up to 66% of the progress bar. Therefore 33% of the time will be used by the personality script to load chunks.