-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmapnav.lic
More file actions
128 lines (107 loc) · 3.94 KB
/
mapnav.lic
File metadata and controls
128 lines (107 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
=begin
Navigate and map areas that mapmap can't by moving the direction specified and recording the data.
I primarily created this to map the area to Dragonspine Fane in Zul Logoth, as mapmap was getting confused by the staircases.
;mapnav help
;mapnav inspect
;mapnav climb downward stairs
author: LostRanger (thisgenericname@gmail.com)
game: Gemstone
tags: core
version: 0.1.1
required: Lich >= 4.2.0
changelog:
0.1.1 (2017-04-17):
fixed 'save' not terminating script
0.1 (2017-04-17):
initial release
=end
command = script.vars[0].downcase
if not command or command == "help"
if not command
echo "no command specified, showing help"
end
# Code shamelessly plundered from mapmap
script_starter = "#{$lich_char}#{script.name}"
script_spacerr = ''.ljust(script_starter.length, ' ')
respond
respond "This script manually updates your local map database in a simple four-step process:"
respond " 1. Add the current room you're in (if it's not already in the DB)"
respond " 2. Perform the specified command (e.g. GO DOOR or NORTH)"
respond " 3. Add the room you arrive in (if it's not already in the DB)"
respond " 4. Update the appropriate movement information for the origin room."
respond ""
respond "The database will not be updated if the move command fails or you otherwise end up in the same room"
respond "that you started in."
respond
respond "Changes this script makes to your map database are not saved immediately. Use #{script_starter} SAVE"
respond "or invoking another script that saves map changes (e.g. #{$lich_char}mapmap) will cause changes to be"
respond "saved."
respond
respond "Usage:"
respond
respond " #{script_starter} help Shows this help text."
respond
respond " #{script_starter} inspect Inspect the current room."
respond
respond " #{script_starter} create Create current room in the map database if it doesn't exist, "
respond " #{script_spacerr} then inspect it."
respond
respond " #{script_starter} save Save the map database."
respond
respond " #{script_starter} MOVEMENT Execute MOVEMENT (e.g. 'go doorway') and record the result."
respond
respond "This script is not foolproof."
respond
exit
end
if command == "inspect"
current = Room.current
if current.nil?
echo "no matching room found in DB"
exit
end
echo "showing details for room ##{current.id}"
respond current.inspect
exit
end
if command == "create"
current = Room.current
if current.nil?
echo "no matching room found in DB, creating it"
current = Room.current_or_new
end
echo "showing details for room ##{current.id}"
respond current.inspect
exit
end
if command == "save"
Map.save
echo "map data saved"
exit
end
is_direction = ["north","south","east","west","northeast","northwest","southeast","southwest","ne","nw","se","sw","out","up","down"].any?{ |dir| dir.start_with?(command) }
is_go = command.start_with?("go ", "climb ", "swim ")
if not (is_direction or is_go)
echo "suspicious command '#{command}'. You might have meant '#{$lich_char}#{script.name} help'. Trying your movement command anyways, use #{$lich_char}kill #{script.name} if navigation hangs..."
end
origin = Room.current_or_new
origin_id = String(origin.id)
move command
destination = Room.current_or_new
destination_id = String(destination.id)
if destination_id == origin_id
echo "Destination room and origin room are the same (##{origin_id}). Not recording navigation."
exit
end
old_wayto = origin.wayto[destination_id]
if old_wayto == command
echo "'#{command}' from room ##{origin_id} already goes to ##{destination_id}, no changes made."
exit
elsif old_wayto
echo "Replacing previous wayto '#{old_wayto}'"
end
origin.wayto[destination_id] = command
if origin.timeto[destination_id].nil?
origin.timeto[destination_id] = 0.2 # Seems to be a default, not entirely certain what it does (Maybe factor in RT?)
end
echo "'#{command}' from room ##{origin_id} now goes to ##{destination_id}."