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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Struggling.

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Struggling.
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sat 28 Aug 2010 04:16 AM (UTC)  quote  ]
Message
Hehe, okay, I see where you're coming from now. I am, unfortunately, not as precise as you are in your terminology. My "you need to" is not an absolute, but is relative to what is already present. I don't read RFCs very often, but I know that they try to nail things down exactly. You sometimes need to understand the origin of the "exact" terminology to know what the specific meaning is, though. I just try to explain things as easily to understand as possible. Colloquially, you might say.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Sat 28 Aug 2010 04:12 AM (UTC)  quote  ]
Message
If I could just clarify something here... In my experience as a consultant, I get to deal with different classes of people, whether the "Suits", the Programmers, or the IT staff. When talking to them, you need to have some frame of reference so everyone's "on the same page" and "speaking the same language" and communicating effectively.

When dealing with the computer types, the common jargon seems to sprout from the RFCs. When reading the RFCs, the language is very specific on what verbs to use, and when.

If "must" or "need" is used, it is a requirement for the implementation.
"Should" denotes something that's strongly recommended.
"May" is optional.


Perhaps I over-reacted to reading your quote, and I just wanted to clarify it for the other Geeky RFC minded people out there.

In this context: "You need to use \[this format]" Is inaccurate, because that format isn't an absolute requirement. (And if it was a requirement to use parens, then the string/table scenario can't work.)

So, in RFC-speak:
You SHOULD use the form:
Func(param, param2)
unless you're passing 1 param and that parameter is a literal string or table, which you MAY use the form:
Func "param"
or
Func {param}



So, this whole 'argument' is because the word "need" has very specific and absolute meaning to me and some other people. :)

Pedantic? Yea... but we're talking about code. And that brings up the old joke

"This stupid computer doesn't do what I want it to. It only does what I tell it to!"



I apologize for any hurt feelings and ruffled feathers. :)
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sat 28 Aug 2010 03:28 AM (UTC)  quote  ]

Amended on Sat 28 Aug 2010 03:36 AM (UTC) by Twisol

Message
WillFa said:
That's what I said...

I know it is. I just disagree that it needed to be said.

WillFa said:
I don't agree with your insinuation that it's "grandfathered". It was a deliberate choice and I've never read anything suggesting that if they had the choice to make all over again, they wouldn't make the same one. I don't think it's so exceptional when 95% of all Lua code I've read or written starts with it. (require "foo")

The table-literal calling shorthand came from SOL, Lua's predecessor. The semantics changed from "defining a record" to "calling a function with this table", but the syntax remained. http://www.lua.org/history.html

I can't find anything about the string-literal calling shorthand.

I'm not saying these things shouldn't exist, nor am I saying they shouldn't be taught. I'm saying the universal way should be taught first. And please; I never said foo{} and foo"" didn't work, I expressly didn't mention them. I wanted to solve the problem, and give a syntax that they can use anywhere.

WillFa said:
You're fixing mistakes that aren't mistakes.

Same to you. :)


[EDIT] Just so you know, I only responded to your original point because you aimed it specifically at what I had said (or rather, hadn't said). I don't care if you say it or not, but don't make me look ignorant. I do a good enough job of that on my own :P

[EDIT] For the sake of the OP, this marks my last post on the subject. I think we both understand eachother at this point, and I don't like arguments :S

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Sat 28 Aug 2010 03:14 AM (UTC)  quote  ]

Amended on Sat 28 Aug 2010 03:20 AM (UTC) by WillFa

Message
Twisol said:

WillFa said:
To be perfectly accurate, in Lua when passing a single string literal or single table construct to a function, the parentheses are optional.

It's an exceptional case grandfathered in from Lua's roots, and it only works when you have just one argument (which must be a string literal or a table literal). I'd rather teach people the way that always works first. =/




That's what I said...

I don't agree with your insinuation that it's "grandfathered". It was a deliberate choice and I've never read anything suggesting that if they had the choice to make all over again, they wouldn't make the same one. I don't think it's so exceptional when 95% of all Lua code I've read or written starts with it. (require "foo")

You're fixing mistakes that aren't mistakes. He didn't 'need to use Send()'. He needed a capital S. Don't teach that Send "flee northeast" is wrong, because it's not, and it will confuse your student when they do try to figure out why something like require "foo" works. (Is require a keyword? Nope, it's just a function included by default. But I was taught that functions need parentheses...)





http://xkcd.com/386/
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sat 28 Aug 2010 03:13 AM (UTC)  quote  ]
Message
Well, don't be too afraid to ask again. :) I helped a lot of really new users every day in the MUSHclient clan on Achaea, and it makes me happy to see someone learn the ropes and begin doing interesting things.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Siris   (17 posts)  [Biography] bio
Date Sat 28 Aug 2010 03:12 AM (UTC)  quote  ]
Message
thank you guys, got everthing working. hopefully i woulnt be bugging you guys for simplistic problems everyday.
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sat 28 Aug 2010 01:17 AM (UTC)  quote  ]
Message
WillFa said:
To be perfectly accurate, in Lua when passing a single string literal or single table construct to a function, the parentheses are optional.

It's an exceptional case grandfathered in from Lua's roots, and it only works when you have just one argument (which must be a string literal or a table literal). I'd rather teach people the way that always works first. =/


'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Sat 28 Aug 2010 01:07 AM (UTC)  quote  ]
Message
Twisol said:

...
Also, you need to use Send("flee northeast").

...


To be perfectly accurate, in Lua when passing a single string literal or single table construct to a function, the parentheses are optional.


print "Hello world."

require "tprint"
tprint { 1,2,3 }


print("Hello world.")
require("tprint")
tprint( {1,2,3} )


are equivalent.

So his original

send "flee northeast"

only needed the capitalization fixed.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 28 Aug 2010 12:32 AM (UTC)  quote  ]
Message
The GUI mapper really comes in two parts. The "core" mapper is a Lua module (mapper.lua) which comes with MUSHclient. This will draw a GUI map based on whatever information gets fed into it.

There are a couple of implementations of mapper plugins (one is the ATCP_Mapper.xml). I also did a "simple" one which doesn't use the telnet codes that the ATCP mapper does. This is presented here:

http://www.gammon.com.au/forum/bbshowpost.php?id=10138&page=7

As described in that thread, the core problem is to recognize rooms uniquely. If they happen to give you room numbers, that's great! Otherwise I hashed up the room description (and the exits I think) to give something that hopefully is unique.

In your case you might be able to adapt the simpler mapper to hash up the lines you showed (Mayor's Office, exits, description) to give something unique.

The exits themselves aren't that critical, as I think the plugin recognized when you typed a direction (eg. East) and when you entered a new room (because of the hash) and therefore it knows that east from room x takes you to room y.

There might be a way of handling absolutely identical room descriptions (assuming the exits are also identical) by remembering which room led to this one.

For example room a (reached from b) could be different from room a1 (reached from c) even if a and a1 had the same descriptions (because you remember how you got there).


- Nick Gammon

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

Posted by Siris   (17 posts)  [Biography] bio
Date Fri 27 Aug 2010 11:23 PM (UTC)  quote  ]

Amended on Fri 27 Aug 2010 11:33 PM (UTC) by Nick Gammon

Message
Thank you again. I will read the manual, and hopefully stop pestering you fine gentlemen. One last question though. Nick Your gui mapper seems to only use one line exit codes do you think it could be adapted to read multiple line exit codes? My mud's room code is as follows:


 Mayor's Office                                         -      -      -
(-------------------------------------------------)     - <---(M)-D-> -
                                                        -      S      -

  The office of Lord Telleri is luxurious enough to impress visitors with
the importance of the occupant, but still has all the markings of a working
office.  Despite the best efforts of secretaries and assistants, papers are
stacked on every corner of the priceless hand-carved desk, and half-read
briefs litter the credenza.  
*[Quest] Lord Telleri stands before you with a slight grin on his face.


and unfortunately some room descriptions are identical, however could that be manually mapped when the rooms are identical?
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 27 Aug 2010 11:19 PM (UTC)  quote  ]
Message
Yeah. The other question is how does "fighting" get set in the first place?

It could be easier to set the Lua variable rather than the MUSHclient variable.

eg.


<triggers>
  <trigger
   enabled="y"
   match="* kicks you!"
   send_to="12"
   sequence="100"
  >
  <send>fighting = 1</send>
  </trigger>
</triggers>


Now that trigger sets the Lua variable rather than the MUSHclient variable, and then your alias works as is.

- Nick Gammon

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

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Fri 27 Aug 2010 11:16 PM (UTC)  quote  ]
Message
Ah, because there are two kinds of variables: MUSHclient variables, and the scripting language's native variables. MUSHclient variables are held by MUSHclent, and you're using one by using <variable>. On the other hand, scripting variables (in this case, Lua's variables) are native language constructs, which you're attempting to use in your if-statement.

Change fighting in the if-statement to GetVariable("fighting"). Also, because MUSHclient variables can only contain strings, you need to check it against "1" instead of 1.

That's probably the most common trip-up when you're dealing with MUSHclient. :)

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Siris   (17 posts)  [Biography] bio
Date Fri 27 Aug 2010 11:01 PM (UTC)  quote  ]
Message
<variables>
<variable name="fighting">1</variable>
</variables>

<aliases>
<alias
match="ne"
enabled="y"
send_to="12"
keep_evaluating="y"
sequence="100"
>
<send>if fighting == 1 then
Send ("flee northeast")
else
Send ("northeast")
end</send>
</alias>
</aliases>

Errors are done with, however it will not send flee northeast to the mud. I hate to seem like such a newbcake, but I fail to see what I'm missing
[Go to top] top

Posted by Siris   (17 posts)  [Biography] bio
Date Fri 27 Aug 2010 10:54 PM (UTC)  quote  ]
Message
lol, i proof read it again and tried to fix my syntax errors, i'm not new to scripting just new to lua. ;) thank you for your fast response guys.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 27 Aug 2010 10:44 PM (UTC)  quote  ]
Message
Ninja'd! And I didn't spot the comma.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


2,719 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]