attempt to index global 'torch' (a nil value) - lua

When I run a simple piece of code a = torch.Tensor(5,3) in ZeroBraneStudio, I receive the following error:
attempt to index global 'torch' (a nil value)
Does this mean that ZeroBraneStudio does not recognize Torch?

Make sure you select Torch as the interpreter (Project | Lua Interpreter | Torch-7) and configure the path to your th or luajit executable from torch (as described in this post).

Related

Why salome-elmer simulation could return LUA error when doing linear elasticity simulation?

I am using Salome-Elmer and have an LUA error. I found out it may be the reading problem.
MAIN: Reading Model: C:\Users\...\case.sif
Caught LUA error:...0-Release/share/elmersolver/lua-scripts/defaults.lua:58: r
LoadInputFile: Scanning input file: C:\Users
when I open the Lua file, line 57-58 writes:
function readsif(fname)
local f = assert(io.open(fname), 'r')
Anyone knows why? Thanks?

Attempt to index global 'application' (a nil value) error

I'm trying to follow a Lua roguelike course to learn the language and by line 17 when I had attempted to run the program to see the title it came up with the error
lua: [string "<eval>"]:1: attempt to index global 'application' (a nil value)
stack traceback:
[string "<eval>"]:1: in main chunk
Here's all the code I've written and the link to the course
application:setOrientation(Application.LANDSCAPE_LEFT
application:setScaleMode("letterbox")
BLACK # 0x1A1A1A
application:setBackgroundColor(BLACK)
local fg = Bitmap.new(Texture.new("images/foreground.png", true))
fg:setX(1201)
stage:addChild(fg)
YELLOW # 0xDAD45E
local title = TextField.new(nil, "The Long Dark")
title:setTextColor(YELLOW)
title:setPosition(1320, 100)
stage:addChild(title)
https://programmingbymoonlight.com/roguelike-part-1-lua-and-gideros-an-introduction/
So I tried gideros and it worked properly, while it depends on lua it has it's own commands native to it's IDE framework.

Mediawiki scribunto lua module do not know builtin functions

I am having a problem with calling Lua built-in functions using Scribunto.
I created basic module Module:Item
local p = {};
function p.test(frame)
print("Hello World!")
end
return p
Which I call in different page as {{#invoke: Item | test}}
and I receive a following error:
Lua error in Module:Item at line 3: attempt to call global 'print' (a nil value).
Backtrace:
1. (tail call): ?
2. Module:Item:3: in function "chunk"
3. mw.lua:511: ?
4. (tail call): ?
5. [C]: in function "xpcall"
6. MWServer.lua:99: in function "handleCall"
7. MWServer.lua:313: in function "dispatch"
8. MWServer.lua:52: in function "execute"
9. mw_main.lua:7: in main chunk
10. [C]: ?
Since print is Lua built-in function I have the feeling the problem will be somewhere in setting on the pc.
However, when I imported wiki Infoboxes, they are working OK.
Versions:
Linux Mint Tara - Cinnamon based on ubuntu 18
MediaWiki 1.31.7
Scribunto (106fbf4) 17:24, 15 May 2018
Lua 5.1.5
Any help pointing where the problem can be is highly appreciated.
Scribunto intentionally doesn't include print. The "Removed functions and packages" section in its manual says this about it:
This was discussed on wikitech-l and it was decided that it should be omitted in favour of return values, to improve code quality. If necessary, mw.log() may be used to output information to the debug console.

attempt to index a nil value (global 'math'))

I am using lua to make scripts in my game,
after updating the lua libs version from 5.1 to 5.3, an error appears on the game engine every time I use
math.X in a function
error :
Lua run doFile failed.attempt to index a nil value (global 'math'))
original code :
local value = math.random(1,10)
do you have any solutions ?

Attempt to index global 'Grid' (a nil value)

I have been trying to run the following codes from Euler Equations Solver. It is a Lua script that I have been toying with using ZeroBrane Studio. But the project gave the following error every time I try to execute it.
attempt to index global 'Grid' (a nil value)
stack traceback:
...mming Codes\Project 1\Lua Script\Problem 1\Problem 1.lua:7: in main chunk
[C]: at 0x00401b00
I am completely new to Lua and I have been looking for the solutions everywhere. Appreciate any help that I can get.

Resources