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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Trouble getting started with Lua
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Trouble getting started with Lua

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


Posted by BishopOsiris   USA  (38 posts)  [Biography] bio
Date Sat 26 Nov 2016 02:35 PM (UTC)
Message
I bought the book "Programming in Lua" fourth edition by Lerusalimschy. I downloaded a binary interpreter for Window x86 from http://luadist.org/. When I open it, it says its a compiler. I can't even get the very first program (hello world) to work. It just says "nil". I was really excited to get started with this language but I hit this road block right out of the gate :(

Is there is a difference between a compiler and an interpreter?

What am I doing wrong?
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Sat 26 Nov 2016 09:24 PM (UTC)
Message
Quote:
I can't even get the very first program (hello world) to work. It just says "nil".
You've failed to tell us what you did so we have no comments on why it didn't work.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 27 Nov 2016 12:39 AM (UTC)
Message
You can use the Immediate window inside MUSHclient (Ctrl+I) to try a lot of Lua stuff. A possible problem is that if you go into an infinite loop you will have to force-quit MUSHclient. You can add this timer to pretty-much prevent that:


<timers>
  <timer name="runaway" 
    enabled="y" 
    second="5.00" 
    send_to="12"
    active_closed="y" >
  <send>

runaway_instruction_limit = 100000

function hook ()
  debug.sethook (hook, "", runaway_instruction_limit)
  error ("Runaway instruction limit reached")
end -- hook

debug.sethook (hook, "", runaway_instruction_limit)

</send>

  </timer>
</timers>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.





As for your issue, copy/paste exactly what you tried, that printed "nil".

- Nick Gammon

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

Posted by BishopOsiris   USA  (38 posts)  [Biography] bio
Date Reply #3 on Sun 27 Nov 2016 12:43 PM (UTC)
Message
How do I post images?
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #4 on Sun 27 Nov 2016 09:57 PM (UTC)
Message
Post them on an image sharing service and put the URL here.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sun 27 Nov 2016 10:02 PM (UTC)
Message
Why do you want to post an image? Copy and paste the code you were using, and copy and paste the error message you got.

Template:codetag To make your code more readable please use [code] tags as described here.

- Nick Gammon

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

Posted by BishopOsiris   USA  (38 posts)  [Biography] bio
Date Reply #6 on Wed 07 Dec 2016 03:47 PM (UTC)

Amended on Wed 07 Dec 2016 08:53 PM (UTC) by BishopOsiris

Message
At the Lua prompt in my interpreter:

Lua>


I type:

Quote:
hello.lua


This is what it spits out:


stdin:1 attempt to index a nil value (global 'hello')
stack traceback:
     stdin:1: in main chunk
     [C]: in ?


The hello.lua file is in the same directory as the interpreter and it consists of this:

 print("hello world")
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Wed 07 Dec 2016 10:10 PM (UTC)
Message
If you want to run an external file, then run Lua with an argument, eg.


lua hello.lua


You don't start Lua up, and then type in a file name like you did.

However if you have already started the Lua interpreter up, then you can "dofile" it, eg. from inside Lua:


Lua>  dofile "test.lua"

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


3,236 views.

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 FutureQuest]