Page 4 of 6

Re: SUPER STRICT for LUA

Posted: Sun Feb 14, 2021 12:00 pm
by MrFariator
Couldn't get that one to specifically trigger, so I'm assuming it's working now. However, now I found a new issue regarding comments:

Code: Select all

return function ( item, other ) 
  if --[[other.isSlope or]] (other.isSolid and other.isPassable) then return "cross"
  elseif other.isSolid or other.isPlayer or other.isBreakable  then return "touch" end -- invalid expression 'elseif'
end
Removing the comment in line 2 will naturally stop sstrict from raising the error.

Re: SUPER STRICT for LUA

Posted: Sun Feb 14, 2021 1:20 pm
by ivan
Another good catch. Thanks again and I have pushed another fix on bitbucket!
Also if you want to have a report of the errors without halting each time you can use: "require("sstrict").panic = false"

Re: SUPER STRICT for LUA

Posted: Sun May 16, 2021 12:45 pm
by togFox
Silly question - how do I use this?
Just include the "sstrict.lua" file and any subsequent calls to "require","dofile","loadfile" or "loadstring" will be checked through SUPERSTRICT
.

If this checks subsequent calls to REQUIRE etc then how does it check my main.lua?

Re: SUPER STRICT for LUA

Posted: Sun May 16, 2021 5:18 pm
by ivan
You are right, it doesn't check main.lua by default.
One option is to include main twice: require("main")
Please note that you don't need to run SUPERSTRICT in real-time.
You can run a separate script that goes through all of the files in your game folder.
Thanks for using SUPERSTRICT.

Re: SUPER STRICT for LUA

Posted: Sun May 16, 2021 9:27 pm
by togFox
I'll try both and see how I go. :)

Re: SUPER STRICT for LUA

Posted: Mon May 17, 2021 11:09 am
by togFox
I did the extra file thing:

Code: Select all

require("sstrict")
require("Source.main")
And it is really as simple as that. Very sweet. :)

Now, to decipher what it is doing. I get this message:
Image

and here is the code (see line 118 and line 120):

Image

I really can't see what I'm doing wrong here. I commented out line 118 and then SSTRICT simply moved on to 120 and threw the same error. :(

Here is my function:

Code: Select all

local function Initialise2DArrrays()
	garrGameMessageLog[1] = {}
	table.remove(garrGameMessageLog,1)
	possibleactions = {}
	for i = 1,50 do						--! arbitrary number
		possibleactions[i] = {}
	end	
	local intNumOfObjects = 15			--! arbitrary number
	-- initialise 2D array
	for i = 1,intNumOfObjects do
		objects[i] = {}
		objectsingredients[i] = {}
		objectactions[i] = {}
	end	
	objectcanmake = {}
	for i = 1, #objects do
		objectcanmake[i] = {}
	end	
end
It's thinking my function call is a variable I guess. How do I stop that?

Re: SUPER STRICT for LUA

Posted: Tue May 18, 2021 7:58 am
by ivan

Code: Select all

It's thinking my function call is a variable I guess. How do I stop that?
Yes, function calls are variables too.
You have to make sure the function "Initialise2DArrays" is not global (or declare the function before you include SUPERSTRICT).
Looking at your code "Initialise2DArrrays" seems to be local so you can't call it from another file.

Re: SUPER STRICT for LUA

Posted: Tue May 18, 2021 8:10 am
by togFox
The function is in the same file (main.lua).

SS trips up if I declare the function local or not. If I comment out that function call then SS simply trips on the LoadSprites(). Again, defined and called in the same file.

Edit: I think this is the answer:

declare the function before you include SUPERSTRICT

Re: SUPER STRICT for LUA

Posted: Tue May 18, 2021 8:15 am
by ivan
Can you please post the entire file so I can test it?

Re: SUPER STRICT for LUA

Posted: Tue May 18, 2021 8:48 am
by togFox
I think I got it - my love.load,love.update and love.draw is at the TOP of my main.lua meaning those functions are not yet declared.

I'm now doing a mass copy/paste to get things declare in the right sequence. Thanks!