Hey, not that there's anything wrong with the UPD way, but..
And.. not that there would have been anything wrong with the PHP FFI way, had it worked..
The wxLua way!
For example..
http://faux.sison.nl/luabar.png
(The little hp window.. isn't it cute?)
Edit: It's even cuter when you make it smaller, btw =)
Note that there's only one window here as a beta test.. the stability isn't great at the moment, and some things don't work simply because I'm using someone else's old binary of the library.
It also isn't possibly to distribute as a plugin because of:
However, the code I have to make this work:
First, pre-setup..
MUSHDIR\wxlua.lua:
This requires wxLua.dll (and it's support files) to be in the MUSH directory.
http://homepage.ntlworld.com/johanne.winwood/wxLuaBin26.242.zip
Now the actual code..
Part of the script file:
The trigger. (as you may have guessed this is for Discworld, but I hope you can guess what's going on.):
Just to make that even less confusing, the "prompt" looks something like:
As you may have noticed this code does nothing by itself, you have to call the winblow() code to get it going.
See the stability notes down there..
Other notes..
-- Faux the ....
And.. not that there would have been anything wrong with the PHP FFI way, had it worked..
The wxLua way!
For example..
http://faux.sison.nl/luabar.png
(The little hp window.. isn't it cute?)
Edit: It's even cuter when you make it smaller, btw =)
Note that there's only one window here as a beta test.. the stability isn't great at the moment, and some things don't work simply because I'm using someone else's old binary of the library.
It also isn't possibly to distribute as a plugin because of:
- The fact that it needs the wxLua.dll library file.
- The fact that it needs to be able to load the wxLua.dll file, which, by default, MUSH prevents.
However, the code I have to make this work:
First, pre-setup..
MUSHDIR\wxlua.lua:
wx = nil
if loadlib ~= nil then
Note ("loadlib ~= nil");
local luaopen, osError, errorDesc, fileName
fileName = "wxLua.dll"
luaopen, osError, errorDesc = loadlib(fileName, "wxLua")
if luaopen ~= nil then
wx = luaopen()
if wx == nil then
Note ("Error: Call to LuaOpen() in "..fileName.." failed.")
error("Call to LuaOpen() in "..fileName.." failed.")
else
Note ("wxLua version: "..wx.Version)
end
else
Note ("Error: Unable to open "..fileName..".\nWindows reports: "..osError)
error("\nUnable to open "..fileName..".\nWindows reports: "..osError)
end
end
This requires wxLua.dll (and it's support files) to be in the MUSH directory.
http://homepage.ntlworld.com/johanne.winwood/wxLuaBin26.242.zip
Now the actual code..
Part of the script file:
frame = nil
gauge = nil
function winblow()
require "wxLua.lua"
frame = wx.wxFrame( wx.wxNull,
-1,
"hp",
wx.wxPoint(-1, -1),
wx.wxSize(200, 40),
wx.wxFRAME_TOOL_WINDOW + wx.wxCAPTION + wx.wxSTAY_ON_TOP + wx.wxRESIZE_BORDER)
frame:Show(wx.TRUE)
gauge = wx.wxGauge( frame, -1, 20, wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxGA_SMOOTH)
end
The trigger. (as you may have guessed this is for Discworld, but I hope you can guess what's going on.):
<triggers>
<trigger
enabled="y"
match="^Hp: ([0-9]+)\(([0-9]+)\)"
regexp="y"
send_to="12"
sequence="95"
>
<send>frame:SetTitle("Hp! - %1/%2 - (" .. ((%1/%2)*100) .. "\%)" )
gauge:SetRange(%2)
gauge:SetValue(%1)</send>
</trigger>
</triggers>
Just to make that even less confusing, the "prompt" looks something like:
Hp: 2025(2025) Gp: 322(337) Xp: 72993As you may have noticed this code does nothing by itself, you have to call the winblow() code to get it going.
See the stability notes down there..
Other notes..
- For the loadlib code to work you need to modify the Sandbox that MUSH runs by default. This is specified in FILE\General Preferences, which took me a while to find.
My Sandbox simply looks like:
function MakeSandbox () end
Note that this is a bad idea if you don't read code before using it.
- Stability: Re-loading the script file while a wxLua dialog is on the screen either hangs or disappears MUSH. Your guess is as good as mine. [reference-to-frame]:Destroy() doesn't work as expected (doesn't work at all). Maybe it's just my system.
- MUSH seems to be using a really random verson of Lua, as I have a version that requires only 1 dll and contains the functions in both.. it also appears to be completely backwards compatabile as I have it running instead of the default at the moment.
- Building wxLua: wxLua requires you to have built wxWidgets, which I've managed using the C++ Programmers Toolkit and SDK from microsoft (not trivial), but wxLua doens't come with a compatiable makefile, so I can't rebuild.
-- Faux the ....