Scripting
Animation Functions
Warning
To use these functions you must include #include <animation.inc> at the top of the script.
AddAnimframe
AddAnimframe(ident[], x, y, code[]);
Add a frame to animation ident[], x and y are displacement variables used if the sprite is misplaced or of different size along with similar things, code[] is the name of the sprite.
CreateAnim
CreateAnim(speed, ident[]);
Create an animation available to the current script file. "speed" is counted in frames per second.
CreateAnimWithID
CreateAnimWithID(speed, ident[]);
Create a global animation available in all script files after creation. (speed is counted in FPS)
DeleteAnim
DeleteAnim(ident[]);
Delete the animation ident[].
DrawAnim
DrawAnim(ident[], x, y, depth, layer = 0, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);
Draw the animation at x & y(world coordinates). Depth is the position from bottom (0) to top (***) on the current layer (the animation is drawn above anything on a lower depth). Red, green, blue and alpha, along with rotation and scale can also be set.
DrawAnimNoInc
DrawAnimNoInc(ident[], x, y, depth, layer = 0, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);
Same as DrawAnim, but this version does not increase the current frame, the frame stays at the same place until increased by other means.
FinishedAnim
FinishedAnim(ident[]);
Returns true if the animation is at it's last frame.
GetAnimCount
GetAnimCount(ident[]);
Returns the current animation frame.
GetAnimHeight
GetAnimHeight(ident[]);
Return the height of the current sprite in the animation.
GetAnimImage
GetAnimImage(ident[], code[]);
Gets Image from the current frame of animation.
GetAnimWidth
GetAnimWidth(ident[]);
Return the width of the current sprite in the animation.
GetMaxAnim
GetMaxAnim(ident[]);
Return the value for the last animation frame in the animation.
IncrementAnim
IncrementAnim(ident[]);
Increment the current animation frame by 1.
SetAnimCount
SetAnimCount(ident[], val);
Set the current animation frame to "val".
SetAnimDirection
SetAnimDirection(ident[], val);
Set the direction of the animation ident[]. (1 is forward, -1 is backwards)
SetAnimLoop
SetAnimLoop(ident[], doesloop);
Set true or false, if the animation should loop, or stop at the last frame.
SetAnimSpeed
SetAnimSpeed(ident[], speed);
Set the speed of animation ident[] to "speed". (speed is counted in FPS)
General Functions
Warning
To use these functions you must include #include <general.inc> at the top of the script.
AKey
AKey();
Return TRUE if A is pressed
CalculateAngle
CalculateAngle(x1,y1,x2,y2);
Returns Angle from x1,y1 to x2,y2.
CheckForHoleXY
CheckForHoleXY(x,y);
Return Hole type if Hole exist at x,y.
CheckMask
CheckMask(x, y, checkForObjects = 0);
Returns Mask value at x,y. If checkForObjects is TRUE, it will return 0, if their is a collision rectangle at x,y.
ClearRestartTable
ClearRestartTable();
Clears Restart Table.
DownKey
DownKey();
Return true if DOWN is pressed.
DrawBitmapText
DrawBitmapText(string[], x, y, style = 1, red = 255, green = 255, blue = 255, alpha = 255, scale = 200);
Writes text using images at the screen at screen x,y. The Text Images are currently are _OutsideSheet1. style can't not be changed.
DrawImage
DrawImage(code[], x, y, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);
Draw code[] at x/y. Places image above all sprites. Position is not based on world coordinates, but rather screen coordinates, ranging from 0,0 -> 640,480
DrawLine
DrawLine(x1, y1, x2, y2, width, red, green, blue, aplha = 255);
Draws a line on screen from x1, y1 to x2, y2.
DrawRectangle
DrawRectangle(x1, y1, x2, y2, red, green, blue, alpha = 255, angle = 0);
Draws a rectangle on the screen.
DrawText
DrawText(string[], x, y, red = 255, green = 255, blue = 255, alpha = 255);
Writes text at the screen at screen x,y. To change the text size you must use SetTextSize( size ). Arial is the font used.
EnableControls
EnableControls( enable );
Enable/Disable the key input.
EnterKey
EnterKey();
Return TRUE if ENTER is pressed.
FadeTo
FadeTo(red, green, blue, speed);
Fades screen to a color. Return False until it's finished. Note FadeTo(255, 255, 255, speed) will return the screen to normal not white.
FinishedReading
FinishedReading();
Returns true if you completed reading all the current messages.
FirstRun
FirstRun();
Returns true if the current script is running for the first time. Screens/Groups scripts are running for the first time every time you enter them.
GameOver
GameOver();
this just makes a game over screen, can be useful in some ocasions but is only really used in player1.zes
GetDayCount
GetDayCount();
Returns current day. note: start at Zero
GetGlobal
GetGlobal(index);
Returns Global "index".
GetGroupMaxX
GetGroupMaxX();
Returns the Group max. X value.
GetGroupMaxY
GetGroupMaxY();
Returns the Group max. Y value.
GetGroupMinX
GetGroupMinX();
Returns the Group min. X value.
GetGroupMinY
GetGroupMinY();
Returns the Group min. Y value.
GetHeight
GetHeight(ident[]);
Return the height of a sprite.
GetHourCount
GetHourCount();
Returns current hour.
GetLastAnswer
GetLastAnswer();
returns value of last answer.
GetLocal
GetLocal(index);
Returns Local "index". A Local value available to that group only.
GetLowerLevelX
GetLowerLevelX();
Gets the screen something falls to when it falls down a hole.
GetLowerLevelY
GetLowerLevelY();
Gets the screen something falls to when it falls down a hole.
GetMinuteCount
GetMinuteCount();
Returns current minute.
GetPauseLevel
GetPauseLevel();
Returns the pause level.
GetWidth
GetWidth(ident[]);
Return the width of a sprite.
GetWorldX
GetWorldX();
Return the WorldX Coordinates.
GetWorldY
GetWorldY();
Return the WorldY Coordinates.
InitialPlayerX
InitialPlayerX();
Return Player starting X postion.
InitialPlayerY
InitialPlayerY();
Return Player starting Y postion.
InitTextBox
InitTextBox(string[], wid, priority);
Displays a text box on screen with the width of "wid". Setting priority to true, will take over a previous text box. To added a line break use ` in "string"
LeftKey
LeftKey();
Return TRUE if LEFT is pressed.
NearPoint
NearPoint(x1, y1, x2, y2, dist);
Return TRUE if x1 & y1 is within the range of dist from x2 & y2.
PlayMusic
PlayMusic(code[], fade);
Stop playing current music, then plays "code". If "Fade" is true, music would fading out & in when swapping.
PlaySound
PlaySound(code[], volume = 128);
Plays a sound at wanted "volume".
PutSprite
PutSprite(ident[], valx, valy, vald, layer = 0, r = 255, g = 255, b = 255, a = 255, rot = 0, scale = 100);
Draws Sprite "ident" at screen x/y. vald is the depth or z-index. layer is what layer is dawn on. r,g,b,a are the Red,Green, Blue, Alpha value.
QKey
QKey();
Return TRUE if Q is pressed
RightKey
RightKey();
Return TRUE if RIGHT is pressed.
SetAKey
SetAKey(val);
Set AKey Flag to val.
SetDayCount
SetDayCount(val);
Set current day.
SetDayLength
SetDayLength(val);
Set how long a Day is, val is in seconds, with default of 1800.
SetDownKey
SetDownKey(val);
Manually set the state of the down key.
SetEnterKey
SetEnterKey(val);
Set EnterKey Flag to val.
SetGlobal
SetGlobal(index, val);
Sets Global "index" to val.
SetHourCount
SetHourCount(val);
Set current hour.
SetLeftKey
SetLeftKey(val);
Set LeftKey Flag to val.
SetLocal
SetLocal(index, val);
Sets Local "index" to val. A Local values is only available to that group.
SetLowerLevel
SetLowerLevel(x, y);
Set the level you fall to when you walk over a hole. x & y are world values.
SetMinuteCount
SetMinuteCount(val);
Set current minute.
SetMusicFadeSpeed
SetMusicFadeSpeed(speed = 110);
Set the speed the music fade to when swapping.
SetMusicVolume
SetMusicVolume(volume);
Set the volume of the groups music to "volume". Volume is between 0-255
SetPauseLevel
SetPauseLevel(val);
- Unpaused
- Paused
- Used when Wiping
- Used when Saving/Loading
SetQKey
SetQKey(val);
Set QKey Flag to val.
SetRestartPoint
SetRestartPoint(x, y);
This is useful for having your quest start you out in your house but later on have you restart in a dungeon once you get to one
SetRestartTable
SetRestartTable(index, x, y, desc[] );
Set Restart Table "index" to x,y;
SetRightKey
SetRightKey(val);
Set RightKey Flag to val.
SetSKey
SetSKey(val);
Set SKey Flag to val.
SetSpriteAlpha
SetSpriteAlpha( spriteCode[], newAlpha);
Set alpha for sprites called spriteCode[]
SetTextBoxColor
SetTextBoxColor(red, green, blue, alpha);
Changes the Text Color inside of the Text Box.
SetTextSize
SetTextSize( size );
Set the text size for DrawText, Font use is Arial.
SetUpKey
SetUpKey(val);
Set UpKey Flag to val.
SetWKey
SetWKey(val);
Set WKey Flag to val.
SetWorldX
SetWorldX(val);
Set the WorldX to val.
SetWorldY
SetWorldY(val);
Set the WorldY to val.
SKey
SKey();
Return TRUE if S is pressed
TextFile
TextFile(string[]);
Writes string[] into the error-log file in the OpenZelda section.
ToFile
ToFile(value);
Writes "value" into the error-log file in the OpenZelda section.
ToString
ToString(val, string[]);
Copies a numeric value in val to the string.
UpdateWorldCo
UpdateWorldCo(x, y);
Move Viewpoint to x,y.
UpKey
UpKey();
Return TRUE if UP is pressed.
Wipe
Wipe(direction, speed);
Wipes screen to a direction. Used when changing groups
WKey
WKey();
Return TRUE if W is pressed.
Entity Functions
Warning
To use these functions you must include #include <entity.inc> at the top of the script.
AllocateStrings
AllocateStrings(ident[], numstr, length);
Allocates the number(numstr) of strings for the entity. "length" is the length of all strings
AngleCollide
AngleCollide(ident[], val1, val2, val3, val4, val5, val6);
Checks for collisions. Returns TRUE if it's hits some thing. val1 = distance (radius?) from ident's X, Y values plus the offset values. val2 = Which directions to check for collision. See Angle checks chart for details. val3 = Highest Mask value to check for. val4(bool) = Check for holes?. val5 = X offset. val6 = Y offset. Angle Checks Chart:. note: will check up to that value. 1. Ident's Angle;. 2. Ident's Angle + 45 degrees;. 3. Ident's Angle - 45 degrees;. 4. Ident's Angle + 90 degrees;. 5. Ident's Angle - 90 degrees;
AngleMove
AngleMove(ident[]);
Move the entity using the angle in GetMoveAngle(). (This moves the X/Y coordinates)
CallFunction
CallFunction(ident[], isLibrary, funcname[], typestr[], ...);
Call a public function in entity ident[]. If no entity has that ID, entity with the filename will be created. isLibrary is a bool value, if it's set to true, the function act as part of the current entity. funcname[] is the name of the function. If no public function exist, this will return -1 typestr[] is the order of the next few variables, s = string, n = value. ex. (**, "snnss", "blah", 2, 1, "Hey", "Buddy")
ChangeDirection
ChangeDirection(ident[]);
Changes the direction of the entity to a new one.
CheckForHole
CheckForHole(ident[]);
Check if entity collides with a hole.
ClearCollisionRect
ClearCollisionRect(ident[], index);
Delete collision rectangle "index".
Collide
Collide(ident[], ident2[]);
Check if any collision rectangle in ident[] collides with any in ident2[].
CollideAll
CollideAll(ident[], ident2[]);
Check if all collision rectangles in ident[] collides with all in ident2[].
CollidePoint
CollidePoint(ident[], x, y);
Check if the point (x, y) falls within the collision rectangles of the Entity
CreateEntity
CreateEntity(code[], x, y, ident[]);
Creates a Entity at x,y sending the it's unique name to "code".
CreateEntityWithID
CreateEntityWithID(code[], x, y, ident[]);
Creates a Entity at x,y and give it the name "code".
DeleteEntity
DeleteEntity(ident[]);
Delete the entity ident[]. basicly quits that entity.
GetAnglePointX
GetAnglePointX(ident[], dist, xoffset);
Get X value in front of entity at "dist".
GetAnglePointY
GetAnglePointY(ident[], dist, yoffset);
Get Y value in front of entity at "dist".
GetBounceValue
GetBounceValue(ident[]);
Get the entity's current bounce value. ( the player script makes use of this when throwing... )
GetCurrentEntity
GetCurrentEntity();
Retrieve the name of the current entity in the list. ( Use ToString(GetCurrentEntity(), string) to copy it into a string)
GetDamage
GetDamage(ident[]);
Retrieve the value from SetDamage().
GetDirection
GetDirection(ident[]);
Get the current entity direction.
Avaiable Directions:
- north
- east
- south
- west
- northeast
- southeast
- southwest
- northwest
GetEntityCount
GetEntityCount();
Get the total count of entities in the game currently.
GetFloat
GetFloat(ident[], index);
Same as GetValue but returns a float value
GetGotoNextMessage
GetGotoNextMessage(ident[], index);
returns true, if message number from message "index" and answer "index2" exists
GetHealth
GetHealth(ident[]);
Returns Health vaule for entity
GetImage
GetImage(ident[], code[]);
Copy the image string into code[].
GetInitialX
GetInitialX(ident[]);
Get the X position the entity was created on.
GetInitialY
GetInitialY(ident[]);
Get the Y position was created on.
GetItem
GetItem(ident[], code[]);
Copy the item string into code.
GetLiftLevel
GetLiftLevel(ident[]);
Retrieve the liftlevel for ident[].
GetMaxHealth
GetMaxHealth(ident[]);
Returns Max. Health value for the entity.
GetMoveAngle
GetMoveAngle(ident[]);
Get the movement angle for Entity in degrees.
GetNextMessage
description coming soon
GetNumNextMessages
description coming soon
GetParam
GetParam( ident[] );
Returns the Param. The Param is the value of # in the entity's name.
GetParent
GetParent( ident[], buffer[] );
Set buffer[] to the name of the parent of ident[]
GetSpeed
GetSpeed(ident[]);
Get the speed for entity;
GetSpeedMod
GetSpeedMod(ident[]);
Retrieve the speed modification value for entity.
GetState
GetState(ident[]);
Returns State for Entity "indent".
Available States:
- standing
- walking
- hit
- knocked
- jumping
- swimming
- floating
- chasing
- using
- lifting
- standLift
- walkLift
- dying
- dead
- falling
- falling2
- stunned
- frozen
- shocked
- burning
- sleeping
- waiting
- leaping
- pushing
- pulling
Any Number value can be used
GetString
GetString(ident[], index, string[]);
Retrieve string nr "index" from entity and copy it into string[].
GetType
GetType(ident[]);
Retrieve the current entity type.
GetValue
GetValue(ident[], index);
Retrieve entity's "index" value.
GetWeight
GetWeight(ident[]);
Get the weight of entity.
GetX
GetX(ident[]);
Get the current X position for ident[].
GetY
GetY(ident[]);
Get the current Y position for ident[].
isActive
isActive(ident[]);
Returns Active Flag for the entity.
isCuttable
isCuttable(ident[]);
Returns Cuttable Flag for the entity.
isDead
isDead(ident[]);
Returns Dead Flag for the entity
isInteracting
isInteracting(ident[])
Return Entity's Interacting Flag.
isLarge
isLarge(ident[]);
Return Entity's Large Flag.
isOpen
isOpen(ident[]);
Returns Open Flag for the entity
isOwned
isOwned(ident[]);
Check if the Owned Flag is true for the wanted entity. Weapons/items from a chest/shop have a unique "ident", so isOwned can't be used to see if player own them.
isPickable
isPickable(ident[])
Returns Pickable Flag for the entity.
isPushed
isPushed(ident[])
Return Entity's Pushed Flag.
isTaken
isTaken(ident[]);
Returns Taken Flag for the entity
isVisible
isVisible(ident[]);
Returns Visible Flag for the entity .
MessageMap
MessageMap(ident[], index, Message[], gotoNext, ...);
This is the basic code to make an NPC talk. When you are typing the message use ` to go to the next line and | to make an answer to a question that the NPC might ask
NextEntity
NextEntity(dist, x=-1, y=-1);
Go to the next entity in the list.
Respawn
Respawn(ident[], seconds);
Respawn dead entity in every "seconds" seconds
SetActiveDist
SetActiveDist(ident[], val);
Set the distance in pixels from current scren X/Y that the entities will be run. -2 means entities always run; -1 means entities never run;
SetActiveFlag
SetActiveFlag(ident[], val);
Sets Entity's Active Flag.
SetActiveInGroups
SetActiveInGroups(ident[], val);
If "val" equals true, Active Flag will be true even if your not in that group, otherwise it's false when you not in the same group as the entity, or not within it's active distance.
SetAngleFromDir
SetAngleFromDir(ident[]);
Set the angle to whatever the current direction is.
SetBounceValue
SetBounceValue(ident[], val);
Set the entity's bounce value. ( player script makes use of this. )
SetCollisionRect
SetCollisionRect(ident[], index, solid, left, top, right, bottom);
Create collision rectangle "index" for the entity. solid indicates if you can walk through it or not, left, top, right & bottom are the corresponding edges of the rectangle.
SetCuttableFlag
SetCuttableFlag(ident[], val);
Sets Entity's Cuttable Flag.
SetDamage
SetDamage(ident[], val);
Set the damage of ident[] to val. This works pretty much like using Set/GetValue().
SetDeadFlag
SetDeadFlag(ident[], val);
Sets Entity's Dead Flag. Use with Enemies & player entities.
SetDirection
SetDirection(ident[], val);
Set the current direction for entity.
SetDirFromAngle
SetDirFromAngle(ident[]);
Set the direction according to what the current angle is.
SetFloat
SetFloat(ident[], index, floatval);
Same as SetValue but use a float value
SetHealth
SetHealth(ident[], val);
Set the the level of health for the entity.
SetImage
SetImage(ident[], code[]);
Set the main image sprite to code[].
SetInteractingFlag
SetInteractingFlag(ident[], val);
Sets Entity's Interacting Flag.
SetItem
SetItem(ident[], code[]);
Gives Entity (Chest, enemy or shop) an Item.
SetLargeFlag
SetLargeFlag(ident[], val);
Sets Entity's Large Flag.
SetLiftLevel
SetLiftLevel(ident[], val);
Works the same as SetDamage(), set the lift level for entity ident[] to val.
SetMaxHealth
SetMaxHealth(ident[], val);
Set Max Health for the Entity.
SetMoveAngle
SetMoveAngle(ident[], val);
Set the Entity's movement angle to val. (counted in degrees)
SetOpenFlag
SetOpenFlag(ident[], val);
Sets Entity Open Flag
SetOwnedFlag
SetOwnedFlag(ident[], val);
Sets Entity's Owned Flag. Use to see if player owns a weapon/item (if you know the ident[]).
SetPickableFlag
SetPickableFlag(ident[], val);
Sets Entity's Pickable Flag.
SetPosition
SetPosition(ident[], x, y);
Set both X & Y position for ident[] at the same time.
SetPushedFlag
SetPushedFlag(ident[], val);
Sets Entity's Pushed Flag.
SetSpeed
SetSpeed(ident[], val);
Set the speed for entity to val.
SetSpeedMod
SetSpeedMod(ident[], val);
Set the speed modification value for entity to val.
SetState
SetState(ident[], val);
Available States:
- standing
- walking
- hit
- knocked
- jumping
- swimming
- floating
- chasing
- using
- lifting
- standLift
- walkLift
- dying
- dead
- falling
- falling2
- stunned
- frozen
- shocked
- burning
- sleeping
- waiting
- leaping
- pushing
- pulling
Any Number value can be used
SetString
SetString(ident[], index, string[]);
works like other Set function, but more than one can be set by giving a different index value (starting at 0). The Entity must use AllocateStrings().
SetTakenFlag
SetTakenFlag(ident[], val);
Sets Entity's Taken Flag
SetType
SetType(ident[], val);
Set the entity type to val.
SetValue
SetValue(ident[], index, val);
Set Entity's "index" value to "val".
SetVisibleFlag
SetVisibleFlag(ident[], val);
Sets Entity's Visible Flag.
SetWeight
SetWeight(ident[], val);
Set the weight of entity to val.
SetX
SetX(ident[], val);
Set the X position for ident[].
SetY
SetY(ident[], val)
Set the Y position for ident[].
StartEntity
StartEntity(dist = 40, x=-999, y=-999);
List entity from the start within the pixel distance of "dist" at x & y.
Counter Functions
Warning
To use these functions you must include #include <counter.inc> at the top of the script.
CreateCounter
CreateCounter(min, max, ident[]);
Create a counter available to the current script with minimum and maximum values.
CreateCounterWithID
CreateCounterWithID(min, max, ident[]);
Create a counter available to all scripts after its creation.
DeleteCounter">DeleteCounter
DeleteCounter(ident[]);
Delete the counter.
GetCounterValue
GetCounterValue(ident[]);
Return current the counter value.
IncCounterTarget
IncCounterTarget(ident[], val);
Increase the counter target by "val".
IncCounterValue
IncCounterValue(ident[], val);
Increase the current counter value by "val".
SetCounterMax
SetCounterMax(ident[], val);
Set the counter maximum value to something else than the original maximum value.
SetCounterMin
SetCounterMin(ident[], val);
Set the counter minimum value to something else than the initial minimum.
SetCounterSpeed
SetCounterSpeed(ident[], val);
Set the speed of the counter to val.
SetCounterTarget
SetCounterTarget(ident[], val); (ident[], val);
Set the counter target to "val".
SetCounterValue
SetCounterValue(ident[], val);
Set the current counter value to "val".