EchoLink assistance

Post Reply
User avatar
Omni
Posts: 131
Joined: Fri Feb 12, 2010 10:26 am

EchoLink assistance

Post by Omni »

I have some code that deletes the ingame exit line and replaces it with one that I can more easily read as things are happening. The base code works, but what I want to do now is have it that when I hover over each exit, it will show me the room name and the area of the room. It is overall imperfect right now, but does what I need it to for now. For the hover text, I've been attempting to use echoLink, but have run into multiple issues. I have the new exit look as such:
Exits: ne(1970) in(6834) se(1971) d(1964) sw(1972) nw(1973) n(1969)
with a lot of fiddling with echoLink, the best I get is this, with the hover part working as intended:
Exits: <DarkTurquoise>ne<SpringGreen>(<red>1970<SpringGreen>)
with it then erroring after any following exits.

Base code that works:
Code: [show] | [select all] lua
deleteLine()
local exits = gmcp.Room.Info.exits
local exit = ""
for e,n in pairs(exits) do
	exit = exit ..  string.format("<DarkTurquoise>%s<SpringGreen>(<red>%d<SpringGreen>) ", e, n)
end

cecho(string.format("\n<CadetBlue>Exits: %s", exit))
current form of testing code that doesn't work:
Code: [show] | [select all] lua
function showExits()
local exits = gmcp.Room.Info.exits
local exit = ""
cecho(string.format("\n<CadetBlue>Exits: "))

for e,n in pairs(exits) do
	echoLink(cecho(string.format("<DarkTurquoise>%s<SpringGreen>(<red>%d<SpringGreen>) ", e, n), [[send(]].. e .. [[)]], string.format("%s - %s", getRoomName(n), mmp.areatabler[getRoomArea(n)]), false))
end


end
Various errors I've gotten:
[ERROR:] object:<run lua code> function:<Alias6>
<mudlet-lua/lua/GUIUtils.lua:812: bad argument #1 to 'split' (string, table or userdata
expected, got nil)>
[ERROR:] object:<run lua code> function:<Alias6>
<mudlet-lua/lua/GUIUtils.lua:812: bad argument #1 to 'split' (string, table or userdata
expected, got nil)>
[ERROR:] object:<run lua code> function:<Alias6>
<echoLink: wrong argument type>
[ERROR:] object:<run lua code> function:<Alias6>
<echoLink: wrong argument type>

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: EchoLink assistance

Post by Belgarath »

The echoLink is interpreting the send(e) as a variable instead of as a string, I believe. Adding quotes should fix that error. Also, the first argument is supposed to be text, not a cecho or any other function:
Code: [show] | [select all] lua
function showExits()
  local sf = string.format
  local exits = gmcp.Room.Info.exits
  cecho("\n<CadetBlue>Exits: ")
  for e,n in pairs(exits) do
    local text = sf("%s(%d) ", e, n) -- uses echo, not cecho, so can't use <colour> tags
    local cmd = [[send("]] .. e .. [[")]]
    local hint = sf("%s - %s", getRoomName(n), mmp.areatabler[getRoomArea(n)])
    echoLink(text, cmd, hint, false)
  end
end
If you want to colour the output, you'd have to use fg() or setFgColor(). If you're using Mudlet 3.0, I believe there is a new function cechoLink() that will let you add color_table additions. Hope this helps :)

User avatar
Omni
Posts: 131
Joined: Fri Feb 12, 2010 10:26 am

Re: EchoLink assistance

Post by Omni »

That did it, thank you. Now just need to fix colors and refine it for rooms not in the mapper. Thanks a bunch.

Post Reply