Editor autocompletion for project LUA modules not working

#1

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?

0 Likes

#2

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).

0 Likes

#3

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

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

0 Likes

#4

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

0 Likes

#5

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
0 Likes

#6

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

1 Like

#7

This should work.

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

2 Likes

#8

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: ?

0 Likes

#9

@mats.gisselson and @vlaaad!

3 Likes

#10

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

#11

should i create a ticket on github for this?

0 Likes