All pastes #806120 Raw Edit

Someone

public text v1 · immutable
·published 2007-12-04 23:43 UTC
rendered paste body
Hey there. I've seen alot of requests for information about scripting commands that are newer, and not documented in the Genie help files/Scripting manual. So in a fit of boredome today, I ran through all of Conny's posts in the announcements folder, copied all the new commands down, and double checked which ones are not listed on the genieclient website. Let me know if you need me to try and explain anything better.

* Gosub clear - used to clear the gosub depth


ACTION:
Command: action <command> when <text>

* <command> is the action to take

* <text> is the string from the game in which you wish to trigger on

Command: action remove <text>

* removes the action command that is triggered off of that text.

Command: action clear

* removes all actions from the script until you reload them.



Additional Features:

* The ACTION command has a INSTANT option. When a GOTO is used in

   a action it waits for roundtime before going to that label. Using the

   INSTANT keyword you can have it ignore roundtime and hit the label

   instantly.

Example: action instant goto dead when ^Your death cry echoes in your brain



* Action groups are used to activate/inactivate a "set" of actions. The ()

characters right after the action word marks group.

Syntax: action (groupname) <command> when <text>

Example:

action (mygroup) echo Hello world when Hi

action (mygroup) echo Greetings when Heya

to disable the "mygroup" triggers use: action (mygroup) inactivate

to enable them use: action (mygroup) activate



* Using if/then in an Action:

You may use an IF statement within an Action.

Example: ACTION IF %monstercount > 3 THEN goto changeroom WHEN  

begins to advance



* There are several built in Action commands (health, mana, fatigue,

   spirit, monster) that you may use in conjunction with an Action.  These

   Actions will fire "behind the scenes".  

   The new actions are fired somewhat randomly (not only when value

   changes) so use them in combination with a IF check.

Examples:

action if %monstercount > 3 then goto changeroom when monster

action if %health < 50 then goto heal when health

action if %mana < 30 then goto rest when mana



IF:
Command: if <expression> <compare> <expression> then <command>

Example: if %c > 10 then goto done

Example: if "%weapon" = "scimitar" then goto scimitar

Example:  if not hidden then gosub hide

<expression> is what to compare.

<compare> is how to compare the expressions. valid compare syntax is: not, =, ==, !=, <>, >=, <=, >, <, indexof

<command> is the action to take. you may use gosub from a IF command



* indexof - There are a few rules to keep in mind when using indexof

1) In it's current state, Indexof can not compare 2 lists.

2) the list you are comparing to has to be the first item. I.E:

    if "scimitar|longbow|bastard sword" indexof "%rhand" then goto fight

    or

    if "%roomitems" indexof "bloodstone" then gosub GetGem bloodstone

3) The second item must be an exact syntax match to an item in the list.

    if the item in your left hand is a crocodile skin, this will work:

    if "gargoyle hide|Azure-scaled hide|crocodile skin" indexof "%lhand" then goto bundle

    if the item in your left hand is a crocodile skin, this will not work:

    if "hide|skin|pelt" indexof "%lhand" then goto bundle



* else - Used in combination with the if command. It simply remembers if last if statement was true or not. If it was false it executes.

  Example:

  if "%rhand" = "%weapon" then goto fight

  else goto get.weapon


Include:
Include is used to include other scripts or snippets in your current script. It is a great tool for saving you time

when it comes to editing.  For example, you can write 1 foraging script and include it into as many different scripts as you wish.

When you need to edit the foraging section, you can edit this one script and it will effect all of the other scripts that have this

file included in.

Warning: You may include from an include file. If you are not cautious you may cause genie to crash/freeze with include loops.

You should make sure that you do not put the include command in the path of the script.  Genie will search your script for

included files when the script loads.  It will treat the included script as if it were written into the original script.

You can gosub into and return out of an included script as if it were all written as one.

Syntax: include <filename>

  

goto start

  

include forage.cmd

include juggle.cmd

  

start:

gosub forage

gosub juggle

goto start

Math:
math is used to do math functions on varibles.

Syntax: math <variablename> <add/substract/multiply/divide/modulus> <value or another variablename>

Example: math myvariable add 10

Example: math myvariable subtract %myothervariable

Modulus example: math 22 mod 6 would give you an output of 4, because 22 / 6 = 3 with a remainder of 4 (Thanks Conny!)

*note* you don't use "%" with math unless it's the second variable.


Random:
random - A command to get random numbers

Example:

random 1 10

echo %r


Commands:
#statusbar

Syntax: #statusbar <panel0/panel1/panel2/panel3> <text>

Example: #statusbar panel1 Hello World!

#layout - This is used if you want to load a layout file. Syntax: #layout filename

#remvariable - This is used to remove a global variable
#echo. Used to send text to any output window.

Syntax: #echo game/familiar/thoughts/log1/log2/log3/log4/log5 <text>

Example: #echo log1 HELLO WORLD

#if. Used to do condition checks. Works the same way as the script command if. except it's used in Global triggers and settings

#else. Works the same was as script else but works off the #if command in global triggers and settings

  Example: insert this as the NUMBERPAD6 Macro, and it will autosneak while hidden. #if hidden then sneak east;#else east

#math. Used to do math functions on global variables.

Built in Variables:
%health - Your health points on a scale of 1-100

%mana - Your mana points on a scale of 1-100

%fatigue Your fatigue points on a scale of 1-100

%spirit Your spirit points on a scale of 1-100

%preparedspell If you are preparing a spell, the spell name will fill this variable, otherwise it will be listed as None



These should all be self explanitory -

%roomtitle

%roomdesc

%roomitems

%roomcharacters

%roomexits

%timestamp

%datestamp