As you can see from demos LostHero language is similar to PHP. Variables are decleare by first call and they always starts by$. Variables can have two types. First is text content, which also represents numbers. Second is pointer to class.There is not possibile to create own class in lost hero, but everything in lost hero (persons, map, fights, dialogs, etc.)and as class it can be accessed or putted to pointer. For example
echo(leader:name);
will return name of actual leader. Same result will have this code: $a=leader:this;
echo($a:name);
as you can see, to get class as result of operation, you must can use identified :this, which has every class or just $a=leader;
You can also work withclasses like this: $a=item; $c=$a; echo($c.class);
Result of this is text "item", what is text name of class Item. This shows that every class also has second default function and this is .class, what represent name of that class.
As you can see items of classes can be accessed with : or . . There is no difference between these operators but : is there to increase better finding of errors, because . is also oprator for joining texts. There are globaly defined some keywords, which enables to access all defined classes in game. Most import of them is "this". "This" represent actual class from which was code called. For example when you have event onUse in item you can use this code: actor:add("HP",2); this:drop;
and it will work. But when you put this code in map event onClick, it will return "undefined function drop".You can also skip part this:, because all entered functions are tested on actual class. But it can sometime make problems, with duplicationof names.
Please read
lang.class
description and list of
basic.class
functions.
actor - Returns actualy acting person or monster.
askBox (image, title, text, captionYes, captionNo, width) - Shows confirmation dialog on screen and waits for choose.
break - Breaks actual block (for, if, { )
cancelAction - Exits from actual script and continue on next in queue
clearMessage - Clear all messages in message box.
clicked - Returns actualy clicked part of square.
dialog - Returns actual dialog in view part of screen.
doKeyLock (name, key, keyId, [lockDeep], [lockLevel], [Id]) - Symplified version of doLock for KeyLock @see doLock
doLock (name, key, keyId, lockDeep, lockLevel, lockStuck, trapLevel, doorStuck, Id) - Shows lock/open on screen.
doNext (x, y, element) - replacement for map:doNext()
doPickLock (name, lockDeep, lockLevel, [lockStuck], [doorStuck], [Id]) - Symplified version of doLock for KeyLock @see doLock
doTrapLock (name, trapLevel, [Id]) - Symplified version of doLock for KeyLock @see doLock
echo (text) - Add line to message box.
fight - Returns actual fight.
firstCall (value) - Returns if this "value" was called. IMPORTANT!
goDown (add) - move party to level defined in map parameters as levelDown and to actual postion X,Y + levelDownX,levelDownY
goUp (add) - move party to level defined in map parameters as levelUp and to actual postion X,Y + levelUpX,levelUpY
goto (x, y, dir, map) - Move party to another square on map or to another map.
hand - Returns actual item in hand of selected person from party.
isFirstCall (value) - Returns if there was first call, but don't change anything.
item - Returns actualy used item.
leader - Returns leader of persons.
lock - Returns actual lock.
map - Returns actual map.
meet (name) - Start meeting with NPC name. If NPC doesn't exist returns false.
meeting - Returns actual meeting with NPC
message (text, [delay=0]) - Add white line of text to message box.
messageBox (image, title, text, caption, width) - Shows dialog box on screen and waits for confirm.
monsters - Returns actuall list of all monsters.
panel - Returns actual panel dialog in icons part of screen.
party - Returns player's persons party.
play (filename) - Play audio file.
restMode - Returns if is now runngin restMode (faster time).
spawn - spawn monsters on this field, if possible. Monsters must have spawnProc=0
spell - Returns actualy casted spell.
spells - Returns all spells.
square - Returns square on which is party actually standing.
terminate - Terminate all scripts. Very dangerous. It's mostly system call and it can stuck game.
this - Returns actual class, defined by kind of event, which called this code
wait (count) - Wait for some time.
actor Returns actualy acting person or monster.
Returns
askBox (image, title, text, captionYes, captionNo, width) Shows confirmation dialog on screen and waits for choose. if (!askBox("images/basic/rest.gif","End level","Do you want to continue?","yes","no")) exit;
Parameters image - name
title - of dialog
text - in dialog
captionYes - of Yes button
captionNo - of No button
width - of window, default 400
see
break Breaks actual block (for, if, { )
cancelAction Exits from actual script and continue on next in queue
clearMessage Clear all messages in message box.
clicked Returns actualy clicked part of square.
Returns
dialog Returns actual dialog in view part of screen.
Returns
doKeyLock (name, key, keyId, [lockDeep], [lockLevel], [Id])
Parameters name - of open/unlock dialog
key - name of key which opens lock
keyId - this value must be equivalent to key's value of parameter keyId, to open the lock
[lockDeep] - how many parts have lock (if 0 - there is no lock)
[lockLevel] - how complicated is lock [0-100]
[Id] - identification of door's for storing status. This is usable only when you call same doors from diferent functions, or you have more that one door on a square.
Returns
doLock (name, key, keyId, lockDeep, lockLevel, lockStuck, trapLevel, doorStuck, Id) This function shows lock/open on screen and restore its actual status (openned/jammed) from actual game save. This means that you can call this function for any item, object on map or whatever to unlock/open it. For example you can have just single lock on wall and when you call
doLock("Lock","Rubby key",'',3,25,0,0,0);
you get just unlock dialog. Or you can have rusted doors w/o lock so you call doLock("Rusted doors","",'',0,0,0,0,35);
you will only be able to smash door. But chest can have lock, trap on doors and doors can be stucked. For this you can call this code if (doLock("Doors","Key",'1',5,15,20,5,30)) {
message("You has opened chest and found these items!");
showItems();
} else {
message("Sorry!");
}
Functions which can be called when lock is open are in class
lock.class
.
Parameters name - of open/unlock dialog
key - name of key which opens lock
keyId - this value must be equivalent to key's value of parameter keyId, to open the lock
lockDeep - how many parts have lock (if 0 - there is no lock)
lockLevel - how complicated is lock [0-100]
lockStuck - if lock is not open, with which power he blocks doors to open [0-100]
trapLevel - complexity of trap on doors [0-100], 0 - no trap
doorStuck - how are doors stucked [0-100] 100 can't be smashed
Id - identification of door's for storing status. This is usable only when you call same doors from diferent functions, or you have more that one door on a square.
Returns
see
doNext (x, y, element) it's shortcut for right code to change actual wall to next state.
map:doNext(map:clickedX,map:clickedY,map:clickedW);
Parameters x - x pos on map
y - y pos on map
element - element of x,y square (0..3-walls, 4-floor, 5-ceiling, 6-object, 7-flags)
Returns
doPickLock (name, lockDeep, lockLevel, [lockStuck], [doorStuck], [Id])
Parameters name - of open/unlock dialog
lockDeep - how many parts have lock (if 0 - there is no lock)
lockLevel - how complicated is lock [0-100]
[lockStuck] - if lock is not open, with which power he blocks doors to open [0-100]
[doorStuck] - how are doors stucked [0-100] 100 can't be smashed
[Id] - identification of door's for storing status. This is usable only when you call same doors from diferent functions, or you have more that one door on a square.
Returns
doTrapLock (name, trapLevel, [Id])
Parameters name - of open/unlock dialog
trapLevel - complexity of trap on doors [0-100]
[Id] - identification of door's for storing status. This is usable only when you call same doors from diferent functions, or you have more that one door on a square.
Returns
echo (text) Add line to message box.
Parameters
see
fight Returns actual fight.
Returns
firstCall (value) Returns if "value" doesn't exists and define it. This is usefull mechanism, when you, for example, enter square and you want to show some text only one time you can use this function. It will look like this:
if (firstCall()) {
dialog:open;
dialog:say("You has entered dark room. You see martyred body on bloody table in the middle of this room!");
dialog:close(@true);
}
and this will show only one time in all game. From this time parameters of this map will contains value "FR"+map.x+","+map.y.
Or another exmple, when you click on chest: if (firstCall()) {
$s="You has found chest, ";
if (showItems>0) message("and there are some items");
else message("but it's empty");
message($s.".");
} else {
message("Treasury is empty");
}
What it will do is clear.
Parameters value - [value="FR"+map.x+","+map.y] - identificator
see
goDown (add) move party to level defined in map parameters as levelDown and to actual postion X,Y + levelDownX,levelDownY
Parameters add - how many add in move direction to x,y
goUp (add) move party to level defined in map parameters as levelUp and to actual postion X,Y + levelUpX,levelUpY
Parameters add - how many add in move direction to x,y
goto (x, y, dir, map) Move party to another square on map or to another map.
Parameters x - on map
y - on map
dir - on map, default = actual dir, valid is <0..3>
map - name of level, default = actual map
hand Returns actual item in hand of selected person from party.
Returns
isFirstCall (value) Returns if there was first call, but don't change anything.
Parameters value - default = "FR"+map.x+","+map.y.
see
item Returns actualy used item.
Returns
leader Returns leader of persons.
Returns
lock Returns actual lock.
Returns
map Returns actual map.
Returns
meet (name) Start meeting with NPC name. If NPC doesn't exist returns false.
Parameters name - name of NPC which you want to meet
Returns
meeting Returns actual meeting with NPC
Returns
message (text, [delay=0]) Add white line of text to message box.
Parameters text - of line
[delay=0] - wait [delay] s, default = 0
see
messageBox (image, title, text, caption, width) Shows dialog box on screen and waits for confirm. Example:
messageBox("images/basic/rest.gif","Nice day","It's nice day!","Ok");
Parameters image - name
title - of dialog
text - in dialog
caption - of button
width - of window, default 400
see
monsters Returns actuall list of all monsters.
Returns
panel Returns actual panel - dialog in icons part of screen.
Returns
party Returns player's persons party.
Returns
play (filename) play("sounds/basic/die.wav");
Parameters filename - name of file starting in root of game data dir
restMode Returns if is now runngin restMode (faster time).
Returns
spawn spawn monsters on this field, if possible. Monsters must have spawnProc=0
Returns boolean if operation was successfull
spell Returns actualy casted spell.
Returns
spells Returns all spells.
Returns
square Returns square on which is party actually standing.
Returns
terminate Terminate all scripts. Very dangerous. It's mostly system call and it can stuck game.
this Returns actual class, defined by kind of event, which called this code
Returns
wait (count) Wait for some time.
Parameters count - wait for count * fightSpeed constant miliseconds.
Generated by Hideoshi's Documentation Tool on 28.10.2003 20:08:54