2

I'm running Zerobrane 1.8 and LUA 5.3. However, in the interpreter the string function does not have "pack()" method/sub-function, i.e.,

  print(string.pack("<I4",9))

returns the error: "pack method is nil."

I've tried this in other online version of lua interpreters but got the same problem. Yet, the reference manual

https://www.lua.org/manual/5.3/manual.html#pdf-string.pack clearly shows that this function should exist. What am I missing here?

Shejo284
  • 4,541
  • 6
  • 32
  • 44
  • 1
    What is the output of `print(_VERSION)` ? – Egor Skriptunoff Oct 23 '18 at 20:01
  • It works [here](https://www.lua.org/cgi-bin/demo). – IS4 Oct 23 '18 at 22:44
  • 1
    In the version of ZeroBrane that I have (1.60), the interpreter ("Local console") uses Lua 5.1. Lua 5.1 doesn't have `string.pack`, which was added in Lua 5.3. – cyclaminist Oct 23 '18 at 23:09
  • @EgorSkriptunoff (also cyclaminist): thanks for the tips. Even though I have selected "Project -> Lua interpreter -> 5.3" in the local console the command "print(_VERSION) returns 5.1. This explains it but how do I force the local console to use Lua 5.3? – Shejo284 Oct 24 '18 at 05:51
  • 1
    I use [Textadept](https://foicica.com/textadept/) most of the time, so I can't answer your question for sure. But my impression is that the Lua interpreter menu only selects the version of Lua that is used for running scripts. – cyclaminist Oct 24 '18 at 08:08
  • @cyclaminist that is strange because I have version 5.3 selected. I'll ask at the LUA home to see if I can get an answer. Thanks :-) – Shejo284 Oct 24 '18 at 08:39
  • 1
    Replace exit -> exist (typo). Can't edit one character. – val - disappointed in SE Oct 24 '18 at 13:58
  • 1
    @val - Replace also `method` with `function` :-) – Egor Skriptunoff Oct 24 '18 at 14:35

1 Answers1

2

As pointed out in the comments, the Local console interpreter uses the same Lua version as the one that runs the IDE, which is Lua 5.1 by default. Switching the interpreter in the IDE only affects running and debugging scripts. A simple workaround to get Lua 5.3 interpreter in the console is to start a debugging session using Lua 5.3 interpreter, which will allow to run Lua 5.3 commands in the (Remote) console. There is also a related ticket, which you may want to monitor or contribute to.

Paul Kulchenko
  • 25,884
  • 3
  • 38
  • 56