Free Hero Mesh

Artifact [3c2c2fa9a7]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.

Artifact 3c2c2fa9a7c5c0dff8058c5f57c8c52b1326d7c3:

Wiki page [SQL functions] by anonymous on 2020-10-20 20:55:35.
D 2020-10-20T20:55:35.844
L SQL\sfunctions
P a3eedcdef30232186bd5006a1ce09ee378addc06
U anonymous
W 4582
This document is a list of the available SQL functions that you can use in the customization of Free Hero Mesh. In addition to the ones listed here, you can also use the [http://sqlite.org/lang_corefunc.html|core functions], [http://sqlite.org/lang_datefunc.html|date/time functions], and [http://sqlite.org/lang_aggfunc.html|aggregate functions], of SQLite, as well as any functions defined by extensions. See also: [SQL tables].

(Note: This is only a draft and is likely to change in future.)

Asterisks in the headings indicate aggregate functions.

<h2>BASENAME()</h2>
Returns the base name, which is a copy of the first command-line argument (other than switches).

<h2>CLASS_DATA(id,info)</h2>
Returns data about the class with the given ID number.

The second argument can be: 0=class ID number, 1=Temperature, 2=Shape, 7=first image number available in editor (null if none), 12=Misc4, 13=Misc5, 14=Misc6, 15=Misc7, 18=Arrivals, 19=Departures, 32=Busy, 33=Invisible, 34=UserSignal, 35=UserState, 36=KeyCleared, 37=Player, 38=Destroyed, 39=Stealthy, 40=VisualOnly, 64=Density, 65=Volume, 66=Strength, 67=Weight, 69=Height, 70=Climb, 72=Hard(E), 73=Hard(N), 74=Hard(W), 75=Hard(S), 76=Sharp(E), 77=Sharp(N), 78=Sharp(W), 79=Sharp(S), 80=Shape(E), 81=Shape(N), 82=Shape(W), 83=Shape(S), 84=Shovable, 128=fraction of volume, 129=number of user variables, 130=CollisionLayers, 132=Compatible

<h2>CVALUE(number)</h2>
Returns a 64-bit integer representing a value of type TY_CLASS; the argument is the class number.

<h2>HEROMESH_ESCAPE(blob)</h2>
Converts a unescaped representation of a string with [formatting controls] into the escaped representation.

<h2>HEROMESH_TYPE(value)</h2>
Given a Hero Mesh value (which is represented in SQL by a 64-bit integer), return a string representing its type. It can be one of:
  *  ???
  *  class
  *  number
  *  object
  *  sound
  *  string

<h2>HEROMESH_UNESCAPE(text)</h2>
Converts a escaped representation of a string with [formatting controls] into the unescaped representation.

<h2>LEVEL()</h2>
Returns the one-based order number of the current level.

<h2>LEVEL_CACHEID()</h2>
Returns the ID number of the active level file in the user cache table.

<h2>LEVEL_ID()</h2>
Returns the ID number of the current level.

<h2>LEVEL_TITLE()</h2>
Returns the level title as a blob (see [formatting controls]).

<h2>LOAD_LEVEL(levelid)</h2>
Load a level by ID; returns null. Usable only if the <tt>-x</tt> [Command-line arguments|switch] is used; otherwise it is an error.

<h2>MODSTATE()</h2>
Get the current keyboard modifiers state. It is the sum of the following:
  *  0x0001: Left shift
  *  0x0002: Right shift
  *  0x0040: Left control
  *  0x0080: Right control
  *  0x0100: Left alt
  *  0x0200: Right alt
  *  0x0400: Left meta
  *  0x0800: Right meta
  *  0x1000: Num lock
  *  0x2000: Caps lock
  *  0x4000: Mode

<h2>MOVENUMBER()</h2>
Tells you how many moves have been played so far since it has been reset.

<h2>MVALUE(number)</h2>
Returns a 64-bit integer representing a value of type TY_MESSAGE; the argument is the message number.

<h2>NVALUE(number)</h2>
Returns a 64-bit integer representing a value of type TY_NUMBER; the argument is the number. This function is actually the same as ZERO_EXTEND.

<h2>OVALUE(number)</h2>
Returns a 64-bit integer representing a object pointer value; the argument is the object ID number.

<h2>PICTURE_SIZE()</h2>
Tell you the picture size.

<h2>READ_LUMP_AT(offset,ptr)</h2>
Used internally by Free Hero Mesh. If the second argument is not a pointer to a FILE, this function does nothing. Since SQL codes cannot generate pointers, there is no way to use this in user code.

<h2>RESOURCE(...)</h2>
Given a list of strings, find the matching resource from the .heromeshrc file and command-line arguments. Result is null if there is no such resource value.

<h2>SIGN_EXTEND(num)</h2>
Sign-extend a 32-bit integer to 64-bits. The 32-bit user variables in Free Hero Mesh might or might not be signed, so when accessing them in SQL (which uses 64-bit numbers) you must use this if you want to treat it as a signed number.

<h2>SOLUTION_CACHEID()</h2>
Returns the ID number of the active solution file in the user cache table.

<h2>SOLUTION_REPLAY()</h2>
Returns 1 if replaying the solution or 0 for the normal game.

<h2>ZERO_EXTEND(num)</h2>
Zero-extend a 32-bit integer to 64-bits. Can also be used to convert other types of values (such as classes, messages, and objects) into plain numbers.

Z a473c6f7d3c80fb29eda877f9058f3d2