a suggestions about “set prompt hp”

Posted by Zilin on Sun 23 Apr 2006 01:42 PM — 5 posts, 19,522 views.

#0
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
Australia Forum Administrator #1
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.
Australia Forum Administrator #2
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.
Australia Forum Administrator #3
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

Australia Forum Administrator #4
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)
      )