I just started learning love and I've tried opening love with a batch file, while it does open it gives this error
Error
[love "boot.lua"]:321: No code to run
Your game might be packaged incorrectly.
Make sure main.lua is at the top level of the zip.
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'error'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
however when dragging the whole folder inside of love it works perfectly, does somebody know how can I fix this?
Error message
Error message indicates, that you did not set correct path to your code, so the is no code to run. It should be folder containing main.lua
Simple batch file
Place the following code to file start.bat:
#ECHO OFF
"C:\Program Files\LOVE\love.exe" "C:\path\to\game\folder"
(replace C:\path\to\game\folder with actual path to folder containing main.lua and if you have love.exe elsewhere, also replace it to the correct path)
And then, you can run your code by double-clicking the start.bat file
Some helpful links:
How to run your game
Batch file example
Related
I am trying to use luasnip.
The configuration I am using is AstroNvim.
The modifications I made to this configuration are :
require("luasnip.loaders.from_snipmate").lazy_load() at the end of init.lua
Made a directory snippets in the same directory of init.lua, and added some basic snipmate styled snippets inside.
Commands Like :LuaSnipListAvailable works well, and snippets from friendly-snippets works well too.
However the following error message pops up when opening neovim.
Error detected while processing /Users/myusername/.config/nvim/init.lua:
E5113: Error while calling lua chunk: ...m/site/pack/packer/start/packer.nvim/lua/packer/load.lua:171: Vim(echomsg):E121: Undefined variable: Error
stack traceback:
[C]: in function 'cmd'
...m/site/pack/packer/start/packer.nvim/lua/packer/load.lua:171: in function <...m/site/pack/packer/start/packer.nvim/lua/packer/load.lua:16
7>
/Users/myusername/.local/share/nvim/packer_compiled.lua:496: in function </Users/myusername/.local/share/nvim/packer_compiled.lua:485>
[C]: in function 'require'
/Users/myusername/.config/nvim/init.lua:23: in main chunk
I tried other methods of adding snippets, but any sort of require("luasnip") seems to break all.
I'm in the configuration neovim
I added the configuration file in C:\Users\wupan\AppData\Local\nvim\init.lua
require("lua.plugins")
and C:\Users\wupan\AppData\Local\nvim\lua\plugins.lua
return require('packer').startup(function()
use "wbthomason/packer.nvim"
end)
After the start-up neovim
Error detected while processing C:\Users\wupan\AppData\Local\nvim\init.lua:
E5113: Error while calling lua chunk: C:\Users\wupan\AppData\Local\nvim\init.lua:1: module 'lua.plugins' not found:
no field package.preload['lua.plugins']
no file '.\lua\plugins.lua'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\lua\plugins.lua'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\lua\plugins\init.lua'
no file '.\lua\plugins.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\plugins.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\loadall.dll'
no file '.\lua.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua.dll'
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\loadall.dll'
stack traceback:
[C]: in function 'require'
C:\Users\wupan\AppData\Local\nvim\init.lua:1: in main chunk
Press ENTER or type command to continue
May I ask why
I tried to install Lua test the require
scoop install lua
C:\Users\wupan\code\lua\test.lua
require("hello")
C:\Users\wupan\code\lua\hello.lua
print("hello world")
There are also problems
C:\Users\wupan\scoop\apps\lua\current\lua54.exe: .\test.lua:1: module 'hello' not found:
no field package.preload['hello']
no file 'C:\Users\wupan\scoop\apps\lua\current'
no file 'C:\Users\wupan\scoop\apps\lua\current'
stack traceback:
[C]: in function 'require'
.\test.lua:1: in main chunk
[C]: in ?
Problem analysis
Let's use the following example which you gave us:
C:\Users\wupan\AppData\Local\nvim\init.lua
require("lua.plugins")
C:\Users\wupan\AppData\Local\nvim\lua\plugins.lua
return require('packer').startup(function()
use "wbthomason/packer.nvim"
end)
And now let's take a look into your error message:
no file 'C:\Users\wupan\scoop\apps\neovim\current\bin\lua\lua\plugins.lua'
The important part is the bin\lua\lua thing here. It's because your
require("lua.plugins") starts to look up a directory in one of your runtime
path (see :h rtp for more information).
Solution
You just need to fix your content in
C:\Users\wupan\AppData\Local\nvim\init.lua to:
require("plugins")
because then neovim will look up a directory which is named plugins in
C:\Users\wupan\scoop\apps\neovim\current\bin\lua for example, since its in
your runtime path.
Little note
You can change your content from
C:\Users\wupan\AppData\Local\nvim\lua\plugins.lua to:
require('packer').startup(function()
use "wbthomason/packer.nvim"
end)
or how I did it:
local packer = require('packer')
packer.startup(function(use)
use 'wbthomason/packer.nvim'
end)
That makes it a little bit more readable in my opinion :)
I get a problem when playing Torch 7 code. I have a shared library libhashnn.so file, and I want to load the functions in Torch 7 script, so I use this expression: require 'libhashnn', but the trepl gives an error.
However, if I use package.loadlibfunction, it does work. Here are the results, but I don't know why I can't use require, how can I use require to load lib successfully?
require'libhashnn'
/home/dazhen/torch/install/share/lua/5.1/trepl/init.lua:383: bad argument #1 to '?' (table expected, got string)
stack traceback:
[C]: in function 'error'
/home/dazhen/torch/install/share/lua/5.1/trepl/init.lua:383: in function 'require'
[string "_RESULT={require'libhashnn'}"]:1: in main chunk
[C]: in function 'xpcall'
/home/dazhen/torch/install/share/lua/5.1/trepl/init.lua:650: in function 'repl'
...zhen/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
and
f=package.loadlib('libhashnn.so' ,'luaopen_libhashnn')
[0.0195s]
th> f
function: 0x41630f38
Try calling the function that package.loadlib gives you. I bet you will then get the same error that you get when you use require.
To understand why: require does the equivalent of package.loadlib and then calls that function so that the module that you are loading can initialize itself. With just package.loadlib, this initialization is not done and so the error that occurs during initialization does not show up.
I don't know what hashnn is and so I cannot tell you why it is broken, but looking at /home/dazhen/torch/install/share/lua/5.1/trepl/init.lua line 383 might be a good start to figure out what is going on.
Uploades file represented as tmpfile() and will be removed then script exits.
How to hardlink this file to keep its content after removing tmpfile?
How to get name of file by its handle?
> a=io.tmpfile()
> print(a)
file (0x20c8790)
> lfs=require"lfs"
> lfs.link(a,"/tmp/aaaa")
stdin:1: bad argument #1 to 'link' (string expected, got FILE*)
stack traceback:
[C]: in function 'lfs.link'
stdin:1: in main chunk
[C]: in ?
This file is too big to copy it by byte to another.
io.tmpfile uses tmpfile of stdio.h, so it wont be possible to adjust this exported function.
you can use libraries such as pl.path to get full path of temp file.
I'm trying to format code with a package I installed for Sublime Text 3 - FormatLua.
However, I'm getting this error when I try to use it...
/usr/local/bin/lua: ./metalua/compiler.lua:119:
./metalua/compiler/bytecode/lopcodes.lua:284: attempt to call field
'gfind' (a nil value) stack traceback:
[C]: in function 'error'
./metalua/compiler.lua:119: in function 'get_bytecode_compiler'
./metalua/compiler.lua:125: in function 'f'
./metalua/compiler.lua:153: in function <./metalua/compiler.lua:150>
(...tail calls...)
[C]: in function 'require'
formatter.lua:24: in main chunk
[C]: in ?
Does anyone know what I must do to fix this issue? I must be missing some files - I see that gfind is nil (this was taken out after 5.0), but I don't want to mess with anything unless I'm sure I know what I'm doing. Thanks!
Yes, gfind was deprecated. You can replace string.gfind with string.gmatch. I applied a similar change for the same reason; here is the commit.
Works well after downgrading lua version to 5.1.4
Compiling from source code:
Lua 5.1.4 here: http://www.lua.org/ftp/lua-5.1.4.tar.gz:
Open your Terminal.app
wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
tar xvzf lua-5.1.4.tar.gz
cd lua-5.1.4
make macosx
make install