Jump to content

Recommended Posts

I add some new cookpot recipies  in modmain, some were ok, However, some went wrong.

When cooking,some material matches will report bug. It say" attempt to compare number with nill"

How to solve it?

 

I had this same problem in a mod I just published

 

Look at the line of code referenced by the error,

does it say something like

test = function(cooker, names, tags) return tags.meat >= 1

 

I believe the problem is the game is looking to see if your cooker has (in this example) meat value greater than 1, but you have 0 meat and the game is confused.

you are asking Is there more than X of this ingredient?

the game comes back and says 'I cant tell if it is greater because I cant find it.'

(attempting to compare a number with nil)

 

Anytime your recipe needs to check a value be greater than, you need to tell it to check for the value be present first.

Also if you want a value to be less than, you need to do the same thing, otherwise anything with 0 (none of the ingredient) will still qualify

 

try this

test = function(cooker, names, tags) return tags.meat and tags.meat >= 1

 

Imagine it a two step question - is there any of this ingredient and if so is it more (or less) than X ?

Edited by MidrealmDM

I had this same problem in a mod I just published

 

Look at the line of code referenced by the error,

does it say something like

test = function(cooker, names, tags) return tags.meat >= 1

 

I believe the problem is the game is looking to see if your cooker has (in this example) meat value greater than 1, but you have 0 meat and the game is confused.

you are asking Is there more than X of this ingredient?

the game comes back and says 'I cant tell if it is greater because I cant find it.'

(attempting to compare a number with nil)

 

Anytime your recipe needs to check a value be greater than, you need to tell it to check for the value be present first.

Also if you want a value to be less than, you need to do the same thing, otherwise anything with 0 (none of the ingredient) will still qualify

 

try this

test = function(cooker, names, tags) return tags.meat and tags.meat >= 1

 

Imagine it a two step question - is there any of this ingredient and if so is it more (or less) than X ?

 

Thanks a lot for your help. I noticed the "name" should be repeated when use “≥“,but I ignored that so does tags. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...