A Lich script is a Ruby file with access to special methods and objects:
example.lic
# Output to the user (appears in script window)echo "Starting script..."# Send commands to the gameput "look"# Wait for specific text from the gamewaitfor "Obvious exits:"# Get the next line from the gameline = get# Output back to the main game windowrespond "Script complete!"
# Wait for specific textwaitfor "arrives."# Wait with a timeoutmatchtimeout 5, "arrives.", "leaves."# Wait for roundtime to expirewaitrt?# Wait for a conditionwait_until { Char.mana > 50 }
# Find all NPCs in the roomGameObj.npcs.each do |npc| echo npc.nameend# Check what's in your right handGameObj.right_hand.name# Find items in the roomGameObj.loot.find { |obj| obj.name =~ /sword/ }
XMLData.room_id # Current room IDXMLData.room_count # Rooms visited this sessionXMLData.roundtime_end # When roundtime expiresXMLData.active_spells # Hash of active spells
# Start another scriptstart_script "myother"# Start with argumentsstart_script "hunter", ["dirge", "careful"]# Force start (even if already running)force_start_script "watcher"
# Check if a script is runningif running? "healer" echo "Healer is already active"end# List all running scriptsScript.list.each do |script| echo script.nameend
# Save data between script runsUserVars.last_hunt ||= Time.nowUserVars.kill_count ||= 0UserVars.kill_count += 1echo "Total kills: #{UserVars.kill_count}"
# Wait for something to arrivewait_until { GameObj.npcs.any? { |npc| npc.name =~ /merchant/ } }# Wait for a buff to expirewait_until { !Spell[101].active? }