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 ➜ Plugins ➜ Health and Experience and Bars, oh my!

Health and Experience and Bars, oh my!

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


Pages: 1  2 3  4  

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #15 on Sat 26 Feb 2011 06:12 AM (UTC)
Message
I think the movewindow sets one of the flags so you should really "or" it in. Like this:


-- make miniwindow so I can grab the font info
  WindowCreate (win, 
                windowinfo.window_left,
                windowinfo.window_top,
                WINDOW_WIDTH, 
                WINDOW_HEIGHT,  
                windowinfo.window_mode,   
                bit.bor (windowinfo.window_flags, 4),    
                BACKGROUND_COLOUR)


- Nick Gammon

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

Posted by Caelen   (81 posts)  Bio
Date Reply #16 on Sat 26 Feb 2011 06:58 AM (UTC)

Amended on Sat 26 Feb 2011 06:59 AM (UTC) by Caelen

Message
Twisol said:

Sounds like a great idea. I personally like having a separate file for configuration, but if you'd like to keep everything in one file that's fine too.


What's the trick to getting a single config file for these plugins? Considering it's three plugins total (one for health bars, one for xp bars, and one for both combined), it'd be nice if there was just one file for configuration ^^

Nick Gammon said:

I think the movewindow sets one of the flags so you should really "or" it in.


Works wonderfully, except for one snag. It draws the window how I want it, with the background completely invisible... then after about half a second it fills it with black (my chosen background color for testing).

http://www.mediafire.com/?pl3n1hfj03b9vc9

This is the plugin file. It also has some slight issues, mostly because I had to remove the line that drew over the entire window to "erase" it in order to get parts to draw independently. The text smudges a bit after a while, and if I level the level counter gets all screwy as it writes numbers over numbers.

It also has the layout for my intended config setup in it.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #17 on Sat 26 Feb 2011 10:04 PM (UTC)
Message
Caelen said:
What's the trick to getting a single config file for these plugins? Considering it's three plugins total (one for health bars, one for xp bars, and one for both combined), it'd be nice if there was just one file for configuration ^^

I'd put the plugin XML file in its own directory (e.g. "health_bar_miniwindow.plugin/plugin.xml"), and add another file next to it called config.lua. Then you can use GetPluginInfo(GetPluginID(), 20) to get the directory the plugin is in, allowing you to do something like this to load the config file:

require(GetPluginInfo(GetPluginID(), 20) .. "/config.lua")

My "structured plugin" guidelines[1] define my ideal plugin structure, based on the idea that a plugin should be within its own directory. It lets you modularize your plugin by separating scripts out into their own files, and it keeps things tidy by packaging resources (like images or audio files) with the plugin. I even built a simple "plugin stub" library called Plugger[2] that lets you keep the scripts entirely separate from the plugin XML file. If you want an example, you can find a number of my plugins at my website[3]. In particular, RoomName.plugin is a pretty good foundation to begin from.

[1] http://www.gammon.com.au/forum/?id=10011
[2] http://www.gammon.com.au/forum/?id=10081
[3] http://jonathan.com/new-gmcp-plugins-for-achaea

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Caelen   (81 posts)  Bio
Date Reply #18 on Sun 27 Feb 2011 12:41 AM (UTC)
Message
I've been going through those plugins, reading the files and such, but I'm a bit lost...

First, is semantic versioning a requirement? I don't understand it at all.

Second, what is PPI? In terms someone who knows very little about programming can understand, please. Is PPI needed, or is it only something used with GMCP/ATCP? New Worlds Ateraan uses nothing fancy like that sadly (or not that I'm aware of... they are very tight-lipped about the code).

I intend to have only one version, and one plugin file, for the final product, and I'm going to use that plugger.xml to help configure it so people can choose which setup they want with a simple number choice.

Also, still have a problem with the transparency, but everything else seems to be working just fine, including my ever increasing volume of triggers.

Can those triggers be pulled into a separate file as well? Like... plugindirectory/triggers/triggers.xml and have them be called by the main.lua file?
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #19 on Sun 27 Feb 2011 03:54 AM (UTC)
Message
Caelen said:
I've been going through those plugins, reading the files and such, but I'm a bit lost...

No worries. I use several things together in my plugins, but most of them are unrelated to each-other.

Caelen said:
First, is semantic versioning a requirement? I don't understand it at all.

No. It's just a way of versioning software so you can tell what it changes or breaks at a glance. Bugfix and minor version changes are supposed to be backwards-compatible, while bugfix chnges shouldn't add any new functionality.

I learned about it at semver.org.

Caelen said:
Second, what is PPI? In terms someone who knows very little about programming can understand, please. Is PPI needed, or is it only something used with GMCP/ATCP? New Worlds Ateraan uses nothing fancy like that sadly (or not that I'm aware of... they are very tight-lipped about the code).

PPI stands for "Plugin to Plugin Interface", and it lets plugins expose methods to other plugins. I use this in particular for my GMCP-based plugins because it lets them listen for GMCP events. You can ignore it if you don't plan on doing any complex plugin communication. It shows how easy it is to bundle a library in with a plugin though.

Caelen said:
I intend to have only one version, and one plugin file, for the final product, and I'm going to use that plugger.xml to help configure it so people can choose which setup they want with a simple number choice.

I'm not sure what you mean? Plugger is an aid for building complex plugins. You include it through the plugin XML and it automatically runs scripts/main.lua.

Caelen said:
Can those triggers be pulled into a separate file as well? Like... plugindirectory/triggers/triggers.xml and have them be called by the main.lua file?

Kind of. Yes, you can put them in a separate XML file, and use Lua's 'io' library to read the file into memory. Then you can use ImportXML() to take that file and turn the XML into actual triggers and stuff.

Alternatively, just use an <include> tag from the main plugin XML file.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Caelen   (81 posts)  Bio
Date Reply #20 on Sun 27 Feb 2011 07:00 AM (UTC)

Amended on Sun 27 Feb 2011 07:46 AM (UTC) by Caelen

Message
Twisol said:

PPI stands for "Plugin to Plugin Interface", and it lets plugins expose methods to other plugins. I use this in particular for my GMCP-based plugins because it lets them listen for GMCP events. You can ignore it if you don't plan on doing any complex plugin communication. It shows how easy it is to bundle a library in with a plugin though.


PPI won't be needed then, I don't think... the amount of complexity I can implement with Ateraan is quite limited. Zero automation is tolerated, not even something to make certain consumables when the cooldown is up.

Twisol said:

I'm not sure what you mean? Plugger is an aid for building complex plugins. You include it through the plugin XML and it automatically runs scripts/main.lua.


I was thinking Plugger lets you put things into sub directories instead of having all the files within the one folder... But, with only a few files, I should be fine if I just keep the filenames consistent, no? A single plugin.xml, a main.lua, a config.lua, and a triggers.xml? That should let me use a single setup for all of them, no?

EDIT: While I'm at it, is there any rhyme or reason to the "plugin id"?

<plugin
   name="Health_Bar_Miniwindow_Plus"
   author="Nick Gammon and Caelen Foss"
   id="48062dcd6b968c590df50f32"
   language="Lua"
   purpose="Shows stats in a mini window"
   date_written="2010-02-14 09:00"
   requires="4.40"
   version="2.0"
   save_state="y"
   >


EDIT2: I can't seem to find any documentation on the <include> tag... what are the details on how to use this?
EDIT3: Found it. http://www.gammon.com.au/forum/?id=10630
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #21 on Sun 27 Feb 2011 10:31 AM (UTC)
Message
Caelen said:

EDIT: While I'm at it, is there any rhyme or reason to the "plugin id"?


That was my idea, so let me explain ...

When I initially designed plugins I wanted to have some way of knowing plugin A from plugin B. For example, the CallPlugin function. Now initially I thought of having plugin names, but there was no real way of making sure that people all around the world wouldn't make names that clashed (eg. "mapper", or "health bars").

So then, along similar lines to the Windows GUID for COM objects, I just decided to have a randomly-generated hex string (effectively a hash of a GUID). This way each plugin author could get a different one (you can generate them with a function call or from the GUI interface of MUSHclient).

*This* string is what uniquely identifies plugins, even if you change their names (eg. correcting spelling errors). Of course, I can't stop you using someone else's plugin ID, but why would you want to? They aren't particularly exciting per se.

BTW, in recent versions, the CallPlugin function lets you pass multiple arguments (in Lua) and also get results returned. So the need for PPI (which was developed before this extra functionality) is reduced somewhat.

Both PPI and now, CallPlugin, let you have one plugin call another one, passing data (like, multiple arguments), and get one or more results back. So you might have a generic database-query plugin, for example.

- Nick Gammon

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

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #22 on Sun 27 Feb 2011 05:56 PM (UTC)
Message
Caelen said:
PPI won't be needed then, I don't think... the amount of complexity I can implement with Ateraan is quite limited. Zero automation is tolerated, not even something to make certain consumables when the cooldown is up.

Well, PPI just lets plugins talk to eachother. Whether or not you use that for automation is up to you. But no, you don't need PPI for this. :)

Caelen said:
I was thinking Plugger lets you put things into sub directories instead of having all the files within the one folder... But, with only a few files, I should be fine if I just keep the filenames consistent, no? A single plugin.xml, a main.lua, a config.lua, and a triggers.xml? That should let me use a single setup for all of them, no?

Yeah, that's pretty much what Plugger does. I like to keep the same directory structure through all my plugins, because it's just a simple plugger.path() call to get the path to one of the subdirectories.

Nick Gammon said:
BTW, in recent versions, the CallPlugin function lets you pass multiple arguments (in Lua) and also get results returned. So the need for PPI (which was developed before this extra functionality) is reduced somewhat.

Both PPI and now, CallPlugin, let you have one plugin call another one, passing data (like, multiple arguments), and get one or more results back. So you might have a generic database-query plugin, for example.

The primary difference is that PPI lets you pass and return functions and tables, so if that's something you ever want you may want to look into PPI. (It also alerts you when a plugin is installed, which really helps with dependency issues.)

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Caelen   (81 posts)  Bio
Date Reply #23 on Mon 28 Feb 2011 12:43 AM (UTC)

Amended on Mon 28 Feb 2011 01:13 AM (UTC) by Caelen

Message
Okay, some questions about how to get this mess working. I am going to use Plugger to use the subdirectory setup, because it looks pretty. I have subdirectories set up, and main files in the folders.

Current Setup, for each plugin:
plugins
  plugin name
    plugin.xml
    config.lua
    readme.txt
    libraries
      plugger.xml
    scripts
      main.lua
    triggers
      triggers.xml


On to the questions!

1) Using the original plugin I started with, the triggers were before the scripts. Does this order matter, or can I put the <include/> part later on in the plugin.xml file?

</plugin>

<!--  Triggers  -->

<include name="$PLUGINDIR\triggers.xml" />

<!--  Script  -->

<script>


2) How can I use the readme.txt file as the long description? I want to be able to just edit the readme and have that be the description.

<description trim="y">
<![CDATA[
long description

]]>
</description>


3) Assuming the "Name" has been entered into Game > Configure > Connecting, is there a way to call this to create a trigger that catches the matching name? For instance, when you report your health status for everyone to see, you get "Name reports (stats)", where Name is your character name (or someone else). It does not say "You report". I want to catch this Name variable as the trigger text.

4) Is there a way to call the world's font (or the global font if the world font is being overridden), rather than having it left to the config file?
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #24 on Mon 28 Feb 2011 02:45 AM (UTC)
Message
Caelen said:

1) Using the original plugin I started with, the triggers were before the scripts. Does this order matter, or can I put the <include/> part later on in the plugin.xml file?

</plugin>

<!--  Triggers  -->

<include name="$PLUGINDIR\triggers.xml" />

<!--  Script  -->

<script>

Mmmmmm.... this is a good question. I think it shouldn't matter, from what I remember of the source.

Caelen said:
2) How can I use the readme.txt file as the long description? I want to be able to just edit the readme and have that be the description.

<description trim="y">
<![CDATA[
long description

]]>
</description>

That's a good question! I don't know of any way to make the <description> tag scripted, but if you're using an alias to display the description (like that the Plugin Builder adds), you can just change it to read in the readme.txt file and display that.

Caelen said:
3) Assuming the "Name" has been entered into Game > Configure > Connecting, is there a way to call this to create a trigger that catches the matching name? For instance, when you report your health status for everyone to see, you get "Name reports (stats)", where Name is your character name (or someone else). It does not say "You report". I want to catch this Name variable as the trigger text.

You can use GetInfo(3) to get the value in the character name field, and either create a trigger using AddTriggerEx() or update an existing one with SetTriggerOption().

Caelen said:
4) Is there a way to call the world's font (or the global font if the world font is being overridden), rather than having it left to the config file?

GetInfo(20) contains the name of the font being used, I believe.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Caelen   (81 posts)  Bio
Date Reply #25 on Mon 28 Feb 2011 03:20 AM (UTC)

Amended on Mon 28 Feb 2011 03:23 AM (UTC) by Caelen

Message
Twisol said:

You can use GetInfo(3) to get the value in the character name field, and either create a trigger using AddTriggerEx() or update an existing one with SetTriggerOption().


in triggers/triggers.xml
  <trigger
   enabled="y"
   match="^.* Reports\: HP\:(\d+)\%  SP\:(\d+)\%  EP\:(\d+)\%$"
   name="hpall"
   regexp="y"
   script="do_prompt_currentpercentname"
   sequence="100"
  >
  </trigger>
in config.lua
CHARACTER_NAME = GetInfo(3)
if CHARACTER_NAME then
  SetTriggerOption("hpall", "match", "^" .. GetInfo(3) .. " Reports\: HP\:(\d+)\%  SP\:(\d+)\%  EP\:(\d+)\%$")
end
Would this work?



Twisol said:

GetInfo(20) contains the name of the font being used, I believe.


Any way to get the font size as well? I searched through the GetInfo documentation, but couldn't find anything for it :(
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #26 on Mon 28 Feb 2011 04:00 AM (UTC)

Amended on Mon 28 Feb 2011 04:01 AM (UTC) by Twisol

Message
Caelen said:
Would this work?

I do believe so! Though for efficiency, you might want to use ".*?" instead of ".*".

And for safety, you might want to check if the returned name is empty (like "") and just leave it as .*? if that's the case.

Caelen said:
Any way to get the font size as well? I searched through the GetInfo documentation, but couldn't find anything for it :(

Hmm. Try printing the GetOptionList() return table, it might have both the font and the font size somewhere in there. The options aren't documented anywhere unfortunately.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Caelen   (81 posts)  Bio
Date Reply #27 on Mon 28 Feb 2011 04:47 AM (UTC)

Amended on Mon 28 Feb 2011 05:01 AM (UTC) by Caelen

Message
These triggers don't seem to be working at all. First is the triggers from the file, second is the script for the triggers, third is what it's supposed to match.
  <trigger
   enabled="y"
   match="^HP\:(\d+)\%  SP\:(\d+)\%  EP\:(\d+)\%$"
   regexp="y"
   script="do_prompt_currentpercent"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="y"
   match="^.*? Reports\: HP\:(\d+)\%  SP\:(\d+)\%  EP\:(\d+)\%$"
   name="hpall"
   regexp="y"
   script="do_prompt_currentpercent"
   sequence="100"
  >
  </trigger>
function do_prompt_currentpercent (name, line, wildcards)

  hpp = tonumber (wildcards [1])
  spp = tonumber (wildcards [2])
  epp = tonumber (wildcards [3])
  hp = (max_hp * hpp) / 100
  sp = (max_sp * spp) / 100
  ep = (max_ep * spp) / 100

  draw_the_bars ()
      
end -- do_prompt_currentpercent
HP:100%  SP:100%  EP:79%
Verren Reports: HP:100%  SP:100%  EP:79%


The first one always returns 100%, and the second one doesn't trigger at all.

EDIT: Oh, and I still can't get transparency to work... XD
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #28 on Mon 28 Feb 2011 05:33 AM (UTC)
Message
Caelen said:

Any way to get the font size as well? I searched through the GetInfo documentation, but couldn't find anything for it :(


A lot of this stuff is given by GetOption, so GetInfo doesn't necessarily have all of it. GetInfo is more for stuff computed at run time (like, how big the window is right now) but GetOption gives the values of the various options.

Try doing this in the Immediate window (from the help for GetOptionList):


for k, v in pairs (GetOptionList()) do 
  Note (v, " = ", GetOption (v)) 
end


Scrolling through that you'll see stuff about output_font_xxxx.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #29 on Mon 28 Feb 2011 05:40 AM (UTC)
Message
Caelen said:


The first one always returns 100%, and the second one doesn't trigger at all.



On your triggers and test data they both fired for me. Using the "summary" feature I got this:


------ Trigger: *trigger1122 ------

  <trigger
   enabled="y"
   match="^HP\:(\d+)\%  SP\:(\d+)\%  EP\:(\d+)\%$"
   regexp="y"
   script="do_prompt_currentpercent"
   sequence="100"
  >
  </trigger>

         Matched count: 5
            Has script: No
   Times script called: 0
     When last matched: 16:36:30
               Send to: world
             Temporary: No
         Time to match: 0.000314
        Match attempts: 15


------ Trigger: hpall ------

  <trigger
   enabled="y"
   match="^.*? Reports\: HP\:(\d+)\%  SP\:(\d+)\%  EP\:(\d+)\%$"
   name="hpall"
   regexp="y"
   script="do_prompt_currentpercent"
   sequence="100"
  >
  </trigger>

         Matched count: 5
            Has script: No
   Times script called: 0
     When last matched: 16:36:30
               Send to: world
             Temporary: No
         Time to match: 0.000052
        Match attempts: 20



I tested 5 times, and both fired 5 times. (I got an error on draw_the_bars () but that wasn't germane to whether the trigger fired or not).

Caelen said:

EDIT: Oh, and I still can't get transparency to work... XD


Well you will have to post more details than that. Like, code that you think should work.

- 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.


128,281 views.

This is page 2, subject is 4 pages long:  [Previous page]  1  2 3  4  [Next page]

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.