forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addroom.lic
71 lines (54 loc) · 1.93 KB
/
addroom.lic
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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#addroom
=end
arg_definitions = [
[
{ name: 'path', display: 'path to map', regex: /^[\w\s,]+$/i, variable: true, description: 'comma separated list of directions to map, use double quotes to wrap. "north, south"' },
{ name: 'debug', regex: /debug/i, optional: true },
{ name: 'manual', regex: /manual/i, optional: true, description: 'Don\'t automatically checkout and commit mapdb to lich' }
]
]
args = parse_args(arg_definitions)
$debug_mode_ar = UserVars.add_room_debug || args.debug
$skip_checkout = args.manual
$last_room = nil
def multimap(args)
directions = args.path.split(',')
echo("multimap:#{directions}") if $debug_mode_ar
directions.each { |dir| map_room(dir.strip) }
end
def map_room(dir)
echo("map:#{dir}") if $debug_mode_ar
time_step = 0.2
base_room = $last_room || Room.current
echo("snapshot_base:#{base_room.id}") if $debug_mode_ar
move dir
new_room = Room.current_or_new
if new_room == base_room && reget(10, 'You can\'t do that while lying down')
fput('stand')
move dir
new_room = Room.current_or_new
end
if new_room == base_room
echo('move failed, sorry. stopping')
start_script 'repository', ['release-mapdb'] unless $skip_checkout
exit
end
echo("snapshot_base:#{base_room.id}") if $debug_mode_ar
echo("snapshot_new:#{new_room.id}") if $debug_mode_ar
new_id = new_room.id
echo("base.wayto:#{base_room.wayto}") if $debug_mode_ar
base_room.wayto = {} unless base_room.wayto
base_room.wayto[new_id.to_s] = dir
echo("base.wayto:#{base_room.wayto}") if $debug_mode_ar
base_room.timeto[new_id.to_s] = time_step
$last_room = new_room
end
start_script 'repository', ['checkout-mapdb'] unless $skip_checkout
while Script.running?('repository')
end
multimap(args)
start_script 'repository', ['upload-mapdb'] unless $skip_checkout
while Script.running?('repository')
end
$last_room = nil