Small
Small is a scripting language created by ITB CompuPhase; it uses a C-like syntax and is Eternity's main scripting language, replacing the Fragglescript of earlier versions. To be used in Eternity, the script files must first be compiled using the sc executable. Script files usually have the extension .sma, but files of any extension can be compiled. Assuming the script has no errors, the compiler should output an .amx file, which can be loaded into a WAD for use with Eternity.
Script types
There are two types of script: gamescript and levelscript. Gamescripts work over a whole gaming session, while levelscripts only work on maps which have specified that script in their level info. To use a script file as a gamescript, the compiled script file should be loaded into a WAD and given the lump name GAMESCR. These gamescript files will work over every level.
Levelscripts are loaded using a different method. To specify a script for use in a single map, levelscript=MYSCRIPT should be added to the map's MapInfo. Here, MYSCRIPT should be replaced with your script's lump name, which can be anything.
Triggering scripts
There are many ways to start a script. They can be triggered by a linedef, the start of a map, or a codepointer specified on a Thing.
Triggering via linedef
The most common way is to start a script when a linedef is triggered. To do this, first give the linedef you want to trigger the script a Start script action (linedef actions 273-280) and a unique tag number. For example, if we want our script to start when the player walks over a linedef, use linedef action 280 and give the linedef a tag of 1. The script would then look like this:
public Script1() { _Printf( _MSG_NORMAL, "Hello World"); }
Note that the Script## number is the same as the linedef's tag. Compile your script and set up the wad as explained above. Assuming all things have been set up properly, when you walk over that linedef, it will output "Hello World" to the screen.
Triggering on map start
Another way of starting a script is using the OnInit() function.
public OnInit() { _Printf( _MSG_NORMAL, "Hello World"); }
This script will output "Hello World" when the map starts up. This could be useful for starting a series of callbacks for animating HUD sprites or raising/lowering sectors.
Triggering by Thing codepointer
The final way is to use the StartScript codepointer on a Thing's frame. The StartScript codepointer uses the first two args to decide the script number to execute and the script type (whether it is levelscript or gamescript). For example, the EDF file to do this is:
stdinclude(root.edf) framedelta { name = S_TROO_DIE1 // Frame we want to start the script on action = StartScript // The startscript codepointer args = {1,0} // Codepointer's arguments, starts script 1 and sets the type to game (0) }
Load the EDF with your map and script, and whenever you kill an imp (therefore going onto the frame S_TROO_DIE1, it will run script 1, outputting "Hello World". As this script is a gamescript, it will do this on every map.
Functions
Note: this list contains functions as of Eternity version 3.33.50. Current version is 4.02.00.
Core Small functions
- heapspace
- funcidx
- numargs
- getarg
- setarg
- strlen
- strpack
- strunpack
- tolower
- toupper
- swapchars
- min
- max
- clamp
Invocation Functions
- _GetInvokeType
- _GetCcmdSrc
- _GetPlayerSrc
- _GetThingSrc
- _SetCallback
- _ExecGS
- _ExecLS
- _GetLevelVar
- _SetLevelVar
- _GetGameVar
- _SetGameVar
Input/output
Fixed-point math library
Random number generators
Heads-up display
- _NewPatchWidget
- _SetWidgetPatch
- _PatchWidgetColor
- _NewTextWidget
- _GetWidgetText
- _SetWidgetText
- _ToggleWidget
- _MoveWidget
- _GetHUDMode
- _InAutomap
Game functions
Mapthings
- _ThingKill
- _ThingHurt
- _ThingMassacre
- _ThingHate
- _ThingNumForName
- _ThingNumForDEHNum
- _ThingUnknown
- _ThingCheckType
- _ThingSpawn
- _ThingSpawnSpot
- _ThingGetProperty
- _ThingSetProperty
- _ThingFlagsFromStr
- _ThingThrust
- _ThingThrust3f
- _ThingGetPos
- _GetFreeTID
Sounds
- _SoundGlobal
- _SoundGlobalNum
- _SectorSound
- _SectorSoundNum
- _ThingSound
- _ThingSoundNum
- _ThingInfoSound
Particles
Sectors
Parameterized line specials
- _SpecialMode
- _ByteAngleToDegrees
- _DegreesToByteAngle
- _ByteAngleToFixed
- _FixedToByteAngle
- _Door_Raise
- _Door_Open
- _Door_Close
- _Door_CloseWaitOpen
- _Door_WaitRaise
- _Door_WaitClose
- _Floor_RaiseToHighest
- _Floor_LowerToHighest
- _Floor_RaiseToLowest
- _Floor_LowerToLowest
- _Floor_RaiseToNearest
- _Floor_LowerToNearest
- _Floor_RaiseToLowestCeiling
- _Floor_LowerToLowestCeiling
- _Floor_RaiseToCeiling
- _Floor_RaiseByTexture
- _Floor_LowerByTexture
- _Floor_RaiseByValue
- _Floor_LowerByValue
- _Floor_MoveToValue
- _Floor_RaiseInstant
- _Floor_LowerInstant
- _Floor_ToCeilingInstant
- _Ceiling_RaiseToHighest
- _Ceiling_ToHighestInstant
- _Ceiling_RaiseToNearest
- _Ceiling_LowerToNearest
- _Ceiling_RaiseToHighestFloor
- _Ceiling_LowerToHighestFloor
- _Ceiling_ToFloorInstant
- _Ceiling_LowerToFloor
- _Ceiling_RaiseByTexture
- _Ceiling_LowerByTexture
- _Ceiling_RaiseByValue
- _Ceiling_LowerByValue
- _Ceiling_MoveToValue
- _Ceiling_RaiseInstant
- _Ceiling_LowerInstant
- _Stairs_BuildUpDoom
- _Stairs_BuildDownDoom
- _Stairs_BuildUpDoomSync
- _Stairs_BuildDownDoomSync
- _Polyobj_DoorSlide
- _Polyobj_DoorSwing
- _Polyobj_Move
- _Polyobj_OR_Move
- _Polyobj_RotateRight
- _Polyobj_OR_RotateRight
- _Polyobj_RotateLeft
- _Polyobj_OR_RotateLeft
- _Pillar_Build
- _Pillar_BuildAndCrush
- _Pillar_Open