Lua testpad. socket not found error?

I’m just getting my head around all this lua thing . i’m a complete begginer to scripting . lot of you might have been in my place so first error "thanks " i’m trying to follow step by step guide and execute following in Testpad lua :slight_smile:

Let’s debug the following small test script, paste into RENOISE_PREFERENCES/Scripts/TestPad.lua:

debug.start()

local function sum(a, b)
return a + b
end

local c = sum(1, 2)
print(c)

debug.stop()


and what i get is this = in terminal :

Last login: Sat Sep 10 21:46:16 on ttys001

/var/folders/9g/yq3jrfn95_b2gcqjqlcqf8980000gn/T/Renoise-0-1189/Renoise_TmpFile-0-2.tmp.command ; exit;

gencode@GenCode ~ % /var/folders/9g/yq3jrfn95_b2gcqjqlcqf8980000gn/T/Renoise-0-1189/Renoise_TmpFile-0-2.tmp.command ; exit;

lua: …enoise/V3.4.2/Scripts/Libraries//remdebug/controller.lua:7: module ‘socket’ not found:

no field package.preload[‘socket’]

no file ‘/usr/local/share/lua/5.4/socket.lua’

no file ‘/usr/local/share/lua/5.4/socket/init.lua’

no file ‘/usr/local/lib/lua/5.4/socket.lua’

no file ‘/usr/local/lib/lua/5.4/socket/init.lua’

no file ‘./socket.lua’

no file ‘./socket/init.lua’

no file ‘/usr/local/lib/lua/5.4/socket.so’

no file ‘/usr/local/lib/lua/5.4/loadall.so’

no file ‘./socket.so’

stack traceback:

[C]: in function ‘require’

…enoise/V3.4.2/Scripts/Libraries//remdebug/controller.lua:7: in main chunk

[C]: in ?

** Failed to lauch the controller. Please make sure that Lua for Max OSX is installed.

Saving session…

…copying shared history…

…saving history…truncating history files…

…completed.

[Process completed]


before i continue i wanted to know if anybody knows how to fix it . secondly do i absolutely need Lua testpad ?
Lua is installed on my Mac . i’ have installed lua 5.4 and using Visual sudio Code app to learn and practice lua
i was hoping somebode can enlighten why i’m getting above error ?

Many Thx
GC

the LUA path is not written on your system

This is the weirdest thing. I tried your example and got the same error.

I sort of messed around, removing th debug things, and then, just to make it look nicer, indented the function code (the one line that returns the sum).

No error.

In fact, if I indent one space I get the error. Two spaces, and it works fine (including the debug calls)

I suspect it has something to do with the code being eval’ed inside some other running lua system.

But try it/

debug.start()
local function sum(a, b)
  return a + b
end
local c = sum(1, 2)
print(c)
debug.stop()

So Lua work like python
I have forgotten this

No, lua is not usually white-space sensitive. I think it is the embedded dev environment that does this.

strange…but it keep the code clean

a serious coder always keep the code clean even if he isn’t forced to do this

Hello,
I’m old school, so my debug listings are filled with prints,
but I guess you’re trying to connect to the debugger, which is supposed to run in the background.
I suspect it’s not running and that’s why you have a socket error.

PS: also it doesn’t seem to find the “sockets” library.

T-ger , how do i set path to LUA would you care to explain ?

I’m on mac

No need to do that. Just fix the indentation. It’s a quirk of the dev terminal.

i’m a very new Lua , terminal . is there any tutorial or simpler step by step explanation of how to fix the indentation ? or how to wix it any othr way ?

fixed it . i did’t have lua socket installed . installed socket . it works now

Thx