Trouble with WindowAddHotspot

Posted by Norbert on Sun 24 Aug 2008 03:49 AM — 5 posts, 21,290 views.

USA #0
I can't seem to get my hotspots to add. I took these examples from the help and still cannot get the hotspots to add. I'm using version 4.35 on a Vista computer. WindowHotspotList is always nil.

WindowCreate ("test", 0, 0, 200, 200, 6, 0, ColourNameToRGB("slategray"))
WindowAddHotspot("test", "hs1",  
                 0, 0, 200, 200,   -- rectangle
                 "mouseover", 
                 "cancelmouseover", 
                 "mousedown",
                 "cancelmousedown", 
                 "mouseup", 
                 "Click here to be healed",  -- tooltip text
                 1, 0)  -- hand cursor
function mouseover (flags, hotspot_id)
  Note ("we moused over hotspot " .. hotspot_id)
end -- mouseover
WindowShow("test", true)
-- show all hotspots
hotspots = WindowHotspotList("test")

if hotspots then
  for _, v in ipairs (hotspots) do 
    Note (v) 
  end
end -- if any 

Australia Forum Administrator #1
It helps to wrap a function call with "check", especially if you are having problems. This only applies to functions that are documented to return eOK, and other codes. Like this:


check (WindowAddHotspot("test", "hs1",  
                 0, 0, 200, 200,   -- rectangle
                 "mouseover", 
                 "cancelmouseover", 
                 "mousedown",
                 "cancelmousedown", 
                 "mouseup", 
                 "Click here to be healed",  -- tooltip text
                 1, 0))  -- hand cursor


When I tried that I got:


Run-time error
World: smaug 2
Immediate execution
[string "Immediate"]:2: Only a plugin can do this
stack traceback:
        [C]: in function 'error'
        [string "Check function"]:1: in function 'check'
        [string "Immediate"]:2: in main chunk


Were you doing this in a plugin?

USA #2
I'm building the script in my world script file then plan to move it to a plugin once I have it all working. I'm trying to recreate a compass like Darwin's for the mud I play on. Does this mean I need to move it to a plugin now and maybe it'll work?
USA #3
That's exactly what it means. The hotspot functions will only work once inside a plugin file. I ran into the same problem.
USA #4
Thanks works great.