Lich script development: Difference between revisions
No edit summary |
m (→events) |
||
(14 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{RTOC}} |
|||
== common, common-crafting, common-money, common-summoning, common-travel== |
|||
== Lich script libraries == |
|||
These are lich scripts, but do not accomplish a task. Rather, they provide functionality that other scripts can take advantage of. |
|||
=== bootstrap === |
|||
{{Lich script |
{{Lich script |
||
|description= |
|description= |
||
|usage=You can turn on debug mode with <code>;e UserVars.bootstrap_debug = true</code> |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== common === |
|||
{{Lich script |
|||
|description=A large set of helper functions for common actions shared by many scripts. |
|||
|usage= |
|usage= |
||
Probably the single most useful function in this file is <code>bput</code> (short for 'blocking put'). |
|||
bput is designed to be a more robust version of fput in situations where you know the desired response from the game. Unlike fput which will resend the same command repeatedly until it sees the desired message first from the game, bput only sends a given command one time (unless round time or type ahead errors occur) and then waits for the desired response. if the desired response isn't seen bput will eventually time out and echo debugging information. |
|||
This would never work because the game sends a response line "You search around..." before "Roundtime" is encountered: |
|||
<code>fput "forage grass", 'Roundtime'</code> |
|||
Similarly a command that can only succeed once can cause fput to hang. In this case, you have to deal with the failure case and just spam the command until failure in a noisy room with fput: |
|||
<code>fput "get box", 'you pick up', 'get what?'</code> |
|||
Lets you know with confidence if a box was picked up or if the item was missing: |
|||
<code>bput "get box", 'you pick up', 'get what?'</code> |
|||
|args= |
|args= |
||
|settings= |
|settings= |
||
Line 9: | Line 40: | ||
}} |
}} |
||
== |
=== common-arcana === |
||
{{Lich script |
|||
Useful if you are doing development on Windows. Set the LICH_SCRIPTS environment variable to the path to your lich/scripts/ directory. |
|||
|description=A large set of helper functions for common actions related to spell casting, ability activation, etc. |
|||
|usage= |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== common-crafting === |
|||
{{Lich script |
|||
|description=A large set of helper functions for common actions related to crafting. |
|||
|usage= |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== common-healing === |
|||
{{Lich script |
|||
|description=A large set of helper functions for common actions related to health, wounds, and healing. |
|||
|usage= |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== common-items === |
|||
{{Lich script |
|||
|description=A large set of helper functions for common actions related to manipulating items. |
|||
|usage= |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== common-money === |
|||
{{Lich script |
|||
|description=A large set of helper functions for common actions related to money and coins. |
|||
|usage= |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== common-summoning === |
|||
{{Lich script |
|||
|description=A large set of helper functions for common actions related to summoning weapons. |
|||
|usage= |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== common-travel === |
|||
{{Lich script |
|||
|description=A large set of helper functions for common actions related to travel. |
|||
|usage= |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== dependency === |
|||
{{Lich script |
|||
|description= |
|||
|usage= |
|||
For first time setup, see the Getting Started section of the repository README: https://github.com/rpherbig/dr-scripts/blob/master/README.md |
|||
You'll want to remove any of our scripts that you replace with this from the auto start so they aren't getting run twice. |
|||
Useful helpers: |
|||
* <code>get_script('name')</code> - fetch the script and start tracking it |
|||
* <code>get_yaml('filename')</code> - download the specified yaml file to your profiles directory |
|||
* <code>list_autostarts</code> - show all scripts that are started automatically |
|||
* <code>autostart(script)</code> - add a script to the autostart list |
|||
* <code>remove_autostart(script)</code> - remove a script from the autostart list |
|||
* <code>list_tracked_scripts</code> |
|||
You can turn on debug mode by passing 'debug' as an argument with <code>;dependency debug</code> |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== drinfomon === |
|||
{{Lich script |
|||
|description=Updated info tracking for use in other scripts in DragonRealms |
|||
|usage= |
|||
* skill tracking - name/rank/xp |
|||
* info tracking - everything listed under info other than debt wealth and birthdate |
|||
Provides some additional commands to the user: |
|||
* <code>;banks</code> - Tracks your money and converts copper strings to plat format. Not all locations tracked. |
|||
* <code>;vault</code> - Tracks vault contents and location. -not all location included |
|||
Display experience gain in your Field Experience window: |
|||
* <code>;e UserVars.track_exp=true</code> |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== events === |
|||
{{Lich script |
|||
|description=Flags are simple true/false string detectors. |
|||
|usage= |
|||
* <code><nowiki>Flags.add(<key>, <trigger>|[<trigger1,...,triggerN])</nowiki></code> |
|||
* <code><nowiki>Flags.add('test', 'exp help')</nowiki></code> |
|||
* <code><nowiki>Flags.add('another', 'exp help', 'a second message')</nowiki></code> |
|||
This creates a new flag "test", which will return the matched string any time you see a message containing "exp help". Note that |
|||
the message will be treated as a regular expression and is case insensitive (google for more info) so be careful with |
|||
special characters, remember to use single quote strings if you're going to use special characters. |
|||
Calling add with the same key will overwrite any previous matchers and reset the flag. |
|||
Alternatively you can add an array with multiple matchers. If multiple messages match the flag will be set to the first match found. |
|||
* <code><nowiki>Flags.add('skillexp', '(\w[^:\(\)]+):\s+(\d+)\s\d+\.\d+%[^\(\)]*\((\d+)\/\d+\)')</nowiki></code> |
|||
This example will add a flag watching for the results of an exp message, specifically "exp skillname". |
|||
After sending "exp mech" to the game Flags['skillexp'] would contain... |
|||
["Mechanical Lore: 146 16.82% focused (20/34)", "Mechanical Lore", "146", "20"] |
|||
You can see the array containing entire matched string and the three capture groups containing |
|||
skill name, ranks, and mind state. |
|||
* <code><nowiki>Flags['test']</nowiki></code> |
|||
Returns the match if you've seen any message matching after you called add (or reset); false otherwise |
|||
* <code><nowiki>Flags['test'] = false</nowiki></code> |
|||
* <code><nowiki>Flags.reset('test')</nowiki></code> |
|||
Both of these commands have the same effect, reseting a flag as if it hasn't been seen yet. |
|||
* <code><nowiki>Flags.delete('test')</nowiki></code> |
|||
Removes a flag, stopping any tracking of it. |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
=== sorter === |
|||
{{Lich script |
|||
|description=A script that converts inventories into sorted categories. |
|||
|usage= |
|||
|args= |
|||
|settings={{Lich setting|name=width|desc=<nowiki>(0-9999)</nowiki> Specify how many characters wide your game window is, and the script will display container contents in columns.}}^{{Lich setting|name=mute_old_inventory|desc=<nowiki>(True|False)</nowiki> Will mute the normal output for inventory, so you don't get sorted version and the normal output}}^{{Lich setting|name=sort_inv_command|desc=<nowiki>(True|False)</nowiki> Sorts the output from command "inventory"}}^{{Lich setting|name=sort_look_others|desc=<nowiki>(True|False)</nowiki> Sorts the output looking at other players}}^{{Lich setting|name=sort_look_items_command|desc=<nowiki>(True|False)</nowiki> Sorts the output from command "look item"}}^{{Lich setting|name=ignore_categories|desc=Categories from base-items.yaml to ignore. Enter in regex format. Default is <code><nowiki>lootables|trash</nowiki></code>}} |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
===spellmonitor=== |
|||
{{Lich script |
|||
|description= |
|||
|usage= |
|||
* <code>DRSpells.prep_spell</code> - returns the string name of the currently preparing spell or nil |
|||
* <code>DRSpells.active_spells</code> - returns hash of spells keyed to duration e.g. <code>{"Bless"=>5, "Minor Physical Protection"=>12}</code> |
|||
** 0 means fading, removed from the hash is worn off |
|||
|args= |
|||
|settings= |
|||
|uservars= |
|||
|children= |
|||
}} |
|||
== Development tools == |
|||
=== create_symlinks.bat === |
|||
Useful if you are doing development on Windows. Set the LICH_SCRIPTS environment variable to the path to your <code>lich/scripts/</code> directory. |
|||
=== create_symlinks.sh === |
|||
Useful if you are doing development on OSX or Linux. Pass it an argument of the path to your <code>lich/scripts/</code> directory. |
|||
=== util/calculate_new_loot.rb === |
|||
Compares <code>profiles/*-setup.yaml</code> files against <code>profiles/base.yaml</code> to determine proper loot_additions and loot_subtractions settings. |
|||
{{cat|Lich scripts}} |
|||
== create_symlinks.sh == |
|||
Useful if you are doing development on OSX or Linux. Pass it an argument of the path to your lich/scripts/ directory. |
Latest revision as of 21:19, 11 June 2022
Lich script libraries
These are lich scripts, but do not accomplish a task. Rather, they provide functionality that other scripts can take advantage of.
bootstrap
Script usage: You can turn on debug mode with ;e UserVars.bootstrap_debug = true
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common
A large set of helper functions for common actions shared by many scripts.
Script usage: Probably the single most useful function in this file is bput
(short for 'blocking put').
bput is designed to be a more robust version of fput in situations where you know the desired response from the game. Unlike fput which will resend the same command repeatedly until it sees the desired message first from the game, bput only sends a given command one time (unless round time or type ahead errors occur) and then waits for the desired response. if the desired response isn't seen bput will eventually time out and echo debugging information.
This would never work because the game sends a response line "You search around..." before "Roundtime" is encountered:
fput "forage grass", 'Roundtime'
Similarly a command that can only succeed once can cause fput to hang. In this case, you have to deal with the failure case and just spam the command until failure in a noisy room with fput:
fput "get box", 'you pick up', 'get what?'
Lets you know with confidence if a box was picked up or if the item was missing:
bput "get box", 'you pick up', 'get what?'
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common-arcana
A large set of helper functions for common actions related to spell casting, ability activation, etc.
Script usage:
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common-crafting
A large set of helper functions for common actions related to crafting.
Script usage:
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common-healing
A large set of helper functions for common actions related to health, wounds, and healing.
Script usage:
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common-items
A large set of helper functions for common actions related to manipulating items.
Script usage:
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common-money
A large set of helper functions for common actions related to money and coins.
Script usage:
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common-summoning
A large set of helper functions for common actions related to summoning weapons.
Script usage:
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
common-travel
A large set of helper functions for common actions related to travel.
Script usage:
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
dependency
Script usage: For first time setup, see the Getting Started section of the repository README: https://github.com/rpherbig/dr-scripts/blob/master/README.md
You'll want to remove any of our scripts that you replace with this from the auto start so they aren't getting run twice.
Useful helpers:
get_script('name')
- fetch the script and start tracking itget_yaml('filename')
- download the specified yaml file to your profiles directorylist_autostarts
- show all scripts that are started automaticallyautostart(script)
- add a script to the autostart listremove_autostart(script)
- remove a script from the autostart listlist_tracked_scripts
You can turn on debug mode by passing 'debug' as an argument with ;dependency debug
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
drinfomon
Updated info tracking for use in other scripts in DragonRealms
Script usage:
- skill tracking - name/rank/xp
- info tracking - everything listed under info other than debt wealth and birthdate
Provides some additional commands to the user:
;banks
- Tracks your money and converts copper strings to plat format. Not all locations tracked.;vault
- Tracks vault contents and location. -not all location included
Display experience gain in your Field Experience window:
;e UserVars.track_exp=true
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
events
Flags are simple true/false string detectors.
Script usage:
Flags.add(<key>, <trigger>|[<trigger1,...,triggerN])
Flags.add('test', 'exp help')
Flags.add('another', 'exp help', 'a second message')
This creates a new flag "test", which will return the matched string any time you see a message containing "exp help". Note that the message will be treated as a regular expression and is case insensitive (google for more info) so be careful with special characters, remember to use single quote strings if you're going to use special characters. Calling add with the same key will overwrite any previous matchers and reset the flag. Alternatively you can add an array with multiple matchers. If multiple messages match the flag will be set to the first match found.
Flags.add('skillexp', '(\w[^:\(\)]+):\s+(\d+)\s\d+\.\d+%[^\(\)]*\((\d+)\/\d+\)')
This example will add a flag watching for the results of an exp message, specifically "exp skillname". After sending "exp mech" to the game Flags['skillexp'] would contain...
["Mechanical Lore: 146 16.82% focused (20/34)", "Mechanical Lore", "146", "20"]
You can see the array containing entire matched string and the three capture groups containing skill name, ranks, and mind state.
Flags['test']
Returns the match if you've seen any message matching after you called add (or reset); false otherwise
Flags['test'] = false
Flags.reset('test')
Both of these commands have the same effect, reseting a flag as if it hasn't been seen yet.
Flags.delete('test')
Removes a flag, stopping any tracking of it.
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
sorter
A script that converts inventories into sorted categories.
Script usage:
Script arguments:
Settings used in this script:
- width: (0-9999) Specify how many characters wide your game window is, and the script will display container contents in columns.
- mute_old_inventory: (True|False) Will mute the normal output for inventory, so you don't get sorted version and the normal output
- sort_inv_command: (True|False) Sorts the output from command "inventory"
- sort_look_others: (True|False) Sorts the output looking at other players
- sort_look_items_command: (True|False) Sorts the output from command "look item"
- ignore_categories: Categories from base-items.yaml to ignore. Enter in regex format. Default is
lootables|trash
UserVars used in this script:
Other scripts used by this script:
spellmonitor
Script usage:
DRSpells.prep_spell
- returns the string name of the currently preparing spell or nilDRSpells.active_spells
- returns hash of spells keyed to duration e.g.{"Bless"=>5, "Minor Physical Protection"=>12}
- 0 means fading, removed from the hash is worn off
Script arguments:
Settings used in this script:
UserVars used in this script:
Other scripts used by this script:
Development tools
create_symlinks.bat
Useful if you are doing development on Windows. Set the LICH_SCRIPTS environment variable to the path to your lich/scripts/
directory.
create_symlinks.sh
Useful if you are doing development on OSX or Linux. Pass it an argument of the path to your lich/scripts/
directory.
util/calculate_new_loot.rb
Compares profiles/*-setup.yaml
files against profiles/base.yaml
to determine proper loot_additions and loot_subtractions settings.