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 ➜ Miniwindows ➜ Adapting AARDWOLF inventory miniwindow

Adapting AARDWOLF inventory miniwindow

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


Pages: 1 2  

Posted by Death   (55 posts)  Bio
Date Wed 17 Jan 2018 04:08 PM (UTC)

Amended on Sun 05 Jan 2020 06:03 AM (UTC) by Death

Message
Hey all,

I've been admiring the AARDWOLF inventory miniwindow (amongst others) and I've been trying to convert it to a non gmcp mud.

Here's what I've got

https://ibb.co/cOymWm

Run-time error
Plugin: Aardwolf_Health_Bars (called from world: Dark Wizardry
Function/Sub: do_prompt called by trigger
Reason: processing trigger "" when matching line: "<1818/1818 hp 9084/9084 m 2566/2566 mv>"
[string "Plugin: Aardwolf_Health_Bars"]:559: bad argument #7 to 'WindowRectOp' (number expected, got nil)
stack traceback:
[C]: in function 'WindowRectOp'
[string "Plugin: Aardwolf_Health_Bars"]:559: in function <[string "Plugin: Aardwolf_Health_Bars"]:552>




I'm not a legendary programmer or anything, and I know not everyone has time to help convert this, but I think figuring out how to fix this would help me understand how to code things in the future. If anyone can help, I'd be SO grateful.
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #1 on Wed 17 Jan 2018 05:21 PM (UTC)

Amended on Wed 17 Jan 2018 05:26 PM (UTC) by Fiendish

Message
Aardwolf_Health_Bars has nothing to do with inventory.

Anyway, capitalization matters. You can't use a variable called BACKGROUND_COLOUR if you only have background_colour defined.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 17 Jan 2018 10:24 PM (UTC)
Message
I did a tutorial about doing an inventory in a minwindow.

Template:post=9965 Please see the forum thread: http://gammon.com.au/forum/?id=9965.

- Nick Gammon

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

Posted by Death   (55 posts)  Bio
Date Reply #3 on Thu 18 Jan 2018 05:57 AM (UTC)

Amended on Thu 18 Jan 2018 06:03 AM (UTC) by Death

Message
Sorry, I must've copied the wrong code when I was posting (VERY LATE AT NIGHT)

Nick, I've already got your inventory window, and it's awesome, but I'm really looking for something closer to the AARDWOLF one, in regard to theme (resize-able, the coloring/headers, the whole thing being far more intricate and useful with tabs and the right click-ability)

This is what I have so far, Nick (already using your inventory window)

https://ibb.co/cOymWm


Basically I've been trying to adapt the AARDWOLF miniwindow themes to NON-GMCP coding. (in my case I would have to find the strings that match circlemud and match them myself of course)


Pretty sure what I was thinking is that if I could figure out how to rework the health bars to non-gmcp I could figure out how to do the same with the inventory (basically just using the theme, but not the gmcp variables)

The aardwolf health bars miniwindow is SO nice, and it would be awesome to be able to utilize the customization of it on another mud.

I originally thought I could copy the theme parts of the code, but it doesn't seem that easy, as I'm sure there are still parts of the code in there that don't belong. Any recommendations?
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #4 on Thu 18 Jan 2018 06:09 AM (UTC)

Amended on Thu 18 Jan 2018 06:11 AM (UTC) by Fiendish

Message
Quote:
The aardwolf health bars miniwindow is SO nice

I'm glad you like it. Nice plugins take a lot of work.

My answer still stands for correcting the error you posted.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 18 Jan 2018 06:18 AM (UTC)
Message
Well, the post I made (above) was really quite minimal. There is a module that lets you drag windows around.

http://www.gammon.com.au/forum/?id=9594

Quote:

if I could figure out how to rework the health bars to non-gmcp I could figure out how to do the same with the inventory (basically just using the theme, but not the gmcp variables)


The GMCP stuff is basically input data. You can get it from other places, like triggers. If you can find a trigger that can "seed" your inventory then your work is largely done. As for the aesthetics you just add extra code to make things happen. It's actually quite fun to sit there and make things like a RH-click do something useful.

- Nick Gammon

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

Posted by Death   (55 posts)  Bio
Date Reply #6 on Thu 18 Jan 2018 11:49 PM (UTC)

Amended on Thu 18 Jan 2018 11:52 PM (UTC) by Death

Message
Okay friends, so I should really change the subject name, but this ends up getting me to where I need to be.
I'm working on modifying the health bars to non-gmcp, which will in turn help me understand how to do the inventory as well.

My problem before was that the stats were never grabbing, so it always said "stats will show here", or whatever the prompt says. Now that I've fixed a few lines around the problem area (thanks fiendish)

It seems to want to be grabbing some stats, or have some weird drawing happening, because the health bars miniwindow is going ALL BLACK.

Here is the updated code.
http://textuploader.com/dmmnh

I've used the "do_prompt" script sequence from Nick's health miniwindows, and initially that was causing a problem, but now there are 0 things tripping the plugin (no failures), but I'm sure there's a drawing problem, and somehow still a stat grabbing problem.


If you could just steer me in the right direction, I'm happy to do the foot work. Thank you.


EDIT: (Is it something in here? Maybe "fill entire box"?
function do_prompt (name, line, wildcards)

hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
move, max_move = tonumber (wildcards [5]), tonumber (wildcards [6])

-- fill entire box to clear it
check (WindowRectOp (win, 2, 0, 0, 0, 0, background_colour)) -- fill entire box

-- Edge around box rectangle
check (WindowCircleOp (win, 3, 0, 0, 0, 0, border_color, 0, 2, 0, 1))

vertical = 6 -- pixel to start at
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #7 on Fri 19 Jan 2018 02:02 AM (UTC)
Message
Can you post the entire function? And use code tags please?

Template:codetag To make your code more readable please use [code] tags as described here.

- Nick Gammon

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

Posted by Death   (55 posts)  Bio
Date Reply #8 on Fri 19 Jan 2018 02:13 AM (UTC)

Amended on Fri 19 Jan 2018 02:14 AM (UTC) by Death

Message
Here is the do_prompt code you've designed for your original health bars mod, Nick, which is featured here..

[link]http://www.gammon.com.au/forum/bbshowpost.php?id=9270&page=1[/link]


function do_prompt (name, line, wildcards)

  hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
  mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
  move, max_move = tonumber (wildcards [5]), tonumber (wildcards [6])

  -- fill entire box to clear it
  check (WindowRectOp (win, 2, 0, 0, 0, 0, background_colour))  -- fill entire box
  
  -- Edge around box rectangle
  check (WindowCircleOp (win, 3, 0, 0, 0, 0, border_color, 0, 2, 0, 1))

  vertical = 6  -- pixel to start at


  WindowShow (win, true)
  
end -- function do_prompt




There aren't any error codes popping off in the current code (see my last comment on this thread, the URL), but my miniwindow is going all black when it gets the prompt, instead of showing the bars.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #9 on Fri 19 Jan 2018 02:49 AM (UTC)
Message
You aren't drawing any bars, that's why you don't see any. The code you linked called a function to draw the bars:


  DoGauge ("HP: ",   hp_percent,    ColourNameToRGB "darkgreen")
  DoGauge ("Mana: ", mana_percent,  ColourNameToRGB "mediumblue")
  DoGauge ("Move: ", move_percent,  ColourNameToRGB "gold")

- Nick Gammon

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

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #10 on Fri 19 Jan 2018 03:22 AM (UTC)

Amended on Fri 19 Jan 2018 03:23 AM (UTC) by Fiendish

Message
Yeah. So, you're clearing the box just fine. That is, every time your prompt comes through, you're setting the whole thing to be solid black. That's good so far, but at that point my code actually draws bars, and yours does...nothing. If your goal is to use my code with your prompt instead of GMCP, you need to be doing after your prompt comes in what I do after the GMCP data comes in.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Death   (55 posts)  Bio
Date Reply #11 on Fri 19 Jan 2018 04:49 AM (UTC)

Amended on Sun 05 Jan 2020 06:04 AM (UTC) by Death

Message
My code started to get really weird, so I've started over from scratch..

LINK TO CURRENT CODE BELOW
http://textuploader.com/dmhdj

My current issues is this

Run-time error
Plugin: Aardwolf_Health_Bars (called from world: Dark Wizardry
Function/Sub: DoNextSimpleBar called by trigger
Reason: processing trigger "" when matching line: "<1818/1818 hp 9084/9084 m 2566/2566 mv>"
[string "Plugin: Aardwolf_Health_Bars"]:81: attempt to index local 'wildcards' (a nil value)
stack traceback:
[string "Plugin: Aardwolf_Health_Bars"]:81: in function <[string "Plugin: Aardwolf_Health_Bars"]:79>


and of course, every time the prompt hits, I get this "Trigger function "DoNextSimpleBar" not found or had a previous error."


I've set the wildcard values and triggering system in the following way.

<triggers>
  <trigger
   enabled="y"
   match="^\&lt;(\d+)\s*\/(\d+)\s*hp (\d+)\s*\/(\d+)\s*m (\d+)\s*\/(\d+)\s*mv>"
   regexp="y"
   script="DoNextSimpleBar"
   sequence="100"
  >
  </trigger>
</triggers>


I've taken the triggering mechanism from Nick's miniwindows, and I've used it here. Instead of using the script "do_prompt", I've asked it to do the script "DoNextSimpleBar", which is what I thought fiendish said, basically (use his drawing script, which is what I wanted anyway)

I've not removed all of the GMCP values yet, but I'm trying to get a working model with HP/MANA/MOVE, and go from there.
The code started with this,

      DoNextSimpleBar("Health", gmcp_char.vitals.hp, gmcp_char.maxstats.maxhp)
      DoNextSimpleBar("Mana", gmcp_char.vitals.mana, gmcp_char.maxstats.maxmana)
      DoNextSimpleBar("Moves", gmcp_char.vitals.moves, gmcp_char.maxstats.maxmoves)


and went to this...

      DoNextSimpleBar("Health",    hp ,   max_hp)
      DoNextSimpleBar("Mana",  mana,  max_mana)
      DoNextSimpleBar("Moves",  move,  max_move)



Another part I've changed is here...


function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label)
   txt = ""
   if (showBar[bar][2] == true) then
      local num_val = tonumber(val)
      local num_maxval = tonumber(maxval)
      if showLabels == 1 then
         if stacked == 1 then
            WindowText(win, font_id, stacked_label or showBar[bar][1], xpos,  ypos, 0, 0, showBar[bar][4], false)
         else
            xpos = xpos + WindowText(win, font_id, unstacked_label or showBar[bar][3], xpos,  ypos, 0, 0, showBar[bar][4], false)
         end
      end


I've added this line RIGHT after
function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label)


hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
  mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
  move, max_move = tonumber (wildcards [5]), tonumber (wildcards [6])

and I also added "wildcards" to the end of

function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label)


I ended up with
function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label, wildcards)
  
hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
  mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
  move, max_move = tonumber (wildcards [5]), tonumber (wildcards [6])
   
txt = ""
   if (showBar[bar][2] == true) then
      local num_val = tonumber(val)
      local num_maxval = tonumber(maxval)
      if showLabels == 1 then
         if stacked == 1 then
            WindowText(win, font_id, stacked_label or showBar[bar][1], xpos,  ypos, 0, 0, showBar[bar][4], false)
         else
            xpos = xpos + WindowText(win, font_id, unstacked_label or showBar[bar][3], xpos,  ypos, 0, 0, showBar[bar][4], false)
         end
      end

      if num_maxval and num_val then
         if flip then
            val = tostring(num_maxval-num_val)
            num_val = tonumber(val)
         end
         if overlay_numbers == 1 or overlay_numbers == 3 or (graphicalMode == 0 and overlay_numbers ~= 2) then
            maxlen = math.max(#maxval, #val)
            txt = string.lpad(val, maxlen, ' ').."/"..string.rpad(maxval,maxlen,' ')
         end
         if overlay_numbers == 2 or overlay_numbers == 3 then
            txt = txt..((overlay_numbers == 3 and " (") or "")..string.lpad(string.format('%u',100*num_val/num_maxval).."%",4,' ')..((overlay_numbers == 3 and ")") or "")
         end
      end

without changing anything else. (I know that's not the end of the function, but I've not changed anything else)

Maybe that's not the correct order, maybe I don't understand that part, or maybe I've put the wildcards part in the wrong part of the script?

I appreciate working with me on this...
Top

Posted by Fiendish   USA  (2,558 posts)  Bio   Global Moderator
Date Reply #12 on Fri 19 Jan 2018 05:20 AM (UTC)

Amended on Fri 19 Jan 2018 05:59 AM (UTC) by Fiendish

Message
Quote:
function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label, wildcards)

You don't get to just make up whatever parameters you want going into the function that is called from your trigger.


Per https://www.gammon.com.au/script/doc.php?general=triggers

Quote:

The script subroutine must have three arguments (four for Lua), as follows:

Name of the trigger
The matching line
An array of the first 10 wildcards (Lua - all wildcards)
Lua only - a table of all the styles in the line


If you were thinking that you could just slap something called wildcards on the end of that function's arguments list and then have it called directly from the trigger, then you might need to start with a beginner's course in basic programming fundamentals and/or some of Nick's excellent MUSHclient scripting tutorial videos. This indicates a pretty serious misunderstanding of how functions work.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #13 on Fri 19 Jan 2018 07:27 AM (UTC)
Message

      DoNextSimpleBar("Health",    hp ,   max_hp)


...


function DoNextSimpleBar(bar, val, maxval, flip, stacked_label, unstacked_label)


When you call a function that you invent (DoNextSimpleBar) then you are supposed to supply the arguments that it expects.

So you are expecting:


bar, val, maxval, flip, stacked_label, unstacked_label



And you are sending:


"Health",    hp ,   max_h


They three things you are sending don't seem to match the six things the function wants.

Plus, as Fiendish points out, you are using wildcards which aren't in the function arguments.

- Nick Gammon

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

Posted by Death   (55 posts)  Bio
Date Reply #14 on Fri 19 Jan 2018 10:03 AM (UTC)
Message
Sorry guys, I guess I'm picking apart the wrong parts of the code then....



I tried to emulate this from Nick's health bars
 DoGauge ("HP: ",    hp ,   max_hp,    ColourNameToRGB "darkgreen")
  DoGauge ("Mana: ",  mana,  max_mana,  ColourNameToRGB "mediumblue")
  DoGauge ("Move: ",  move,  max_move,  ColourNameToRGB "gold")
, and replace it with DoNextSimpleBar

I obviously have no idea what I'm doing, so I'll have to do more research.

I've tried to define the wildcards via the prompt via do_prompt, like
  hp, max_hp = tonumber (wildcards [1]), tonumber (wildcards [2])
  mana, max_mana = tonumber (wildcards [3]), tonumber (wildcards [4])
  move, max_move = tonumber (wildcards [5]), tonumber (wildcards [6])
in nick's health bar plugin.

I obviously have no idea how to link the defining of the wildcards to the calling of that information, and more importantly calling that information after I've drawn the windows. I'll do more research. If anything, thank you guys so much for even responding to my horrible attempts to adapt this awesome plugin.

Also, the entire plugin is original to fiendish except the lines I've spoken of. I'm basically just trying to change the information that's called, and change how it's called (prompt, instead of gmcp). I guess it's a lot harder than I initially thought, since I don't understand the code enough. I'll research LUA more.
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.


72,400 views.

This is page 1, subject is 2 pages long: 1 2  [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.