<eof> expected near 'end' - lua

I'm using these files in my gaming server, and every time I add a new player model, I get
[ERROR] lua/autorun/server/fastdlskins.lua:938: '<eof>' expected near 'end'
1. unknown - lua/autorun/server/fastdlskins.lua:0
I also get a similar error when I add an add-on to a different file
[ERROR] lua/autorun/server/workshopitems.lua:55: '<eof>' expected near 'end'
1. unknown - lua/autorun/server/workshopitems.lua:0
I usually just have to put an 'end' after the code, but I don't see what else I'm required to do. I don't have any loops running (I think), so I'm not closing any of those out. Not sure what to do.

As Egor said, remove the extra end at the end of the files.
end is only used to close blocks for functions and loops, like } in C-like languages. The end at the file is not closing anything, and is thus invalid syntax.

Related

Garry's Mod Lua: Errors that request symbols that shouldn't be there?

I've been attempting to make a GMod gamemode, and as usual, lua is being annoying. It's requesting symbols that (as far as I know) shouldn't be there.
The errors:
gamemodes/gmdm/gamemode/init.lua:7: '(' expected near 'player_manager'
Code in question
function GM:PlayerSpawn
player_manager:SetPlayerClass( ply, "player_custom" )
Error:
gamemodes/gmdm/gamemode/player_class/player_custom.lua:4: '=' expected near 'player_manager'
1. unknown - gamemodes/gmdm/gamemode/player_class/player_default.lua:4
2. include - [C]:-1
3. unknown - gamemodes/gmdm/gamemode/shared.lua:1
4. include - [C]:-1
5. unknown - gamemodes/gmdm/gamemode/cl_init.lua:1
Code:
player_manager:SetPlayerClass( ply, "player_custom", )
(the other file lines it's referring to are the line include ("player_custom.lua") as well as shared.lua in cl_init.lua for some reason?)
Error:
gamemodes/gmdm/gamemode/shared.lua:10: attempt to call field 'Class' (a nil value)
1. unknown - gamemodes/gmdm/gamemode/shared.lua:10
Code:
player.Class( "player_default" )
player.Class( "player_custom" )
(it complains regardless of if it's Class or CLASS)
I have tried adding the symbols requested around the code but then it complains an unexpected symbol (presumably the ) ) is near the :
This one kind of confused me, as far as I know there's no reason there should be an = there.
As I said, I changed the capitalization, which didn't help.
I've been following the code from https://wiki.facepunch.com/gmod/Player_Classes as guide if using it as reference helps debug
Thank you very much for your time.

How do I find the error details using the match function on Lua?

I'm just asking a question on finding error details from the error function.
Like I would like to find error details from example.lua:50: "then" expected near "if".
Any ways on how to do that on Lua? I'm working on something for ComputerCraft on Lua. (Minecraft Java mod)
EDIT:
I'm trying make a function that returns the error parsed out. It's supposed to return 3 variables, var1: file name, var2: line number (if none it is specified nil), var3: error text.
example.lua is the file where the error is. 50 is the line number. There is a syntax error, likely in the if condition. (I'm not familiar with ComputerCraft, so I don't know where that file might be.)

Read a list from stream using Yap-Prolog

I want to run a (python3) process from my (yap) prolog script and read its output formatted as a list of integers, e.g. [1,2,3,4,5,6].
This is what I do:
process_create(path(python3),
['my_script.py', MyParam],
[stdout(pipe(Out))]),
read(Out, OutputList),
close(Out).
However, it fails at read/2 predicate with the error:
PL_unify_term: PL_int64 not supported
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
I am sure that I can run the process correctly because with [stdout(std)] parameter given to process_create the program outputs [1,2,3,4,5,6] as expected.
Weird thing is that when I change the process to output some constant term (as constant_term) it still gives the same PL_int64 error. Appending a dot to the process' output ([1,2,3,4,5,6].) doesn't solve the error. Using read_term/3 gives the same error. read_string/3 is undefined in YAP-Prolog.
How can I solve this problem?
After asking at the yap-users mailing list I got the solution.
Re-compiled YAP Prolog 6.2.2 with libGMP option and now it works. It may also occur in 32-bit YAP.

ROBLOX Lua Error in script: '=' expected near '<eof>'

Hello I am writing a scipt on ROBLOX and I have encountered a problem.
function showVictoryMessage(playerName)
local message = Instance.new("Message")
message.Text = playerName .." has won!"
message.Parent = game.Workspace
wait (2)
message.Destroy()
end
Upon running this function, or more specifically the "message.Destroy" command, I get the error: Error in script: '=' expected near '< eof >'
I have never seen this error before, and the ROBLOX wiki page on Lua errors doesn't mention it.
I would very much appreciate help in this, because I don't personally know anyone who has coded in Lua.
Looks like a syntax error. message.Destroy() should be message:Destroy() according to this Roblox wiki page http://wiki.roblox.com/index.php?title=API:Class/Instance/Destroy
Also see the section Explosions, Messages, and More at URL http://wiki.roblox.com/index.php?title=Basic_Scripting which provides similar syntax using the colon (:) operator.
See also Difference between . and : in Lua and explanation of "possible side-effects of calculations/access are calculated only once" with colon notation.
Instead of message.Destroy() it should be message:Destroy()
Remember that '.' are used directory-wise and ":' are used for inbuilt functions.
WOOOOOOOO! It was a syntax error. The correct command is message:Destroy. Cause why would object.Destroy work and message.Destroy not?

Lua Compiling Error 'do' expected near '['

I have a Lua file that I decompiled using unluac. When I try to recompile the files without any changes I get the following error:
lua: main.lua:647: 'do' expected near '['
I really do not know the problem here, as the while do statement follows the correct format.
The error is on line 647 as stated above.
Source is here:
Full Pastebin Source
Expressions like while {}[1] do and if {}[1].parentFolderName then are invalid because of {}[1] reference. It needs to be ({})[1]. It's probably a result of some sort of automated processing, but you should be able to fix it manually.

Resources