-
Notifications
You must be signed in to change notification settings - Fork 3
Python API
GraLL 2 inherits Python functionality from the NGF (nikki’s Game Framework) Python addon, which GraLL 2 uses. You can read the documentation for NGF Python here.
This is a listing of functionality available in the ‘GraLL2’ module. It includes global functions, and global variables. For GameObject member events, methods etc., visit the page for that particular GameObject. A listing of GameObject types is provided in the GameObject Types page.
GraLL2.showMessage(message, time)
Shows a message. If time > 0, the message fades after the time (in seconds) elapses.
GraLL2.nextWorld()
Go to the next NGF World.
GraLL2.previousWorld()
Go to the previous NGF World.
GraLL2.gotoWorld(n)
Go to the NGF World with the given index (0 = first).
GraLL2.winLevel()
The current level is ‘completed’.
GraLL2.loseLevel()
The current level has been ‘lost’.
GraLL2.loadNgf(name)
Loads the NGF level with the given name, as specified in the .ngf file. or the ‘scene name’ in Blender. If you want to replace the current scene, remember to clear the level (GraLL2.clearLevel()) first.
GraLL2.clearLevel()
Clears the level (destroys all objects).
GraLL2.serialise(name)
Saves the game state to a file with the given name and extension ‘.sav’ under ‘Saves’ in the user directory.
GraLL2.deserialise(name)
Restores the game state from a file with the given name and extension ‘.sav’ under ‘Saves’ in the user directory.
GraLL2.switchDimension()
Makes GraLL switch dimensions.
GraLL2.setDimension(n)
Sets the global dimension to the given one (1 or 2).
GraLL2.fadeInColour(time)
Fades in the the fade colour in given time.
GraLL2.fadeOutColour(time)
Fades out the the fade colour in given time.
GraLL2.fadeInOutColour(in,pause,out)
Fades in and out the colour in respective times, with a pause in between.
GraLL2.saveExists(n)
Whether save for level n exists.
GraLL2.removeSave(n)
Remove level n’s save.
GraLL2.getCurrentLevelNum()
Returns the number of the currently running level.
GraLL2.playMusic(track)
Plays music track given.
GraLL2.crossFadeMusic(track,time)
Crossfades from playing track to given track in given time.
GraLL2.setMusicGain(n)
Sets gain (volume) of currently playing track.
GraLL2.getMusicGain()
Gets gain (volume) of currently playing track.
GraLL2.startRecordingVideo(p)
Starts recording video with the given time period between each frame.
GraLL2.stopRecordingVideo()
Stops recording the video.
GraLL2.setControl(control,key)
Sets the given control to the given key, where ‘control’ is one of:
‘forward’
‘backward’
‘left’
‘right’
‘dimensionSwitch’
‘selfDestruct’
‘peepLeft’
‘peepRight’
Possible ‘key’ values are the strings displayed in the ‘Options’ dialog in the ‘Controls’ tab for the keyboard controls.
GraLL2.getControl(control)
Gets the key for the given control, where ‘control’ is one of:
‘forward’
‘backward’
‘left’
‘right’
‘dimensionSwitch’
‘selfDestruct’
‘peepLeft’
‘peepRight’
GraLL2.clickObject()
Goes into ‘click’ mode. The clicked object can be retieved using ‘getClickedObject()’. It is also saved in the global ‘clicked’ variable. Use carefully! If the clicked object was destroyed this will cause the game to crash!
GraLL2.getClickedObject()
Retrieve the clicked object. The object is also saved in the global ‘clicked’ variable. Use carefully! If the clicked object was destroyed, this will cause the game to crash!
GraLL2.screenshot(highres,name,extension)
Takes a screenshot. The file is saved under the ‘Screenshots’ in the GraLL 2 user directory, with the given name and extension (‘.jpg’, ‘.png’). If highres is true, a high-resolution screenshot is taken.
GraLL2.setBonusTime(time)
Sets the bonus time to given time.
GraLL2.getBonusTime()
Returns the bonus time.
GraLL2.clicked
The object last ‘clicked’. If the object was deleted after clicking, trying to dereference this handle will cause the game to crash! D: