Because many of the HZ Engine's features are based on the embedded Lua scripting language, you can interactively query information about the game, and even write new code from the Lua Console. To get to the Lua console, press the "`" key (backtick). Once there, you should the text console, probably with a bunch of messages from startup.
While in the command console, you can use the pageup/pagedown keys to scroll up or down, and you can use the home/end keys to get to the beginning or end of the scrollback buffer.
Typing help will give you a simple overview of the command console:
> help
QUIT - Quit the game.. (just like ESC)
HI - Hello...
HELP - This message
ADDT - Add text to console
PCON - Print the Console
T - Toggle console view output on or off
Welcome to HZ!
In the command console you can type any command listed
above. You can also type any Lua script command. To find
a list of available Lua functions and variables type:
> dir()
You can also scroll up/down by using the pageup/down keys.
If you type dir() by itself, you will get a listing of the
global functions and data. First all the functions are listed, and
then all the global data is listed. You can see an example here:
setupGameSprites handle_firing
cycle clamp_velocity
hz_register_objtype place_item
luaStatus AdvProtoIndexWithCache
setupMultipleInheritenceForTag add_parent
AdvProtoIndex ProtoIndex
trim clone
printTable printTables
dir dir_object
_old_dofile printGlobalVariables
write C_getmapsize
C_getmapsquare C_setmapsquare
C_tile_addtype C_setpalette
C_obj_setLayer C_obj_setPos
C_obj_getPos C_obj_followsprite
C_obj_setVelocity C_obj_getVelocity
C_obj_viewFollow C_sprite_listtypes
C_addsprite C_sprite_addtype
C_obj_delete C_obj_goTo
randomseed random
rad deg
exp log10
log max
min sqrt
mod floor
ceil atan2
atan acos
asin tan
cos sin
abs gsub
strfind format
ascii strrep
strupper strlower
strsub strlen
type tag
tostring tonumber
settag gettagmethod
settagmethod setglobal
seterrormethod rawsettable
rawsetglobal rawgettable
rawgetglobal print
nextvar next
newtag getglobal
foreachvar foreach
error dostring
copytagmethods dofile
collectgarbage call
assert
recharge = ' table: 04E82AD8' table
follower = ' table: 04ECB6C8' table
sprite_types = ' table: 04EBCFE8' table
mainship_physics = ' table: 04E77C80' table
ground_physics = ' table: 04E74318' table
air_physics = ' table: 027FEC40' table
collidable = ' table: 027FEFD8' table
MAX_COLLISIONS = 5 number
collisions_active = 0 number
controllable = ' table: 04E756A0' table
VisualReps = ' table: 04E83190' table
Diry = ' table: 04E80400' table
Dirx = ' table: 04E74FE0' table
a_key_map = ' table: 027FEBE8' table
map_templates = ' table: 04E7A1B0' table
MAP_TILES_LOADED = 1 number
objects = ' table: 04E77510' table
object_types = ' table: 04E774F0' table
srvobjs = ' table: 04E774D0' table
srvobj_types = ' table: 04E77398' table
world_srvobj = ' table: 04E77188' table
world_map = ' table: 04E775B8' table
world_object = ' table: 027FEE68' table
PI = 3.14159 number
_TRIGMODE = ' deg' string
_VERSION = ' Lua 3.1 (alpha)' string
You can also use dir() with any table or object. Try typing
dir(srvobjs) and you should see the following list of all
sprite objects currently on the map (I've cut out the redundant
entries for brevity):
table: 04E77510 [number]: 1 = [object(mainship)] table: 04ED43A0 [number]: 2 = [object(heli)] table: 04ED4D28 [number]: 3 = [object(tank)] table: 04E707E0 [number]: 4 = [object(hovercraft)] table: 04E70EB0 [number]: 5 = [object(litetank)] table: 04E71300 [number]: 6 = [object(hd_mainship)] table: 04E728E0 [number]: 7 = [object(hd_mainship_c)] table: 04ED3050 [number]: 8 = [object(Base)] table: 04ED3720 .... [number]: 107 = [object(Base)] table: 04F094C8 [number]: 108 = [object(flag)] table: 04F09868 .... [number]: 137 = [object(flag)] table: 04F13048 137 entries.The most useful thing you will do, however, is inspect the current values for one of your script objects, and possibly even change some of the properties or functions. For example, if you type dir(srvobjs[1]) you should see something like the following listing:
table=> table: 04F42FB0
key=> table: 04ED4820
0 entries.
action=> table: 04E768F8
SHIELD= [number] 1
SHOOT= [number] 0
2 entries.
key_maps=> table: 027FEB60
'65362'= [string] up
'65363'= [string] right
'79'= [string] o
'80'= [string] p
'37'= [string] left
'38'= [string] up
'39'= [string] right
'40'= [string] down
'65361'= [string] left
'111'= [string] o
'112'= [string] p
'65364'= [string] down
'32'= [string] space
13 entries.
3 entries.
userdata=> table: 04EFEF30
objnum= [userdata] userdata: 04ED42D8
1 entry.
string=> table: 04EFF2B8
Condition= [string] Healthy
bullet_type= [string] bullet
objtype= [string] mainship
obj_type_name= [string] mainship
4 entries.
function=> table: 04E90B10
handleKeys(); function: 04E798D0
setLayer(); function: 04E76190
ai_event(); function: 04E92858
keyDown(); function: 04E79AF8
goTo(); function: 04E765E0
go(); function: 04E76550
inputEvent(); function: 04E77230
goToTile(); function: 04E76C00
new(); function: 04E93DC8
recharge(); function: 04E93DF0
viewFollow(); function: 04E769E8
doTick(); function: 04E759B8
doAction(); function: 04E76D60
ge_collision(); function: 04E7A008
keyUp(); function: 04E801E8
15 entries.
overridden=> table: 04E90B30
mainship:imgdir= [number] 2
nil:rot= [number] 0
mainship:rimgdir= [number] 1
nil:doTick(); function: 04E76B78
mainship:exp_timer= [number] 0
nil:new(); function: 04E72FB8
6 entries.
number=> table: 04F42FD0
damage_max= [number] 10
vx= [number] 0
direction= [number] 0
frame_time= [number] 70
vy= [number] 0
imgdir= [number] 31
layer= [number] 1
exp_timer= [number] 44
damage= [number] 0
MAX_VELOCITY= [number] 0.3
dest_dir= [number] 30
firing_frequency= [number] 200
rimgdir= [number] 6
rot= [number] 30
recharge_rate= [number] 0.1
ctrl_centered= [number] 1
16 entries.
6 entries.
In this listing, items are broken out by type. Most of this listing is
self-explanatory. The "overridden" section lists functions and
properties which exist in parent classes of your object but which have
been overridden by new values. When possible, the name of the class
where the method was originally defined is listed is shown. If that
classname is not available, it's listed as "nil".
NOTE: The order of the sections in this listing changes, because it's temporarily stored in a hash-table, and hash-tables are unordered.
If you know the name of a property you would like to change, you can change it simply by entering a valid line of Lua into the command console. For example, to set the frame_time of the above object to 30, instead of 70, you would enter:
> srvobjs[1].frame_time = 30;The Lua console is neat, but it's not as neat as it could be. Each line of the Lua console needs to be a complete and valid lua block. However, the block must be defined on a single line. In order to define a function in the lua console, you must define it on one line. Here is an example of defining a simple function in the Lua console:
> function say_hi() print("hi!!!"); end;