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
➜ Lua
➜ Trouble getting started with Lua
Trouble getting started with Lua
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| BishopOsiris
USA (55 posts) 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? | Top |
|
Posted by
| Fiendish
USA (2,534 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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>
 |
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 | Top |
|
Posted by
| Fiendish
USA (2,534 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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.
 |
To make your code more readable please use [code] tags as described here.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| BishopOsiris
USA (55 posts) 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:
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:
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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.
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:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
24,399 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top