Skip to content

Instantly share code, notes, and snippets.

@fusspawn
Created May 11, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fusspawn/1587594470144c8e5220f68719141a90 to your computer and use it in GitHub Desktop.
Save fusspawn/1587594470144c8e5220f68719141a90 to your computer and use it in GitHub Desktop.
local orig_load = SurvivalGame.loadCraftingRecipes
SurvivalGame.loadCraftingRecipes = function(self)
orig_load()
local extra = {
{ -- Water + Ember => Milk
itemId = "2c4a2633-153a-4800-ba3d-2ac0d993b9c8",
quantity = 1,
craftTime = 12,
ingredientList = {
{
itemId="869d4736-289a-4952-96cd-8a40117a2d28",
quantity=5
},{
itemId="267e0c93-62e3-45ad-9470-a14035cb9ca4",
quantity=1
}
}
}
}
for k,v in pairs(g_craftingRecipes) do
print("key for g_crafting: " .. tostring(k))
if k == "craftbot" then
for _k,_v in pairs(v) do
print("key for craftbot: " .. tostring(_k))
end
end
end
local recipies = g_craftingRecipes["craftbot"].recipes
local recipiesByIndex = g_craftingRecipes["craftbot"].recipesByIndex
for idx, recipe in pairs( extra ) do
recipe.craftTime = math.ceil( recipe.craftTime * 40 ) -- Seconds to ticks
for _,ingredient in ipairs( recipe.ingredientList ) do
ingredient.itemId = sm.uuid.new( ingredient.itemId ) -- Prepare uuid
end
recipies[recipe.itemId] = recipe
recipiesByIndex[#recipiesByIndex + 1] = recipe
end
-- NOTE(daniel): Wardrobe is using 'recipes' by uuid, crafter is using 'recipesByIndex'
g_craftingRecipes["craftbot"] = { path = g_craftingRecipes["craftbot"].path, recipes = recipies, recipesByIndex = recipiesByIndex }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment