Marco said:
TWO Last Questions:
1) Is there a place in MUSHclient where the last direction taken is stored? I would like using a table to reverse this direction (e.g. if went nord , i came from south obviusly, so i'd like to memorize south in the variable.
I have some tips here: http://www.gammon.com.au/forum/?id=12635
First you need a couple of tables:
-- -----------------------------------------------------------------
-- these commands will be considered "room changing" commands
-- -----------------------------------------------------------------
local valid_direction = {
n = "n",
s = "s",
e = "e",
w = "w",
u = "u",
d = "d",
ne = "ne",
sw = "sw",
nw = "nw",
se = "se",
north = "n",
south = "s",
east = "e",
west = "w",
up = "u",
down = "d",
northeast = "ne",
northwest = "nw",
southeast = "se",
southwest = "sw",
['in'] = "in",
out = "out",
} -- end of valid_direction
-- for calculating the way back
local inverse_direction = {
n = "s",
s = "n",
e = "w",
w = "e",
u = "d",
d = "u",
ne = "sw",
sw = "ne",
nw = "se",
se = "nw",
['in'] = "out",
out = "in",
} -- end of inverse_direction
Now you detect when you send a movement command:
-- -----------------------------------------------------------------
-- try to detect when we send a movement command
-- -----------------------------------------------------------------
function OnPluginSent (sText)
last_direction_moved = valid_direction [sText]
end -- OnPluginSent
Now a table lookup tells you the inverse (way back) of the last direction you moved:
goback = inverse_direction [last_direction_moved]
|