## SUPER STRICT for LUA

MrFariator
Party member
Posts: 265
Joined: Wed Oct 05, 2016 11:53 am

### Re: SUPER STRICT for LUA

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.
ivan
Party member
Posts: 1732
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: SUPER STRICT for LUA

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"
togFox
Party member
Posts: 262
Joined: Sat Jan 30, 2021 9:46 am

### Re: SUPER STRICT for LUA

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?
ivan
Party member
Posts: 1732
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: SUPER STRICT for LUA

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.
togFox
Party member
Posts: 262
Joined: Sat Jan 30, 2021 9:46 am

### Re: SUPER STRICT for LUA

I'll try both and see how I go.
togFox
Party member
Posts: 262
Joined: Sat Jan 30, 2021 9:46 am

### Re: SUPER STRICT for LUA

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:

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

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?
ivan
Party member
Posts: 1732
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: SUPER STRICT for LUA

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.
togFox
Party member
Posts: 262
Joined: Sat Jan 30, 2021 9:46 am

### Re: SUPER STRICT for LUA

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
ivan
Party member
Posts: 1732
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: SUPER STRICT for LUA

Can you please post the entire file so I can test it?
togFox
Party member
Posts: 262
Joined: Sat Jan 30, 2021 9:46 am

### Re: SUPER STRICT for LUA

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!

### Who is online

Users browsing this forum: No registered users and 9 guests