I've found a plugin made by Nick for HP, MV and MANA. This creates a small window that can be moved with a graphic representation of the status'.
What I'm try to do is use parts of that for another plugin, to show whether or not my character is "Cloaked".
I'm new to Lua and from what I can tell with the error I'm getting, the issue lies within my function cloak_status, line 116 onwards.
The TLDR is that I'm after a moveable window that has the text in it showing Cloak: ON or Cloak: OFF.
Cloak: ON is fired off the following triggers:
1. ^You blend into the surroundings and hide yourself\.$
2. ^You are already cloaked\.$
Cloak: OFF is fired off when:
1. ^You step out of the shadows\.$
Here's the code so far, thank for all your help in advance.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, September 27, 2020, 3:04 AM -->
<!-- MuClient version 5.06 -->
<!-- Plugin "Cloak_Status" generated by Plugin Wizard -->
<muclient>
<plugin
name="Cloak_Status"
author="Eios"
id="015ba97d6b9bc32363bb04b3"
language="Lua"
purpose="Shows wether you're cloaked or not"
date_written="2020-09-27 03:02:50"
requires="5.06"
version="1.0"
>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="^You blend into the surroundings and hide yourself\.$"
regexp="y"
name="cloak"
script="cloak_status"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You are already cloaked\.$"
regexp="y"
name="cloaked"
script="cloak_status"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^You step out of the shadows\.$"
regexp="y"
name="uncloaked"
script="cloak_status"
sequence="100"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
WINDOW_WIDTH = 200
WINDOW_HEIGHT = 65
BACKGROUND_COLOUR = ColourNameToRGB "rosybrown"
FONT_COLOUR = ColourNameToRGB "black"
BORDER_COLOUR = ColourNameToRGB "#553333"
function mousedown(flags, hotspot_id)
-- find where mouse is so we can adjust window relative to mouse
startx, starty = WindowInfo (win, 14), WindowInfo (win, 15)
-- find where window is in case we drag it offscreen
origx, origy = WindowInfo (win, 10), WindowInfo (win, 11)
end -- mousedown
function dragmove(flags, hotspot_id)
-- find where it is now
local posx, posy = WindowInfo (win, 17),
WindowInfo (win, 18)
-- move the window to the new location
WindowPosition(win, posx - startx, posy - starty, 0, 2);
-- change the mouse cursor shape appropriately
if posx < 0 or posx > GetInfo (281) or
posy < 0 or posy > GetInfo (280) then
check (SetCursor ( 11)) -- X cursor
else
check (SetCursor ( 1)) -- hand cursor
end -- if
end -- dragmove
function dragrelease(flags, hotspot_id)
local newx, newy = WindowInfo (win, 17), WindowInfo (win, 18)
-- don't let them drag it out of view
if newx < 0 or newx > GetInfo (281) or
newy < 0 or newy > GetInfo (280) then
-- put it back
WindowPosition(win, origx, origy, 0, 2);
end -- if out of bounds
end -- dragrelease
function cloak_status (name, line, wildcards)
local status, on1 = ("ON")
local cloaked, on2 = ("ON")
local uncloaked, off = ("OFF")
end -- function
function ShowStatus
cloak_status ("Cloak: ", on1, ColourNameToRGB "black")
cloak_status ("Cloak: ", on2, ColourNameToRGB "black")
cloak_status ("Cloak: ", off, ColourNameToRGB "black")
WindowShow (win, true)
end -- shows the status
function OnPluginInstall ()
win = GetPluginID ()
font_id = "fn"
font_name = "Courier New" -- the actual font
local x, y, mode, flags =
tonumber (GetVariable ("windowx")) or 0,
tonumber (GetVariable ("windowy")) or 0,
tonumber (GetVariable ("windowmode")) or 8, -- bottom right
tonumber (GetVariable ("windowflags")) or 0
-- make miniwindow so I can grab the font info
check (WindowCreate (win,
x, y, WINDOW_WIDTH, WINDOW_HEIGHT,
mode,
flags,
BACKGROUND_COLOUR) )
-- make a hotspot
WindowAddHotspot(win, "hs1",
0, 0, 0, 0, -- whole window
"", -- MouseOver
"", -- CancelMouseOver
"mousedown",
"", -- CancelMouseDown
"", -- MouseUp
"Drag to move", -- tooltip text
1, 0) -- hand cursor
WindowDragHandler(win, "hs1", "dragmove", "dragrelease", 0)
check (WindowFont (win, font_id, font_name, 9, false, false, false, false, 0, 0)) -- normal
font_height = WindowFontInfo (win, font_id, 1) -- height
if GetVariable ("enabled") == "false" then
ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
check (EnablePlugin(GetPluginID (), false))
return
end -- they didn't enable us last time
end -- OnPluginInstall
function OnPluginDisable ()
WindowShow (win, false)
end -- OnPluginDisable
function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
SetVariable ("windowx", tostring (WindowInfo (win, 10)))
SetVariable ("windowy", tostring (WindowInfo (win, 11)))
SetVariable ("windowmode", tostring (WindowInfo (win, 7)))
SetVariable ("windowflags", tostring (WindowInfo (win, 8)))
end -- OnPluginSaveState
]]>
</script>
</muclient>
|