stripcaged: allow shortened arguments

develop
jj 2012-12-12 18:11:56 +01:00
parent 7315f8cec4
commit 722ed79a98
1 changed files with 16 additions and 12 deletions

@ -138,7 +138,10 @@ if here_only
if not it.kind_of?(DFHack::ItemCagest) and not it.kind_of?(DFHack::ItemAnimaltrapst) if not it.kind_of?(DFHack::ItemCagest) and not it.kind_of?(DFHack::ItemAnimaltrapst)
list = df.world.items.other[:ANY_CAGE_OR_TRAP].find_all { |i| df.at_cursor?(i) } list = df.world.items.other[:ANY_CAGE_OR_TRAP].find_all { |i| df.at_cursor?(i) }
end end
puts 'Please select a cage' if list.empty? if list.empty?
puts 'Please select a cage'
throw :script_finished
end
elsif ids = $script_args.find_all { |arg| arg =~ /^\d+$/ } and ids.first elsif ids = $script_args.find_all { |arg| arg =~ /^\d+$/ } and ids.first
list = [] list = []
@ -153,7 +156,10 @@ elsif ids = $script_args.find_all { |arg| arg =~ /^\d+$/ } and ids.first
list << it list << it
end end
} }
puts 'Please use a valid cage id' if list.empty? if list.empty?
puts 'Please use a valid cage id'
throw :script_finished
end
else else
list = df.world.items.other[:ANY_CAGE_OR_TRAP] list = df.world.items.other[:ANY_CAGE_OR_TRAP]
@ -162,18 +168,16 @@ end
# act # act
case $script_args[0] case $script_args[0]
when 'items' when /^it/i
cage_dump_items(list) if not list.empty? cage_dump_items(list)
when 'armor' when /^arm/i
cage_dump_armor(list) if not list.empty? cage_dump_armor(list)
when 'weapons' when /^wea/i
cage_dump_weapons(list) if not list.empty? cage_dump_weapons(list)
when 'all' when 'all'
cage_dump_all(list) if not list.empty? cage_dump_all(list)
when 'list' when 'list'
cage_dump_list(list) if not list.empty? cage_dump_list(list)
else else
puts <<EOS puts <<EOS
Marks items inside all cages for dumping. Marks items inside all cages for dumping.