[ SOLVED ] Quick Geyser and GMCP question

Iktomi
Posts: 46
Joined: Sat Sep 03, 2011 4:00 am

[ SOLVED ] Quick Geyser and GMCP question

Post by Iktomi »

So I have two questions. I've just started delving into the worlds for gmcp and geyser and I definitely feel out of my depth.

First, how do I a gmcp value to show up and update in a geyser label?

Right now I have a script, and the event "gmcp.Char.Status" is an event handler for it. The script is:

Code: Select all

function charStatus()	

  mylevel = gmcp.Char.Status.level
  mygold = gmcp.Char.Status.gold
  myname = gmcp.Char.Status.fullname	
  mymessages = gmcp.Char.Status.unread_msgs
  mynews = gmcp.Char.Status.unread_news

end
In my geyser label I have:

Code: Select all

namelabel:echo(myname.."<br>Level: "..mylevel.."<br>Gold: "..mygold.."<br>Messages: "..mymessages)
If I save the script, then the values update. However, when I check SCORE (in Achaea) which sends the event "gmcp.Char.Status" it doesn't update.


Second question, how do I change the font size on the label? I've currently got:

Code: Select all

namelabel:setStyleSheet([[
  qproperty-alignment: 'AlignLeft | AlignTop';
  font-family: Calibri;
  font-size: 30px;
  font-style: bold;
  border: 2px solid firebrick;
but no matter what value I put in font-size, and whether it's in px or pt, it doesn't change.


Thank you in advance!
Last edited by Iktomi on Tue Aug 12, 2014 1:35 am, edited 1 time in total.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Quick Geyser and GMCP question

Post by icesteruk »

Iktomi wrote:

Code: Select all

namelabel:echo(myname.."<br>Level: "..mylevel.."<br>Gold: "..mygold.."<br>Messages: "..mymessages)
I would put the above into something like

function MyStatLabel()

namelabel:echo etc

end

then make a trigger for 'return isPrompt()' - lua ..

and place MyStatLabel so on each prompt it'll auto update ^

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Quick Geyser and GMCP question

Post by Oneymus »

You need to call that echo function every time you want to update those values. The reason the values update when you save the script is because the script is executed, calling the function.

While you could call echo every prompt, depending on the order of operations (say, the prompt comes in before the GMCP event), you may have stale data. Your best is to put that echo right in the same event handler you have updating your variables; put it at the end: that way, you can guaranteed that it will be echoing the latest values.

fetaera
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm

Re: Quick Geyser and GMCP question

Post by fetaera »

Yeah, I'd not use an isPrompt() call for other reasons aside of those stated, though to quickly respond to setting the font size, just pass setFontSize() to your label. You also do have the option to pass HTML directly to one.

User avatar
Akaya
Posts: 412
Joined: Thu Apr 19, 2012 1:36 am

Re: Quick Geyser and GMCP question

Post by Akaya »

Yeah... I use html tags in my echo for font formatting.

Iktomi
Posts: 46
Joined: Sat Sep 03, 2011 4:00 am

Re: Quick Geyser and GMCP question

Post by Iktomi »

I'm not sure what you mean by how I can call the function... I'd rather not go the prompt route, but where can I put the function call then? Something like this isn't working:

Code: Select all

function charStatus()	

  mylevel = gmcp.Char.Status.level
  mygold = gmcp.Char.Status.gold
  myname = gmcp.Char.Status.fullname	
  mymessages = gmcp.Char.Status.unread_msgs
  mynews = gmcp.Char.Status.unread_news


end

charStatus()
Also.. and again, forgive my ignorance, but where would the font size tag go in the echo?

fetaera
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm

Re: Quick Geyser and GMCP question

Post by fetaera »

Just add gmcp.Char.Status as the registered event handler and so long as the script name is the same as your function, the function will be called whenever Mudlet receives a char status string. As for the font size, you can literally just pass it as raw HTML:
Code: [show] | [select all] lua
local out = [[<font size="12">I am some ugly text, but I am a different size now!</font>]]
my_label:echo(out)

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Quick Geyser and GMCP question

Post by Oneymus »

Code: [show] | [select all] lua
function charStatus ()
    mylevel = gmcp.Char.Status.level
    mygold = gmcp.Char.Status.gold
    myname = gmcp.Char.Status.fullname   
    mymessages = gmcp.Char.Status.unread_msgs
    mynews = gmcp.Char.Status.unread_news

    namelabel:echo(myname.."<br>Level: "..mylevel.."<br>Gold: "..mygold.."<br>Messages: "..mymessages)
end

Iktomi
Posts: 46
Joined: Sat Sep 03, 2011 4:00 am

Re: Quick Geyser and GMCP question

Post by Iktomi »

Fetaera - the event handler is already registered, and the function is already named the same as script... not sure why it's not working


Oneymus - I put that in there exactly and still no change.

I don't get it! I must be missing something, but I honestly don't know what it could be.

fetaera
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm

Re: Quick Geyser and GMCP question

Post by fetaera »

Can you post a screenshot of the script? This definitely, 100% works. I use it extensively in every single one of my IRE systems.

Post Reply