Documentation

Scripting Basics

Mokoi Games are written in the Pawn Language http://www.compuphase.com/pawn/.

Internal Types

List of Functions

Please note that some of these functions are in development versions and may not be available in current release.

Native Functions

Argument Functions

numargs()
- Get the number of arguments.

getarg(arg,index)
- return the value of argument.

setarg(&v,position)
- Get the number of argument

Functions related functions

FunctionID(name[])
- Return the id of the function.

FunctionCall(id)
- Calls a local function base on it's ID.

ASCII Character functions

CharLower(c)
- Returns lower case of c.

CharUpper(c)
- Returns upper case of c.

CharSwap(c)
- Returns the swapped case of c.

Whole Number functions

NumberRandom(max)
- Returns a random number between 0 and max - 1

NumberMin(value1,value2)
- Returns the lower number between value1 & value2

NumberMax(value1,value2)
- Returns the higher number between value1 & value2

NumberClamp(value,min,max)
- Return value thats has been limited between min and max.

NumberString(string[],index)
- Converts a String into whole number.

Entity Functions

Entity Position Functions

EntitySetPosition(Fixed:x,Fixed:y,Fixed:z,id[])
- Set Entities position on current map.

EntityGetPosition(&Fixed:x,&Fixed:y,&Fixed:z,id[])
- Get Entity position on current map.

Entity Functions

EntityCreate(parententity[],id[],x,y,z,map_id,idlength,args[],...)
- Creates a new entity.

EntityDelete(id[])
- Deletes a entity.

EntityGetSetting(key[],string[],id[])
- Get stored setting for entity. These are set via the Runtime Options.

EntityGetNumber(key[],id[])
- Returns stored setting for entity. These are set via the Runtime Options.

EntityPublicFunction(id[],function[],args[],...)
- Calls a function from another entity.

EntityPublicVariable(id[],variable[])
- Returns a public variable from entity.

EntityPublicVariableSet(id[],variable[],value)
- Sets a public variable on a entity.

Entity Collision Functions

CollisionFromObject(obj,type,id[])
- Set Collision rectangles from the sprite or animation data.

CollisionCheck(id1[],id2[],rect1,rect2)
- Check to see if Entity is colliding with another entity.

CollisionSet(id[],rect,type,x,y,w,h)
- Set a collision for the entity.

CollisionCalculate(id[],rect,type)
- Generate a list of entities it's colliding with.

CollisionGetCurrent(id[],current[],&angle,&dist,&rect,&type)
- Retrieves current collision from generated list.

CollisionGet(id[],rect,&x,&y,&w,&h)
- Retrieves the entity collision rectangle values.

Entity Management Functions

EntitiesList(map)
- Generate a list of entities for required map.

EntitiesNext(string[],map_id)
- Retrieves current entity name from generated list.

Rational Number Support

Fixed point numbers are the supported rational number system and allows for 3 decimal places. Floating point numbers are also support.

RealString(string[])
- Converts a String into Rational number.

RealRound(Real:value,round_method)
- Converts a Rational number into a Whole number

RealSqroot(Real:value)
- Returns the square root of a value.

RealPower(Real:value,exponent)
- Returns the value raised to the power of exponent.

RealAbs(Real:value)
- Returns Absolute value of 'value'.

RealLog(Real:value,Real:base)
- Return the logarithm

RealSin(Real:value,anglemode:mode)
- Return the sine. The input angle may be in radian, degrees or grades.

RealCos(Real:value,anglemode:mode)
- Return the cosine. The input angle may be in radian, degrees or grades.

RealTan(Real:value,anglemode:mode)
- Return the tangent. The input angle may be in radian, degrees or grades.

RealAtan2(Real:value,anglemode:mode)
- Return the arctangent of x/y. The input angle may be in radian, degrees or grades.

RealClamp(Real:value,Real:min,Real:max)
- Return value thats has been limited between min and max.

Graphics Functions

Colour arguments are a RGBA hex value such as 0xFF33BBAA, FF is red value, 33 is green, BB is blue and AA would be the alpha.

Misc Graphic Functions

GraphicsType()
- Returns the type of graphic display. Can be used to enable some effects.

GraphicsDraw(string[],GraphicTypes:type,x,y,z,w,h,c)
- Draw a Display Objects for the current frame.

SheetReference(sheet[],ref)
- Add or remove a reference for sprite sheet. Mainly used to keep a sprite sheet in memory.

SheetReplace(olds[],news[])
- Changing one sheet to another.

Animation Functions

AnimationGetLength(sheet[],anim[])
- Returns length of animation in milliseconds.

AnimationGetLength2(sheet[],anim[])
- Returns length of animation in seconds.

Future Feature AnimationCreate(string[],length)
- Creates new animation.

Future Feature AnimationAddFrame(string[],sprite[])
- Adds a frame to an animation.

Text Functions

TextSprites(able,sheet[])
- Ables the use of Sprites for text instead of the internal bitmap font.

Polygon Functions

Future Feature PolygonCreate(string[])
- Create a polygon.

Future Feature PolygonAddPoint(string[],x,y)
- Add a point to existing polygon.

Display Objects Functions

ObjectCreate(string[],GraphicTypes:type,x,y,z,w,h,c,pos)
- Creates a new Display Objects. 'string' can be a sprite name or some text.

ObjectPosition(object:id,x,y,z,w,h,pos)
- Give the Display Objects a new position and dimension.

ObjectEffect(object:id,colour,rotate,scale_w,scale_h,mirror,style,colour2)
- Change Display Objects effects.

ObjectReplace(object:id,string[],GraphicTypes:type)
- Convert Display Objects to new type.

ObjectToggle(object:id,show)
- Toggle the visibility of a Display Object.

ObjectFlag(object:id,key,value)
- Sets Display Object flags.

ObjectDelete(object:id)
- Delete a Display Objects.

ObjectInfo(object:id,&w,&h)
- Returns width and height of object.

Paths Functions

ObjectFollowPath(object:id,Fixed:speed,&x,&y,bool:loop)
- Makes object follow path.

PathPoints(object:id,point,&x,&y,&t)
- Returns Object Path point values.

Camera Functions

CameraSetScroll(bool:scroll)
- Enable Smooth scrolling.

LayerSetRotation(layer,roll,pitch,yaw)
- Change the rotation of the layer. This feature is still in development and will only be available for OpenGL display system.

LayerSetOffset(layer,Fixed:x,Fixed:y)
- Change the Offset of the layer.

LayerColour(layer,colour)
- Change the base color of the layer.

Display Object Helper Functions

ResetObjects(...)
- Reset effects on all objects passed.

HideObjects(...)
- Hides all objects passed.

ShowObjects(...)
- Shows all objects passed.

Helper Functions

These are define in the helper.inc header, so to use these functions, #include <helper> must be include at the top of the script.

Timer Functions

Countdown(&time)
- Returns true when time value is 0.

CountTimer(&time,reset)
- Returns true when time value is 0, then resets time.

Sound Helper Functions

SoundPlayOnce(&value,file[])
- Play a audio file once.

SoundPlayRepeat(&value,file[])
- Trys to repeat playing audio file.

Bits Functions

SetBit(&v,position)
- Changes a bit value

ClearBit(&v,position)
- Clears a bit value

ToggleBit(&v,position)
- Toggles a bit value

TestBit(&v,position)
- Return the bit value

SetBits(&v,value,position,size)
- Sets a range of bits.

GetBits(value,position,size)
- Sets a range of bits.

Map Functions

Maps are split into two modes, a Grid based Section which allows map switching by moving off the map and a Independent File Mode.

Mask Functions

MaskRefresh()
- Updates Mask from current Map Objects.

MaskGetValue(x,y,layer)
- Returns Mask value.

MaskFill(x,y,w,h,value)
- Fills area of mask.

Map Functions

MapSetOffset(Fixed:x,Fixed:y)
- Set the Offset from the Top-left of the map.

MapGetOffset(axis)
- Get the Offset from the Top-left of the map.

Map File Code

MapCreate(map[],create_new)
- Create a new map.

MapChange(mapid,offsetx,offsety)
- Changes to map id.

MapValid(mapid)
- Check if map id is valid.

MapCurrent(map[])
- Get Current Map ID and nmae. Note: it will load map.

MapID(map[])
- Get Map ID. Note: it will load map.

MapSave()
- Save the map

Map Section Function

SectionSet(section[],gridx,gridy)
- Changes the Section, while keeping the same grid location.

SectionGet(section[],&gridx,&gridy)
- Get the current section name.

SectionValid(name[],gridx,gridy)
- Check if a grid location on a section is valid.

Main Functions

Engine Functions

KeyboardWatch(able)
- Send Keyboard input to KeyboardInput function in the current entity.

GameState(newstate)
- Get/Set Global State.

GameFrame()
- Return the length of last frame in milliseconds.

GameFrame2()
- Return the length of last frame in seconds as a fixed point number.

Log Functions

GameLog(text[],...)
- Prints formatted text to a text file.

DebugText(text[],...)
- Prints formatted text to the debug console.

Save Functions

GameSave(slot,detail[64])
- Save Current Game.

GameLoad(slot)
- Load Game from Slot.

GameSetDetails(slot,array[64])
- Set Save Game Details.

GameGetDetails(slot,array[64])
- Get Save Game Details.

GameDetails(gameid,slot,array[64])
- Get another game save details.

Input Functions

InputButton(input,player)
- Returns Button value for Player.

InputAxis(axis,player)
- Returns Axis value for Player.

InputPointer(axis,player)
- Returns Pointer value for Player.

InputButtonSet(input,value,player)
- Set Button value for the Player.

InputAxisSet(axis,value,player)
- Set Axis value for the Player.

InputPointerSet(axis,value,player)
- Set Pointer value for the Player.

Misc Functions

MiscGetWidth(id[])
- Get Width of Map, Screen or Sprite.

MiscGetHeight(id[])
- Get Height of Map, Screen or Sprite.

Language Functions

LanguageString(line,returnstring[])
- Get String from Language File.

LanguageSet(lang[])
- Loads a new language set. note: previous strings may have updated.

Dialog Functions

DialogShow(line,callback[])
- Shows Dialog box.

DialogGetString(line,returnstring[])
- Get String from Dialog File.

DialogPlayAudio(line)
- Play Dialog.

Audio Functions

AudioVolume(AudioDevice:device,level)
- Sets Audio device volume.

AudioPlaySound(file[],x,y)
- Play Sound Effect. Also return length of file in seconds.

AudioPlayMusic(file[],loop,fadeLength)
- Play Music.

Config Functions

ConfigGetString(config[],value[])
- Get Engine config as a string.

ConfigGetNumber(config[])
- Get Engine config as a number.

ConfigSetString(config[],value[])
- Update Engine config.

File Listing Functions

FileGetList(strings[][],directory[])
- List File in a directory.

Network Functions

These are define in the network.inc header, so to use these functions, #include <network> must be include at the top of the script.

Network Connection Functions

EntityActive()
- Ables networking syncing for entity.

EntityNetworkSync(bool:reliable)
- Send network sync message.

NetworkConnect(name[],password[],email[])
- Connect to Server.

NetworkDisconnect()
- Disconnect from Server.

NetworkMessage(reliable,serveronly,message[],length)
- Sends a message to entity with the same unique id.

NetworkPlayerName(player,name[])
- Gets network player name.

Online Functions

OnlineUpdate()
- "Future Function" Downloads latest game patches.

OnlineSubmitScore(data[4])
- Future Function" Sumbit score to online scoreboard.

OnlineSave(data[64])
- "Future Function" Online save.

OnlineData(callback[32],url[128],post[])
- Downloads URL to the callback function. If data is supported media, it will be loaded, and details pass to callback function.

Player Functions

Future Feature PlayerAdd()
- Adds new player

Future Feature PlayerRemove(num)
- Removes a players

Future Feature PlayerCount()
- Returns the amount of active players.

Future Feature PlayerMaxCount()
- Returns the amount of available players allow in the game.

Future Feature PlayerSetControl(player)
-

Reference pages


Comments

Comming Soon