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 ➜ Jscript ➜ Would Java be best for this script?

Would Java be best for this script?

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


Posted by Shinrar Vallar   (13 posts)  Bio
Date Tue 19 Feb 2008 05:16 AM (UTC)
Message
Over the course of the years of my life, I've dabbled in this and that as far as programing goes. I've never dwelt in any one place long enough to learn the tricks of the trade, with the single exception of a code language called SPHERE, used in an Ultima Online emulator. But thats years and years ago...

I'm currently playing on a MUD, which is a star wars based one.

I'm a pilot on the Mud, and for a living, I transport cargo from one place to another. Its tedious, of course, so I want to write a personal script to use with the intention of having it automate the whole process in, essentially, three phases.

However, because this is a long and involved project, rather then tossing questions back and forth on the forums, I have two questions.

Firstly - Is Java best for this script? Would another language be easier? I choose Java because I know a little of what it does, and if I recall - it can do everything this script is going it need.

Secondly - Would anyone be willing to tutor me in Java for MUSHClient (or whichever language I end up using)? I'd write the script myself (well, I hope to), but in order to learn what i'm doing as I go along, I'd like someone I can either converse with via Instant Messenger, or via email, as I work. That way I learn faster - my work is private - I get the help I need quickly rather then waiting for a forum reply - and I don't have to reexplain what I'm doing from scratch every time I encounter a new problem...

Thank you in advance!
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #1 on Tue 19 Feb 2008 06:01 AM (UTC)
Message
I would, as would Nick, recommend Lua, as it is fast, robust, and easy to learn.

And you will get a TON of support on these forums in learning it.

-Onoitsu2
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Tue 19 Feb 2008 06:27 AM (UTC)
Message
First off, I assume you mean Javascript, not Java; the two are really quite different languages. (The fact that "java" appears in both is just a marketing ploy that has created a fair bit of confusion.)

Secondly, as Onoitsu2 points out, Lua will get much more support here as it is favored by most of the active community members. That said, any of the programming languages are very likely to completely meet your needs. (This is said, naturally, without knowing exactly what it is you want. But it's not as if one of the languages here is vastly superior to others in that it can do things that they simply cannot... that said, something might be easier in language X than language Y.)

Thirdly, I'm not sure how much private help you will receive. That goes against the spirit of the forums, which are based around the idea of sharing knowledge so that people in the future may also benefit from it. Yes, it is a little less convenient for you to have to wait for replies, but many people are happier to spend the time writing a forum post, than to spend the same time helping somebody privately. (Again, it has to do with the ethos of the site.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #3 on Tue 19 Feb 2008 04:34 PM (UTC)
Message
I will concur with the two posts so far... Lua is a great choice. It is more integrated with MUSHclient by virtue of being easier to embed into C++ programs, so it has a few more conveniences than the other languages do. It is also a pretty easy language to learn.

However, as David already mentioned, all languages supported with MUSHclient will work for your project. If you are very familiar with Jscript, then by all means, use them if you like. You will still get a good deal of people helping you out.

As for private help, it is honestly easier to get help on the forums for all the reasons that you would like to via email. With an explanation of what you are doing on the forums, many people will be looking at the issue, and the first available person will be able to post. Also, there will be less re-explaining if you have to get a second person to help you out, since it is all in a forum post. Setting up a 'tutoring' session with someone might be feasable, if someone has the time to sit down with you, but there are plenty of tutorial sites that can be used to get the basics down. Scan the forums as well if you run into problems, chances are someone has had a similar problem (whether the response that helped them will help you or not is uncertain though).

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 19 Feb 2008 07:46 PM (UTC)

Amended on Wed 20 Feb 2008 05:03 AM (UTC) by Nick Gammon

Message
Quote:

Is Java best for this script? Would another language be easier?


I concur with the other replies that, for a new project, I would choose Lua. For one thing, the integration between MUSHclient and Javascript is messy. For example, because Javascript does not directly support VBscript variants, you need to do this sort of stuff to get at wildcards for triggers and aliases:


wildcards = VBArray(wildcardsVB).toArray();	


Lua is more tightly integrated, so in Lua to get wildcard 1 you simply do:


x = wildcards [1]


There have been some reports of memory leaks in the scripting interface for the Windows Script Engine. Another recent thread here discusses the pain someone is going through to convert a lengthy script from another language into Lua.

Lua uses a different interface and does not suffer from this problem.

Lua's support for tables in particular (and nested tables) makes describing virtually any situation in code quite simple. Plus, there has been lengthy discussion about serializing Lua tables into strings (for saving and restoring from one session to another).

As for the personalized help, we try to be helpful here in the forums, but I am a big believer in that help being shared around. In the early days of MUSHclient I would answer questions by private email, only to find someone else ask the same question a week later, and have to answer it again. By answering on the forum I can say "see forum thread x, which discusses your problem" - as can other forum users.

Also I think you learn more if you have to spend an hour working on a problem before asking a question. If effectively forces you to try to find your own solution. Imagine how much _less_ you would learn if, when doing a maths problem, a teacher was hovering over your shoulder immediately correcting each mistake. You start letting the teacher do the work, and relax and stop thinking about it.

One more thing about Javascript - Java "looks like" the C language in many ways - so does Lua (in fact Lua looks bit like Pascal as well). Let me show you a comparison so you can see what I mean. I am taking an example function from example file that ships with MUSHclient:

Javascript


// --------------------------------------------
// Example showing a script called by a trigger
//  Should be connected to a trigger matching on: <*hp *m *mv>*
//   (the above example will work for SMAUG default prompts (eg. <100hp 10m 40mv>)
//    it may need to be changed depending on the MUD prompt format).
// --------------------------------------------
function OnStats (strTriggerName, trig_line, wildcardsVB)
{

  wildcards = VBArray(wildcardsVB).toArray();	
  
  iHP = wildcards [0]
  iMana = wildcards [1]
  iMV = wildcards [2]
  
  Note ("Your HP are " + iHP);
  Note ("Your Mana is " + iMana);
  Note ("Your movement points are " + iMV);

}	// end of OnStats 




Lua


-- --------------------------------------------
-- Example showing a script called by a trigger
--  Should be connected to a trigger matching on: <*hp *m *mv>*
--   (the above example will work for SMAUG default prompts (eg. <100hp 10m 40mv>)
--    it may need to be changed depending on the MUD prompt format).
-- --------------------------------------------
function OnStats (strTriggerName, trig_line, wildcards)

  iHP = wildcards [1]
  iMana = wildcards [2]
  iMV = wildcards [3]
  
  Note ("Your HP are " .. iHP)
  Note ("Your Mana is " .. iMana)
  Note ("Your movement points are " .. iMV)

end -- of OnStats 


Very similar aren't they? The main differences in this example are:


  • Comments are -- rather than //
  • String concatenation is done by .. rather than + (this makes a bit more sense, Lua reserves + for adding, so it can tell the difference between wanting to add 2 numbers (eg. 2 + 2 = 4) or concatenate them (eg. 2 .. 2 = 22)
  • Blocks of code end with "end" rather than using the { ... } brackets that C and Javascript do.
  • Arrays start at 1 rather than zero.


There are other differences, but you can see the language is not frighteningly alien.


- Nick Gammon

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

Posted by Shinrar Vallar   (13 posts)  Bio
Date Reply #5 on Wed 20 Feb 2008 01:42 AM (UTC)
Message
Wow... Now I feel pretty rude, having asked for private help and all. And ignorant.

I had seen the inactivity involved in the JScript board, and I figured the whole forums were that inactive. And having never heard of Lua, I more or less ignored that board, being naieve and writing it off instantly.

I'll go take a read on the threads and se what I can put together. And start a new thread over there, explaining what I want to do. Should be fun.

Thanks for your help!
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #6 on Wed 20 Feb 2008 04:33 PM (UTC)

Amended on Wed 20 Feb 2008 07:54 PM (UTC) by Shaun Biggs

Message
I can only speak for myself, but I did not find your question about private help rude. It was your first post, and you were polite in the whole message. Showing an interest in creating the script yourself with some help also goes a long way here, since hand-holding tends to lead to a person asking the same question again at a later date.

As far as the activity on the Jscript boards, it is simply a matter of how many people post questions. The forum is generally not full of random chatter, so each board is only posted on when a need arises. Looking from the number of responses from your post within 24 hours, you can see the board is still monitored by people willing to give a helping hand.

As far as Lua goes, it has been used since the mid 90's in several video games and embedded systems. Lucas Arts started using Lua for Grim Fandango (1997), when they replaced the SCUMM system they had been using. Since then, it has been used in many different projects, from astrophysics observatories, computer components, medical research, and up through now, it is the scripting language of World of Warcraft.

Ok, so I floated into Lua evangelism there... Sorry. Anyway, I used to write all my scripts/plugins in Jscript and never had an issue with them in MUSHclient. Everything worked great, and I only drifted over to VBscript when I decided I should get more familiar with another scripting language. The only reason I started using Lua was because for a while, I could not get Jscript to work while running MUSHclient on my Linux box. Since then, I have figured out how to get Jscript to work for Windows programs through WINE (a process akin to finding the right wrench to pound in the correct screw), but I still do most of my scripting in Lua now.

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #7 on Wed 20 Feb 2008 04:56 PM (UTC)
Message
I agree, the question wasn't rude for me either, and I hope you didn't take our suggestions to use the forums as being rude either because that certainly wasn't the intention. :-)

Shaun is right about judging activity: it should be judged based on how quickly responses come rather than how many posts there are. Not many people use JScript so not many questions come up, but if they do, plenty of people are willing to help answer them.

I'd float into Lua evangelism too but I think Shaun already covered that. :-P

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Shinrar Vallar   (13 posts)  Bio
Date Reply #8 on Wed 20 Feb 2008 05:02 PM (UTC)
Message
Thank you all!

I'm actually reading the FAQ and documentation on Lua. It... well... I had STARTED by writing triggers from this long multi-line echo I get filled with information from the Mud, and its been time consuming and only works about half the time. And the triggers each set just one variable. Looking at what I have with Lua thus far - it looks like one trigger can populate all my variables for me.

Making me wonder exactly why I haven't been looking into this first!

I didn't take your comments rude. And I'm thankful for the responses. I had feared I'd ask for help and it'd be a week before I got any replies. It seems I was greatly mistaken!

I'll actually probably be dropping into the Lua boards shortly. I seem to have reached a snag... But I'm, thankfully, half-way completed with Phase 1. Only Five-sixths of this thing to go!
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.


29,064 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.