Clickable Miniwindow

Posted by Indico on Sat 20 Feb 2010 10:39 PM — 20 posts, 80,564 views.

#0
Is this even possible? I ask because the character I use has many different hand strikes that he can use directly after a sword strike. Ideally, I would like to create a miniwindow that lists all the different areas I can strike, and upon clicking one, it would create a variable that the game can use. However, I have an infintesimal amount of coding experience and have absolutely no idea where to begin.
Australia Forum Administrator #1
It's possible, yes. See:

http://www.gammon.com.au/mushclient/mw_hotspots.htm
#2
Ok, so far I've created an image file and tried to use the guides provided to put it in the miniwindow. The image is a 300 x 355 bmp showing a human silhouette with various lines pointing to the different points that my character can strike, and can be seen here.
http://img46.imageshack.us/img46/6660/striking.png

I then tried to draw this in a miniwindow using this script,

win = GetPluginID ()
WindowCreate(win, 0, 0, 300, 355, 7, 0, ColourNameToRGB("white"))
WindowShow (win, true)
WindowLoadImage(win, "im1", "C:/program files/mushclient/Striking.bmp")
WindowDrawImage(win, "im1", 0, 0, 0, 0, 1, 0, 0, 0, 0)

,which runs error free but produces no miniwindow.

Is there something wrong with that script? I don't want to try to move forward into the hotboxes until I know what's going on here.
USA #3
Try checking the return values from these functions. An easy way to do that is to use the "check" module, and wrap each call in check(). If an error occurs, it will display it on-screen.


require("check")

check(WindowCreate(win, 0, 0, 300, 355, 7, 0, ColourNameToRGB("white")))
check(WindowShow (win, true))
check(WindowLoadImage(win, "im1", "C:/program files/mushclient/Striking.bmp"))
check(WindowDrawImage(win, "im1", 0, 0, 0, 0, 1, 0, 0, 0, 0))
#4
Well, isn't that useful. Thank you. Well, now I know that the function doesn't seem to be able to open my image file, even though I copied and pasted it's file name.
#5
Past one problem and on to another, gotta love it. So I've gone through and created text boxes and hot spots in my miniwindow for all 17 striking points, only problem is, my script isn't sending the variables to the World when I do click a spot...so it's kind of useless right now. Here's an example of my current mouseup function, how do I get these variables into the World where I can use them?

function mouseup (flags, hotspot_id)

if hotspot_id == "hs1" then
SetVariable("strikingpoint","temple")
end
if hotspot_id == "hs2" then
SetVariable("strikingpoint","nose")
end
end
USA #6
I'm assuming this is all in a plugin? Well, you can't set a variable outside your plugin space. You can access outside with GetPluginVariable though. It'll probably be easiest for you to just use GetPluginVariable() from the world.
Australia Forum Administrator #7
Twisol said:


require("check")



Recent versions of MUSHclient have the "check" functionality automatically loaded into the Lua script space, so you can check things without needing that line.
#8
Is there something that must be done to define the variable in a plugin? Because right now, GetPluginVariable is returning nil.
USA #9
GetPluginVariable("plugin ID here", "variable name"). Make sure you've got your plugin's ID in there, after all you have to tell it what plugin to get the variable from.

Nick: Ahh, thanks, I wasn't sure so I threw it in there anyways.
#10
See I did GetPluginVariable("plugin ID here", "variable name"), and it wasn't working, so I tried print(GetPluginVariable("plugin ID here", "variable name")), just to see exactly what the return value was, and it always showed nil.
USA #11
Could you paste the code in the plugin that's setting the variable, and the code in the world that's getting it, in [code] tags?
#12
My code so far creates a window, draws my image in it, creates 17 hotspots that are all mouseup enabled and correspond to different parts of the image, and then it goes on to this.



function mouseup (flags, hotspot_id)

if hotspot_id == "hs1" then
SetVariable("strikingpoint","temple")
end
if hotspot_id =="hs2" then
SetVariable("strikingpoint","nose")
end
if hotspot_id =="hs3" then
SetVariable("strikingpoint","neck")
end


That's all I have as far as setting the varable, and I haven't written a code in the world yet, since the GetVariable thing keeps returning nill.
USA #13
Well that's not very helpful now is it, considering that the GetPluginVariable thing seems to be the source of your problems! ;) The plugin code looks like it should work.
#14
Well that seems to be my last problem, I fixed the plugin so it works perfectly now. GetPluginVariable returns every value that I click, but I can't figure out how to incorporate it into the world.

Right now I have aliases for all my sword strikes like this one.

alias = cen

centreslash @target
strike @target @strikingpoint

Strikingpoint is the crucial variable here. How do I put the value of GetPluginVariable in its place?
USA #15
Send("centreslash " .. GetPluginVariable("pluginid", "target")
Send("strike " .. GetPluginVariable("pluginid", "target" .. " " .. GetPluginVariable("pluginid", "strikingpoint")


And change "Send to" to "Script". You can also uncheck "Expand variables", since this doesn't use the @varname syntax anymore.
#16
Well, @target is internally defined in the world so it wasn't necessary to get the plugin variable for that. I'm done now! Thank you for all your help along the way.
USA #17
Gladly!
#18
I noticed you can use an hourglass and other images to transform the cursor with WindowAddHotSpot, would it be possible to add a magnifying glass image? I think alot of uses for hotspots are for things like "take a closer look at this", and a magnifying glass is an image used in many other games/applications, may be one that would have widespread use for users of MUSHclient.
Australia Forum Administrator #19
These are standard Windows cursor icons. I'm not sure how to easily add more. For your purposes you could use icon 12 (the ? icon) which would suggest "give me help on this thing".