Jump to content

Problems on cookpot recipies


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?

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...