Jump to content

How to access warly's recipes?


Cyde042

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

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