[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  MXP and Pueblo
. . -> [Subject]  bug? in !entity

bug? in !entity

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


Pages: 1 2  

Posted by Xtian   (53 posts)  [Biography] bio
Date Sun 28 Feb 2010 08:20 PM (UTC)
Message
I have the impression that when the server re-sends an !ENTITY line Mushclient doesnt replace (overwrite) the first definition.

The spec gives the impression that this can be used to actualize an MXP variable in the client:

"The <!ENTITY> tag allows the MUD server to set the value of a variable without displaying the value to the user."

And this does work in cmud.

I am sending for example (omitting MXP encoding):

!ENTITY HP 100
!ENTITY HP 77

The second line doesnt register a change in the menu "world configuration->variables".
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 28 Feb 2010 09:24 PM (UTC)
Message
Entities don't change variables. Use:


hp = tonumber (GetEntity("HP"))



See:

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

*Elements* can change variables, eg.


<!ELEMENT hp flag='set hp'>

<hp>120</hp>


That would change mxp_hp variable.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xtian   (53 posts)  [Biography] bio
Date Reply #2 on Sun 28 Feb 2010 09:51 PM (UTC)
Message
Hm, but using an predefined !ELEMENT or VAR tag outputs the value to the player in-stream. Using !ENTITY hides it.

I dug around a bit and found this thread
http://forums.zuggsoft.com/forums/viewtopic.php?t=14249 (third post)

"OOps, syntax should be:
...
<!ENTITY Hp 50>
depending upon whether you want to display the variables or not"
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sun 28 Feb 2010 10:28 PM (UTC)
Message
Xtian said:

Hm, but using an predefined !ELEMENT or VAR tag outputs the value to the player in-stream. Using !ENTITY hides it.


If you are wanting a variable set, this is for scripting, right? So my solution lets you get at the number.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xtian   (53 posts)  [Biography] bio
Date Reply #4 on Sun 28 Feb 2010 10:32 PM (UTC)
Message
uh, no. I'm thinking server -> to -> client. Should have made that clear.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 01 Mar 2010 03:14 AM (UTC)
Message
I'm sorry, I don't understand the problem. Can you explain in more detail what you are trying to do, and in what way my earlier suggestion does not solve that?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xtian   (53 posts)  [Biography] bio
Date Reply #6 on Mon 01 Mar 2010 07:44 AM (UTC)
Message
I'm a server admin and I want my server to update MXP variables in the client. For example to tell the client the HP just changed.
The client-user can then use them in his scripts.

As I understand the spec there are two ways of the server setting MXP variables in the client:

1.) using a <var> tag or a custom element definition as you proposed abvoe. This will look like this: <var HP>60</var> and the value 60 will be displayed to the user. Servers will use this method if they want to display the value anyway, like in prompts or a character vitals screen.

2.) using !ENTITY like this: <!ENTITY HP 60> and nothing will be displayed to the user. Servers will use this if they want to silently update the value in the client.

Mushclient seems to not correctly implement 2.) but I'm pretty sure now that it is the way the spec was supposed to work (see my quotations for example and cmud does show this behaviour).

Of course I could work around that just for Mush, but I think it is a bug and I wanted to confirm and report it.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Mon 01 Mar 2010 08:10 AM (UTC)
Message
I'm not sure exactly which part of the spec MUSHclient is not following, but I assume you are referring to this:

http://www.zuggsoft.com/zmud/mxp.htm#ENTITY

MXP spec said:

PUBLISH entities can be used by the client to produce a list of MUD Server variables to be access by the player


I note that you didn't mention "publish" in your example so I am guessing a bit here.

*Are* you referring to that? In which case a more complete example, mentioning the word "publish" would have helped.

I think the MXP spec has changed since I implemented it. I am getting a bit tired of having the spec change without me being informed, and then getting "bug" reports that some behaviour, of which I know nothing about, is not implemented.

In any case, I don't like the idea of the server randomly changing client variables. If you mean that your example should change the "hp" variable, what if the client was using that variable for some other purpose? And in the case of MUSHclient, you can have multiple plugins. Should the variable be changed in every plugin script space, or just the main world?

In the case of the "element" variable setting which I mentioned, I specifically prepended "mxp_" to the variable being set, in case that variable was used by the client for some other purpose.

Xtian said:

Of course I could work around that just for Mush, but I think it is a bug and I wanted to confirm and report it.


You don't need to work around it. MUSHclient and cMUD have different scripting anyway, so as long as the variable is accessible to the script, what do you need to worry about? You can hardly have identical scripts running on both clients, and since they have to differ, they can differ in the way they grab that variable. What is the problem exactly?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xtian   (53 posts)  [Biography] bio
Date Reply #8 on Mon 01 Mar 2010 08:29 AM (UTC)
Message
Nick Gammon said:

What is the problem exactly?


Problem: I (the server) am sending variable updates with the ENTITY-Tag and Mushclient-users are not registering them.

Nick Gammon said:

I note that you didn't mention "publish" in your example so I am guessing a bit here.

*Are* you referring to that?


No, I am only sending <!ENTITY name value> and referring to:

Xtian said:

"The <!ENTITY> tag allows the MUD server to set the value of a variable without displaying the value to the user."


from the VAR section of http://www.zuggsoft.com/zmud/mxp.htm (just beneath the ENTITY section).
Since this can be misinterpreted, I looked for confirmation elsewhere and found:
Xtian said:

http://forums.zuggsoft.com/forums/viewtopic.php?t=14249 (third post)

"OOps, syntax should be:
...
<!ENTITY Hp 50>
depending upon whether you want to display the variables or not"


Summing up: The server sending the sequence
<!ENTITY HP 50 publish>
<!ENTITY HP 40>
should create a variable in the client called "hp" (in Mushclient prependet wit an "mxp_") and initialize it to 50, then set it to 40.
Mushclient does parse the second line but does not update the variable as I would have expected.

(the second line may or may not have a publish - I am not quite clear on that)
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Mon 01 Mar 2010 07:01 PM (UTC)
Message
On that page you quote:

Zugg said:

Actually, there isn't any bug in the zMUD variable updating when the correct syntax is used. Either:

<VAR hp>50</VAR>

or

<!ENTITY hp 50>

both properly update the gauge.


There is no talk about "<!ENTITY hp 50>" updating a *variable*.

I still don't understand your problem - this isn't a bug, according to the MXP spec variables should only change if you use the PUBLISH keyword, and you said you are not doing that. So what is the bug? There isn't one.

If you are trying to draw a gauge, and in MUSHclient you have to script to do that, you would do something like this:


-- called when an entity changes
function OnPluginMXPsetEntity (which)
  hp = tonumber (GetEntity("HP"))
  -- draw updated gauge
end -- function




- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Mon 01 Mar 2010 07:08 PM (UTC)

Amended on Mon 01 Mar 2010 07:09 PM (UTC) by Nick Gammon

Message
The relevant part of the MXP spec says:

MXP spec said:

Entities

<!ENTITY> <!EN>
<!ENTITY Name Value [DESC=description] [PRIVATE] [PUBLISH] [DELETE] [ADD] [REMOVE]>


Entities in MXP are used to store information from the MUD (MUD Variables). Once an entity is defined, you can reference it's value using the &Name; syntax. For example:

<!ENTITY Version "6.15">
The current version of zMUD is &version;

would display:

The current version of zMUD is 6.15

Tags can be included within entities. Unlike in XML, tags can be broken across entities within MXP as long as when all entities on a line from the MUD are expanded, all of the tags are properly closed (or MXP will close the dangling tags for you). So, the following is valid in MXP:

<!ENTITY Start "<em>">
<!ENTITY End "</em>">
&Start;This text is emphasized&End;

Also note that as in XML, entities are case sensitive, so &Start; is different than &start;. Unlike XML, entities can be used anywhere in MXP, even within other tags. However, if an external entity has the same name as an attribute, the attribute within a tag takes precedence.

All of the default HTML entities are defined in MXP.

To delete an entity, use the DELETE argument. Setting an entity to a empty value does not delete it.

PRIVATE entities cannot be queried by the MUD client. They are completely hidden.

PUBLISH entities can be used by the client to produce a list of MUD Server variables to be access by the player


Note that it says that Entity sets MUD Server variables - not client variables. It would be a crazy system if the server could just change client variables willy-nilly. The current version of the MUD Server variable set by the !ENTITY command is stored in a lookup table inside MUSHclient and can be queried with GetEntity(<name>). This is logical and what MUSHclient does.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xtian   (53 posts)  [Biography] bio
Date Reply #11 on Mon 01 Mar 2010 08:54 PM (UTC)
Message
Aaah, I just had an epiphany why we are so utterly confusing each other!

I think you are seeing the "thing" the server sends in <var> tags as something different than what the server sends in a <!entity> tag. Am I right?

Look, if I send
<var HP>40</var> to mushclient the "mxp_hp" variable shows up in world-configuration->scripting->variables.

If I send
<!ENTITY HP 40 PUBLISH> to mushclient "mxp_hp" doesn't show up.

Before we start quoting the spec at each other again I should ask: Is there a reasoning on your side behind this?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Mon 01 Mar 2010 10:21 PM (UTC)
Message
Before I answer that can you please explain in what way you can't use MUSHclient to display the gauge you want to display, using the method I described above?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xtian   (53 posts)  [Biography] bio
Date Reply #13 on Tue 02 Mar 2010 05:46 AM (UTC)
Message
I am not looking to display a gauge. The linked discussion referred to a gauge, but this was a MXP <GAUGE> tag, which connects a gauge with a MXP entity/variable - displaying the gauge with the value of that entity/variable sent from the server. The post in question I used as an example for how to correctly send the value == entity/variable.

sever sends: <GAUGE HP MaxHP> (syntax by heart) will tell the client to display a gauge in cmud/zmud with the values of "HP" and "MaxHP".
server sends: <var HP>60</var> or <!ENTITY HP 60> will update the cached value in the client and thus change the gauge.

I can also find other examples on using <var> and <!ENTITY> if you wish, so please ignore the <gauge> reference. It is not relevant to my intention.

ps: When I write: "I send ..." I'll always mean that the server sends. Le server, c'est moi.
[Go to top] top

Posted by Drrcknlsn   (1 post)  [Biography] bio
Date Reply #14 on Fri 05 Mar 2010 03:42 PM (UTC)
Message
The real issue here has nothing to do with the spec. MUSH implements the spec just fine. It has to do with how MUSH handles MXP entities versus MXP variables when it comes to automatically storing them as script variables.

As Xtian said in his other post, MUSH does not automatically produce "mxp_"-prefixed script variables for MXP entities like it does for MXP variables. Even though these entities are still available to scripts through the GetEntity() interface as Nick pointed out, the problem here isn't one of availability; it's of convenience.

It would be -convenient- if MXP entities produced "mxp_"-prefixed script variables like MXP variables do. This, however, has nothing to do with the spec. As long as MUSH is making entities accessible to its users (it is), it's complying with the spec.

So, in short, this is not a bug. It's a feature request.
[Go to top] 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.


51,369 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] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]