SUPER STRICT for LUA

Showcase your libraries, tools and other projects that help your fellow love users.
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: SUPER STRICT for LUA

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

Re: SUPER STRICT for LUA

Post 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"
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: SUPER STRICT for LUA

Post 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?
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: SUPER STRICT for LUA

Post 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.
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: SUPER STRICT for LUA

Post by togFox »

I'll try both and see how I go. :)
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: SUPER STRICT for LUA

Post 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?
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: SUPER STRICT for LUA

Post 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.
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: SUPER STRICT for LUA

Post 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
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: SUPER STRICT for LUA

Post by ivan »

Can you please post the entire file so I can test it?
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: SUPER STRICT for LUA

Post 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!
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests