Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eddy swap script #6741

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions eddy-swap.lic
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
=begin

Modification of the tool-clerk script. Designed to get/put specified sets of items from/into your portal.

Yaml will need to have a portal_store: section added with specified sets and items you want to get and put. You can also link existing sets (like crafting tools) if desired.

You can also designate a container in your portal to get items from/put items into using the portal_container setting.

Example configuration:

<in your crafting section>
alchemy_tools: &alchemy_tools
- mortar
- pestle
- bowl
- mixing stick
- sieve

portal_store:
weapons:
items:
- broadsword
- bar mace
- javelin

alchemy_tools:
items: *alchemy_tools

forging_tools:
items: *forging_tools
portal_container: forging apron

You can then run the script with weapons, alchemy_tools, or forging_tools as the "set" argument and it'll leverage those items.

If any of the containers require adjective and noun, wrap the words in double quotes. Example: "leather pack"

TODO:
- Test with multiple bags of the same type in the portal (e.g., first backpack, second backpack)
- Error handling for full bags

=end
custom_require.call(%w[common common-items equipmanager])

class Eddy
def initialize
arg_definitions = [
[
{ name: 'set', regex: /\w+/i, optional: false, description: 'REQUIRED: Set of items you want to transfer. Build in portal_store section of yaml.' },
{ name: 'action', regex: /get|put/i, optional: false, description: 'REQUIRED: Designate whether you want to get items from portal/put items into portal. Must be get or put.' },
{ name: 'container', regex: /\w+/i, optional: false, description: 'REQUIRED: Worn container you want to put your items into/get items from. Wrap multiple words in double quotes, ex: "leather pack"' }
]
]

portal_container = nil

settings = get_settings

args = parse_args(arg_definitions)
action = args.action
set = args.set
store_data = settings.portal_store[set]
item_swap = store_data['items']
portal_container = store_data['portal_container']
container = args.container

if action.nil? || set.nil? || container.nil?
DRC.message("Missing a required argument!")
exit
end

portal_check

if item_swap.nil?
DRC.message("Portal_store setting #{set} is empty or doesn't exist!")
exit
end

container_check(container, portal_container)

if action == 'get'
get_items(item_swap, container, portal_container)
elsif action == 'put'
put_items(item_swap, container, portal_container)
else
echo 'Unknown action'
end
end

def portal_check
return if DRCI.exists?("eddy")

DRC.message("You need to be wearing a portal to use this script!")
exit
end

def container_check(container, portal_container = nil)
if !portal_container.nil?
return if DRCI.inside?(portal_container, "portal")
DRC.message("Couldn't find the specified container in your portal!")
exit
elsif DRCI.exists?(container)
return
else
DRC.message("Couldn't find the specified container!")
exit
end
end

def get_items(item_swap, container, portal_container = nil)
item_swap.each do |item|
if !portal_container.nil?
return unless DRCI.inside?("#{item}", "#{portal_container} in my portal")

DRCI.get_item?("#{item}", "#{portal_container} in my portal")
DRCI.put_away_item?("#{item}", container)
elsif DRCI.exists?("#{item}", "portal")
DRCI.get_item?("#{item}", "portal")
DRCI.put_away_item?("#{item}", container)
else
DRC.message("Couldn't find #{item} in your portal! Exiting script!")
exit
end
end
end

def put_items(item_swap, container, portal_container = nil)
item_swap.each do |item|
if DRCI.exists?("#{item}", container)
DRCI.get_item?("#{item}", container)
if !portal_container.nil?
fput("put my #{item} in #{portal_container} in my portal")
fput("put my #{item} in #{portal_container} in my portal")
else
DRCI.put_away_item?("#{item}", "portal")
end
else
DRC.message("Coudln't find #{item} in your #{container}! Exiting script!")
exit
end
end
end
end

Eddy.new
11 changes: 11 additions & 0 deletions profiles/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2566,3 +2566,14 @@ tome_settings:
- crossing-repair
- task-forage
debug: false

# Settings for the eddy-swap script, which is designed to take items out of/put items into a Corn Maze portal.
portal_store:
# Create a set name for your items. This set will be called as a argument when running the script.
example:
# Items you'd like to move into/out of the portal. Items that are already in a list, such as workorder tools, can be linked.
items:
- godkiller blade
- bagof holding
# If you want to use containers within your portal for organization, set the portal_container value. This is an optional setting.
portal_container: example baldric
Loading