FraggleScript functions

From DoomWiki.org

Revision as of 16:12, 13 June 2005 by DooMAD (talk | contribs) (large addition - part 2)


This is a comprehensive list of FraggleScript functions:

System variables

These are functions rather than variables, but are always available to the player:

consoleplayer 
The player on the console, ie. in a network game, the player on this machine.
displayplayer
fov 
The current field of view size
trigger 
The object which triggered the current script to start
script 82 {
    // kill the object which started this script
    kill(trigger);
} 

Control functions

break 
Exit a loop, eg.
while (1) {
  break();
}
continue 
Move to the next iteration in a loop
while (1) {
  continue();
  print("this message is never displayed");
}
return 
Stop the current script
script 1 {
   return();
   print("this message is never displayed");
}
goto 
Jump to a particular label
script 1 {
   goto(my_label);
   print("this message is never reached");
   my_label:
}
include 
Execute the contents of the lump specified (acts like "#include" in C)
// include the contents of the wad lump named 'things.h'

include("things.h");   

Basic language functions

print 
Print a message to the console
print("hello, world");
rnd 
Returns a random number from 0..255
script 1 {
    int my_number = rnd();
    if (my_number % 2 == 0) {
        print("heads");
    } else {
        print("tails");
    }
}
prnd (legacy extension)
Returns a random integer from 0..255 (using the doom random table)
input 
(non-functional) read a line from the keyboard
beep 
Make a sound
clock 
Returns the level time, in 1/100ths of a second
wait 
Causes the current script to delay further execution for time number of clocks (1 clock = 1/100 of a second)
tagwait 
Causes the current script to delay further execution until all activity associated with the tag number passed to it has stopped
scriptwait 
Causes the current script to delay further execution until all instances of the script with number scriptnum have finished execution
startscript 
Causes script to run at the start of a level
scriptrunning 
Returns a non-zero result if any instances of the script with scriptnum are currently waiting, and zero otherwise
startskill 
Starts a new game on a skill level from 1 to 5
exitlevel
Exit the level
tip 
Display a message to the player (in the centre of the screen)
timedtip (legacy extension)
Prints a centered message to all players, which lasts clocks/100 number of seconds

Messages

message
Display a message to the player
playermsg
Send a message to a particular player
playermsg(2, "Hello, player 2");
playertip
Send a tip to a particular player (centre-of-screen message)
playertip(2, "Dont go this way, player 2!");
playeringame
Returns 1 if the given player is in the game
if (playeringame(2)) {
    print("player 2 is in the game!");
}
gameskill (legacy extension)
Returns a value from 1 to 5 representing the skill level of the current game
gamemode (legacy extension)
Returns an integer value representing the current mode of gameplay

Player information and control

playername
Returns the name of a given player
playerobj
Returns a reference to the object controlled by a player
playeraddfrag (legacy extension)
With one argument 1 frag will be added to that player's frag count. If passed two arguments, 1 frag will be added to the first player's frag count against the second player specified (for tally screen). If both players are the same number, a frag will be subtracted from that player's frag count (suicide)
isplayerobj (legacy extension)
Returns 1 if the trigger object or specified object is a player avatar, and 0 otherwise
skincolor (legacy extension)
Returns the number corresponding to a player's colour, or can be used to set colour
playerkeys (legacy extension)
If passed a player number (0-31) and a key number (0-5), this function will return 1 if the player possesses that key or 0 if he does not. If additionally passed the givetake parameter, it will give the key to the player if givetake is non-zero, or will take the key away from the player if givetake is zero. In this case, the function always returns zero regardless
playerammo (legacy extension)
If passed a player number (0-31) and an ammo type number (0-5), this function will return the amount of that type of ammo the player has. If additionally passed the amount parameter, it will set the player's ammo of that type to this amount, clipping it into the range of zero to the maximum amount the player can carry for that type
maxplayerammo (legacy extension)
Sets a player's maximum ammo
playerweapon (legacy extension)
If passed a player number and weapon type number, this function will return 1 if that player has that weapon, 0 if he does not. If additionally passed the givetake parameter, it will set the player's possesion of that weapon. 0 will take the weapon away, while any non-zero number will give it to the player

Objects

spawn 
Spawns a new mapthing with various parameters
kill 
Passed nothing, this function kills the thing that triggered the current script. Passed a mapthing number or mobj reference, this function will kill the mapthing to which it refers
removeobj 
Passed a mapthing number or mobj reference, this function will remove the mapthing to which it refers
objx
Returns the X coordinate of an object
objy
Returns the X coordinate of an object
objz
Returns the Z coordinate of an object
teleport 
Passed one parameter, this function attempts to teleport the trigger object to a teleport destination in the sector with tag number sectortag. Passed a mapthing number or a mobj reference, this function attempts to teleport the specified mapthing. This function automatically spawns fog objects and plays sounds in the appropriate locations
silentteleport 
This function works identically to teleport() except that no fog is spawned and no sounds are played
damageobj 
Passed one parameter, this function attempts to do damage in the specified amount to the trigger object. Passed a mapthing number or mobj reference, this function attempts to do damage to the specified object
player
If the object is a player, returns the number of the player
objsector 
Passed nothing, this function returns the tag number of the sector which the trigger object is currently in. Passed a mapthing number or mobj reference, this function attempts to do likewise for the specified object
objflag
If passed only one argument, this function will return 1 if the specified flag is set for the trigger object, and 0 otherwise. Passed all 3 arguments it will set or clear a flag for the specified object
pushobj
objangle 
Passed nothing, this function returns the high-precision angle of the trigger object. Passed a mapthing number or mobj reference, this function does likewise for the specified mapthing. Passed a mapthing number or mobj reference and an angle the specified mapthing's angle will change
objhealth 
Passed nothing, this function returns the current health value of the trigger object. Passed an integer or mobj reference, this function does likewise for the specified mapthing
spawnexplosion (legacy extension)
Spawns a projectile and immediately changes it to the death state so it creates an explosion
radiusattack (legacy extension)
Creates a silent, invisible radius attack at the location of mobj spot. Mobj source defines the creator of the attack (for message purposes). The damage in the center of the attack is defined by int damage. The size of the radius depends on the amount of damage passed to the function
testlocation (legacy extension)
Passed nothing, this function returns if the trigger object is clear of any wall or other objects. Passed a mapthing number or mobj reference, this function does likewise for the specified mapthing
pushthing (legacy extension)
Given a mapthing number or mobj reference, this function pushes the specified thing along a line from its location in the direction of angle for a distance and speed affected by the force applied and its mass. External forces such as friction, wind, or explosions are vector-additive and will still affect the object while it is moving
objdead (legacy extension)
objreactiontime (legacy extension)
reactiontime (legacy extension)
Passed one value, a mapthing number or mobj reference, this function will return the specified object's reaction time, or the amount of time it must sit without being able to move. Given the val parameter, it will first set the object's reaction time to the specified value, and then return this new value
objtarget (legacy extension)
Passed one value, a mapthing number or mobj reference, this function will return a reference to that object's current target, which for enemies is the last thing to hurt them and get their attention. If the second parameter is passed, which may also be either a mapthing number or mobj reference, the target will be set to this object
objmomx (legacy extension)
This function either returns or sets the x momentum of the specified object
objmomy (legacy extension)
This function either returns or sets the y momentum of the specified object
objmomz (legacy extension)
This function either returns or sets the z momentum of the specified object
spawnmissile (legacy extension)
This function can be used to cause one object to fire a projectile at another object. The source and target parameters may be either integer mapthing numbers or mobj references
mapthings (legacy extension)
Returns the number of mapthings in a level. This does not include projectiles, dropped weapons, or FS spawned entities
objtype (legacy extension)
Returns the type of an object in the form of an integer. When nothing is passed the type of the trigger will be returned. When passed a map object or mapthing number it will return the type of that object
mapthingnumexist (legacy extension)
This will test a mapthing number to see if it exists. It will return 1 for an existing mapthing number or 0 for a non-existing mapthing number

Sector control

floorheight
floortext
floortexture (legacy extension)
movefloor
ceilheight
ceilingheight (legacy extension)
moveceil
moveceiling (legacy extension)
ceiltext
ceilingtexture (legacy extension)
lightlevel
fadelight
colormap

Cameras

setcamera
clearcamera
movecamera (legacy extension)

Math functions

pointtoangle
pointtodist
max (legacy extension)
min (legacy extension)
abs (legacy extension)
sin (legacy extension)
asin (legacy extension)
cos (legacy extension)
acos (legacy extension)
tan (legacy extension)
atan (legacy extension)
exp (legacy extension)
log (legacy extension)
sqrt (legacy extension)
floor (legacy extension)
pow (legacy extension)

Sound effects

startsound
startsectorsound
changemusic
startambiantsound (legacy extension)
ambientsound (legacy extension)

Hubs

changehublevel

Doors

opendoor
closedoor

Heads-up GUI

newhupic (legacy extension)
createpic (legacy extension)
deletehupic (legacy extension)
modifyhupic (legacy extension)
modifypic (legacy extension)
sethupicdisplay (legacy extension)
setpicvisible (legacy extension)

Miscellaneous

runcommand 
Executes a console command
script 10 {
    // quit the game

    runcommand("quit");
}
linetrigger
Activates a particular Doom line trigger
playdemo (legacy extension)
checkcvar (legacy extension)
setlinetexture (legacy extension)
lineflag (legacy extension)
setcorona (legacy extension)