Jump to content

Recommended Posts

I'm not talking about where to find them, but how to get access them as to change them.

The last 2 lines were added by me but while I don't crash on recipes_warly, I do crash when it tries to index it.

local require = GLOBAL.require
local cooking = require "cooking"
local recipes = cooking.recipes.cookpot
--local warly = require "prefabs/warly"
local recipes_warly = cooking.recipes.portablecookpot

Non-Warly crock pot food - works

recipes.californiaroll.test = function(cooker, names, tags) return (names.seaweed and names.seaweed == 2) and (tags.fish and tags.fish >= 1) and not tags.frozen and not tags.inedible end

Warly crock pot food - crash

recipes_warly.sweetpotatosouffle.test = function(cooker, names, tags) return (names.sweet_potato and names.sweet_potato == 2) and tags.egg and tags.egg >= 2 and not tags.frozen and not tags.inedible end

Please help me out.

If I recall correctly, "require" only loads the file once, then it loads a cached package.

Here's a great example of this: http://lua-users.org/wiki/ModulesTutorial

package.loaded.PACKAGENAME is the returned value (in this case, "package.loaded.cooking" is the table you nicknamed "cooking")

Edited by Mobbstar
3 hours ago, Mobbstar said:

If I recall correctly, "require" only loads the file once, then it loads a cached package.

Here's a great example of this: http://lua-users.org/wiki/ModulesTutorial

package.loaded.PACKAGENAME is the returned value (in this case, "package.loaded.cooking" is the table you nicknamed "cooking")

I don't get what I'm supposed to make of this... sorry.

I'm not even sure if the local variables are assigned correctly. If you look, the recipes are placed in Warly's prefab in table "specialtyfoods".

Is the require warly part even corect?

if package.loaded.cooking then
  package.loaded.cooking.recipes.portablecookpot.sweetpotatosouffle.test = function(cooker, names, tags) ... end
end

I hope this clears your confusion. The first like checks if the package is loaded ( you could instead use "require" to load it if needed ) and the second directly accesses the wanted value, in this case, the test function.

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...