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 ➜ Suggestions ➜ a suggestions about “set prompt hp”

a suggestions about “set prompt hp”

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


Posted by Zilin   (1 post)  Bio
Date Sun 23 Apr 2006 01:42 PM (UTC)
Message
Good evening, I am a mud players from China. I‘m playing a mud game,when i use zmudclient, a setting(eg.set prompt hp) can show the player's hp value in the last line and only one line, and this line will be automatically refreshed each heartbeats. when i use mushclient, this setting dispaly badly.
like this:
set prompt hp
设定环境变数:prompt = "hp"
1849/7120>
1849/7120> 1849/7120> 【东拉西扯】兽兽对着朱雀惊奇地大叫起来:“哇~~~~~”
1849/7120> 1849/7120> 1849/7120> 【东拉西扯】朱雀拿起笔,在自己的脑门上写了“奸商”两个字。
1849/7120> 1849/7120> 1849/7120> 【东拉西扯】朱雀盯着唐楠,道:“我看你脑门上写了奸商两个字。”
1849/7120> 1849/7120> 1849/7120> 1849/7120> 【东拉西扯】虚夜[Yegui]:能化装舞会了
So I have to choose unset prompt.
Can solve this problem in the next version?
thanks
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 23 Apr 2006 09:57 PM (UTC)
Message
I think you have 2 problems here at least:

  1. I gather these are Chinese or similar Unicode characters which are being displayed using the MXP "entity" syntax: 环

    In MUSHclient MXP has to be turned on by the MUD server, it is not always on as it is in zMUD. There have been numerous discussions about this in the past, I personally don't agree with the idea that the client should always parse MXP, even if the MUD is not using it, as it leads to confusion if the MUD sends (say) <B>lacksmith, which would be interpreted as bold.

  2. You can force MXP on in MUSHclient (world settings) however in the MUSHclient implementation it assumes that entities are in the range 32 to 255, as that is what will fit into a single byte. Thus the number 29615 won't fit into one byte anyway, and MUSHclient stores MUD output (and all screen data) using single bytes.


Have you turned on UTF-8 (Unicode) in the world Output settings? If so, you might be able to write a trigger to effectively show your current HP when a prompt line arrives, and format that in UTF-8.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 23 Apr 2006 10:22 PM (UTC)
Message
Some experimenting has shown that if you enable UTF-8 in the world configuration, you should be able to display Unicode from within a trigger. I tried doing that, using a Unicode font, and did this script (in Lua):


print (utils.fromhex ("cea4ceb720ceb3cebbcf8e"))


The result was some Greek letters on the screen.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 23 Apr 2006 11:07 PM (UTC)
Message
To assist you in converting your Unicode numbers to UTF-8 I have written a Lua function that will handle that.


function to_utf8 (n)

assert (n >= 0 and n < 2097152, 
        "Unicode character out of range") -- range 0x0 to 0x1FFFFF

-- 0x00000000 - 0x0000007F    0 xxxxxxx

if n < 128 then     
  return string.char (n)

-- 0x00000080 - 0x000007FF    110 xxxxx 10 xxxxxx

elseif n < 2048 then
  return string.char (192 + bit.shr (n, 6)) ..
         string.char (128 + bit.band (n, 63))

-- 0x00000800 - 0x0000FFFF    1110 xxxx 10 xxxxxx 10 xxxxxx

elseif n < 65536 then
  return string.char (224 + bit.shr (n, 12)) ..
         string.char (128 + bit.band (bit.shr (n, 6), 63)) ..
         string.char (128 + bit.band (n, 63))

-- 0x00010000 - 0x001FFFFF    11110 xxx 10 xxxxxx 10 xxxxxx 10 xxxxxx

else
  return string.char (240 + bit.shr (n, 18)) ..
         string.char (128 + bit.band (bit.shr (n, 12), 63)) ..
         string.char (128 + bit.band (bit.shr (n, 6), 63)) ..
         string.char (128 + bit.band (n, 63))
end -- if

end -- function to_utf8 


What this does is take a single Unicode number and return a string which is that number converted into UTF-8. Depending on the size of the supplied number the UTF-8 version will be between 1 and 4 bytes long.

See this post for more details about UTF-8:

http://www.gammon.com.au/forum/?bbsubject_id=2681




-- test 4 major cases (each number range is handled separately):

print (utils.tohex (to_utf8 (100)))    --> 64
print (utils.tohex (to_utf8 (2000)))   --> DF90
print (utils.tohex (to_utf8 (5000)))   --> E18E88
print (utils.tohex (to_utf8 (80000)))  --> F093A280


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 23 Apr 2006 11:15 PM (UTC)
Message
With Lua as your script language, and that function somewhere (like in your script file) you could then display your example prompt like this:


Note (to_utf8 (35774),
      to_utf8 (23450),
      to_utf8 (29615),
      to_utf8 (22659),
      to_utf8 (21464),
      to_utf8 (25968),
      to_utf8 (65306)
      )

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


18,721 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.