Ordering pets to move

Post Reply
daviewart
Posts: 14
Joined: Sun Jun 21, 2015 5:32 am

Ordering pets to move

Post by daviewart »

Hi guys,

I am looking for advice and perhaps a clue on how to convert a set of commands from Vadi's map. Whereby they order a pet to move in the directions to drop of an item to newbies.

(mapper): Directions from A DIM COMMODITIES SHOP to DENSE THICKET IN EASTERN ITHMIA:
(mapper): w, n, ne, ne, e, e, se, se, s, e, e, s, ne, ne, se, e, ne, n, ne, nw, w, up, up, sw, s, e,
up, up, up, w, ne, n, se, n, n, e, ne, n, n, ne, ne, w, ne, ne, ne, n, n, e, ne, n, nw, nw, nw, n,
n, n, n, n, n, n, ne, n, se, e, e, e, se, se, sw, se, e, se, s, e, se


Focusing more on this section:

(mapper): w, n, ne, ne, e, e, se, se, s, e, e, s, ne, ne, se, e, ne, n, ne, nw, w, up, up, sw, s, e,
up, up, up, w, ne, n, se, n, n, e, ne, n, n, ne, ne, w, ne, ne, ne, n, n, e, ne, n, nw, nw, nw, n,
n, n, n, n, n, n, ne, n, se, e, e, e, se, se, sw, se, e, se, s, e, se

So that it captures the line given it maybe only 3 steps or 50 steps. I tried to see if I could do this to test if it captures.
Code: [show] | [select all] lua
^\(mapper\) (.+)\,  (.+)\.$

followed by:
send("tell pet go " ..matches[1])
send("tell pet go " ..matches[2]) 
This did nothing except once it spammed this:
You tell porky, "Go e, s."
Anyone got a clue on how to do this? As it could be a fun script to use for newbie that join in order to help them out

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Ordering pets to move

Post by SlySven »

I'm a novice on that part of things but I wonder if the indexes used for "matches[x]" is right - don't you have to start the numbering at '2' for the first match (IIRC matches[1] might have the whole line or something like that...?) :?

EulersIdentity
Posts: 27
Joined: Fri Jun 26, 2015 8:52 am

Re: Ordering pets to move

Post by EulersIdentity »

You can capture the entire string of directions, then split the string up.

Trigger: ^\(mapper\) (.+)\.$
Set up this function:
Code: [show] | [select all] lua
function splitAtComma (str)
	local splitted = {}
	str = tostring(str:gsub(",",""))
	if string.find(str," ") then
		for word in string.gmatch(str, "%a+") do
			table.insert(splitted,word)
		end
	end
        return splitted
end
Then in the trigger script have it do:
Code: [show] | [select all] lua
directions = splitAtComma(matches[2])   -- directions is now an array of the directions
-- now send a tell for each element in the array
for i,v in ipairs(directions) do
     send("tell pet go "..v)
end
Alternatively, just TELL PORKY Download Mudlet and do your own damn autopathing.

Post Reply