Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ InfoBox Lua Module

InfoBox Lua Module

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by WillFa   USA  (525 posts)  Bio
Date Wed 03 Sep 2008 06:28 AM (UTC)

Amended on Wed 03 Sep 2008 06:31 AM (UTC) by WillFa

Message
I think I'm finally happy with my miniwindow project. Instead of writing a plugin which I find is highly spcific to the author's desires and mud he plays on. I chose to write a Lua module. This module is 800+ lines of code that handles the majority of MiniWindow tasks you'd need to recreate the InfoBar or Status lines. I've reinvented the wheel! But I made it rounder.
There's some pictures of it
http://tinyurl.com/5z9yn6
and
http://tinyurl.com/5z9yn6

It has an object oriented approach to making these windows. The scripting outside of the module is minimal and should be accessible to novice scripters as well as plugin authors.


Someone with just a trigger on their hpbar/prompt could be on their way in just:

Window = InfoBox:new("MyHP")
Window:AddBar("HP", 75)
Window:Update()


3 lines of script to get a gauge working isn't bad. Right?




For a more practical example, the scripting required to make and update the 2 windows pictured is only:


require "InfoBox"

function Init ()
	TextRectangle(5,5,-5,-5, 5,0x222222,3, 0x111111,0)

	HPBox = InfoBox:new("HP")
		HPBox.Bar.textStyle = HPBox.textStyles.sunken
	HPBar 	  = HPBox:AddBar("HP", 0, "green", "firebrick", false)
		HPBar.barStyle = HPBar.barStyles.gradientFixed + HPBar.barStyles.glass
		HPBar.threshold = 52
		HPBar:WatchValue ("vars.pHP")
	HPStatus = HPBox:AddBar("",0,0,0,false,0)
	HPStatus.textStyle = 1
	KarmaBar  =	HPBox:AddBar("Karma", 0,"dodgerblue", "firebrick", false, 8+64)
		KarmaBar.threshold = 40
		KarmaBar:WatchValue("vars.pKarma")
	KStatus = HPBox:AddBar("",0,0,0,false,0)
	KStatus:TextColour ("peachpuff")
	KStatus.textStyle = 4
	KStatus.captionPlacement = 4
	SPBar 	  =	HPBox:AddBar("SP", 0, "deepskyblue", "dimgray", false, 8+128)
		SPBar:WatchValue("vars.pSP")
	VoiceBar  =	HPBox:AddBar("Voice", 0, "mediumpurple", "indigo", false, 8+32)
		VoiceBar:WatchValue("vars.cVoice")
	EnemyBar = HPBox:AddBar("", 0, 0x222222, 0x000070, true, 8+64)
		EnemyBar.threshold = 45
		EnemyBar.textStyle = 1
		EnemyBar:CaptionPlacement(1)
	HPBox:WindowPosition ( InfoBox.windowPositions.S )
	HPBox:Rows  (2)
	
	GXPBox = InfoBox:new("GXP")
		GXPBox.windowPosition = InfoBox.windowPositions.E

	GXPSt = GXPBox:AddBar("GXP to Next Level:",0,0,0,false,0)
		GXPSt.textStyle = InfoBox.textStyles.sunken

	GXPgr = GXPBox:AddBar(0, 0, "silver", "silver")
		GXPgr:CaptionPlacement(2)
		GXPgr:Caption(vars.GXPtoNextLevel)
	TSt = GXPBox:AddBar(NextPoint .. " " .. tostring(Skills[NextPoint].current +1))
	TSt:BarStyle(0)
	Tgr = GXPBox:AddBar(Skills[NextPoint].cost, 0, "slateblue","mediumblue",true, HPBox.barStyles.sunken + HPBox.barStyles.solid)
	Tgr:Threshold(97)
end



function HeartBeat (...)
	local fmt = "  HP: %i/%i  (%+4i)  "
	if vars.cHP then
		vars.hpdelta = vars.cHP - (hplastround or 0)
		HPStatus.caption = fmt:format(vars.cHP, vars.mHP, vars.hpdelta)
		HPStatus:ColourText(vars.hpdelta, 0, 0x006600,0x000066,"black")
		SPBar:Threshold(math.floor((152/vars.mSP) * 100))
		EnemyBar.value = tonumber(vars.BadGuyHealth) or 0
		if vars.SongPerformed then
			KStatus.caption = "Singing: " .. titlecase(vars.SongPerformed)
		else
			KStatus.caption = ""
		end
		if vars.inCombat == "" then
			var.Enemy = ""
		end
		if var.Enemy ~= "" then
			EnemyBar:Caption(var.Enemy)
		else
			EnemyBar:Caption("")
		end
		if HPBox:Update() then
			hplastround = vars.cHP
		end
		TSt:Caption(NextPoint .. " " .. tostring(Skills[NextPoint].current +1))
		Tgr:Caption(Skills[NextPoint].cost - vars.GXPtoSpend)
		GXPgr:Value(vars.GXPtoNextPercent)
		Tgr:Value(math.floor((vars.GXPtoSpend/Skills[NextPoint].cost)*100))
		GXPBox:Update()
	end
end

That makes both windows, all 11 "bars", and keeps them up to date.


If anyone's interested, I'll put the module up on Skydrive. (Or if Nick wouldn't mind hosting it with the other plugins?) and continue working on documenting all the functions in it.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 04 Sep 2008 10:24 PM (UTC)
Message
You are welcome to send it to me - I tried to reply privately but the system thinks your email address is wrong - perhaps update your forum profile.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #2 on Fri 05 Sep 2008 05:23 AM (UTC)
Message
Thanks Nick. After thinking about it, I think I'll wait for 4.37 so I can finish cleaning up after myself with WindowDelete.

(The email address was valid; I had "allow e-mail" turned off. I would have guessed Admins could have overridden that. It's updated now, however)
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 05 Sep 2008 07:19 AM (UTC)
Message
Admins can see it, sure, but the fact that it had the "bounced" flag on it meant I thought that the address I could see, would be wrong.

Anyway, if you do this, you will see my email address:


print (utils.base64decode ("bmlja0BnYW1tb24uY29tLmF1"))


Hopefully that is cryptic enough to slow the spammers down. ;)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,507 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.