Editor autocompletion for project LUA modules not working

Ciao,
i’ve divided my project in multiple LUA modules but it seems that the editor autocompletion doesn’t work with them.

Standard libraries (go, tilemap, etc) work.
Imported 3rd party libraries (Monarch, Rendercam) work.
My modules (lua modules files in the project) don’t work. :frowning:

i declare them in the same way as 3rd party libraries

local MA = require “main.match”
local FL = require “ludobits.m.flow”
local MO = require “monarch.monarch”

What i’m missing?

Hmm, you should get autocomplete for those… Could you try renaming from MO to monarch and try if that makes any difference (unlikely but worth trying).

MO (or monarch) works, all imported libraries do.

I don’t get autocompletion for lua modules files in the project (.lua files)

How are your own Lua modules setup? Can you post an example?

For example:

immagine

Declaration in the file where i want to use it (i.e. game.script)

local CO = require "main.constants"

File content (constants.lua)

local M = {}

-- player1, player2, freezed as defined by the following constants
M.ORBS = {hash("red_orb"), hash("blue_orb"), hash("white_orb")}
M.PLAYER1 = 1
M.PLAYER2 = 2
M.FREEZED = 3

return M

i also have modules with functions (don’t work either)

local M = {}

local CO = require "main.constants"
local BO = require "main.board"
local UT = require "main.utils"

-- dumb AI, places an orb in the first empty cell
M.think = function(player, boardValues)
	local tile = vmath.vector3()
	for x = CO.BOARD_XMIN, CO.BOARD_XMAX do
		for y = CO.BOARD_YMIN, CO.BOARD_YMAX do
			tile.x = x;
			tile.y = y;
			local cellPos = BO.getCellIndexInBoard(tile)
			local value = boardValues[cellPos]
			if(value == nil) then
				return tile
			end
		end
	end
	return nil
end

return M

Try function M.think(player, boardValues) instead.

1 Like

This should work.

Also module values do not auto-complete. It has been requested before.

3 Likes

this works for functions… it requires to rewrite all the method signatures :confused: …but i can bear to do it for having the autocompletion to work

but for “constants” i don’t see a similar solution… and i have a lot of them (i only posted a minimal portion of my file :smiley: )

can’t we have autocompletion to work in either way :pray: ?

@mats.gisselson and @vlaaad!

3 Likes

This is a limitation of the current Lua parser. We’ve started looking into how it can be improved, but are busy working on other areas of the editor at the moment.

1 Like

should i create a ticket on github for this?

hello, resurrecting this topic as this is the most annoying limitation i have using the editor.
Any news?

I’m also interested in this. I tend to put almost every function into various modules these days, to make things neater.