Compare commits
No commits in common. "a9457f7c386156b3221fb661010c47db5fed2550" and "3ce2d83c228fa9d1759d427aaed5af2e77dcc5c9" have entirely different histories.
a9457f7c38
...
3ce2d83c22
4 changed files with 11 additions and 68 deletions
|
@ -1,9 +1,4 @@
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 0.0.13
|
|
||||||
Date: 23.05.2025
|
|
||||||
Changes:
|
|
||||||
Add Item class
|
|
||||||
---------------------------------------------------------------------------------------------------
|
|
||||||
Version: 0.0.12
|
Version: 0.0.12
|
||||||
Date: 06.04.2025
|
Date: 06.04.2025
|
||||||
Changes:
|
Changes:
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
--- Utility class for a single item
|
|
||||||
--- @class Item
|
|
||||||
local Item = {}
|
|
||||||
|
|
||||||
--- Pass an item name or an item table to get a Item object
|
|
||||||
--- @param value string|table The name of the item or the item table
|
|
||||||
function Item:new(value)
|
|
||||||
local name
|
|
||||||
local item
|
|
||||||
|
|
||||||
if type(value) == "string" then
|
|
||||||
name = value
|
|
||||||
item = data.raw.item[name]
|
|
||||||
if not item then
|
|
||||||
log("Item not found: " .. name)
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
elseif type(value) == "table" then
|
|
||||||
name = value.name
|
|
||||||
item = value
|
|
||||||
end
|
|
||||||
|
|
||||||
local obj = {
|
|
||||||
prototype = item
|
|
||||||
}
|
|
||||||
|
|
||||||
setmetatable(obj, self)
|
|
||||||
self.__index = self
|
|
||||||
return obj
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Applies the item to the game
|
|
||||||
function Item:apply()
|
|
||||||
data:extend({ self.prototype })
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Assigns data to the item
|
|
||||||
--- Shorthand for table.assign(item.prototype, data)
|
|
||||||
--- @param data table The data to assign
|
|
||||||
function Item:assign(data)
|
|
||||||
table.assign(self.prototype, data)
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Sets the weight of the item calculated from given count per rocket.
|
|
||||||
--- @param count number The amount of items that fit into a rocket
|
|
||||||
function Item:itemsPerRocket(count)
|
|
||||||
self.prototype.weight = (1000 / count) * kg
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
return Item
|
|
|
@ -1,9 +1,9 @@
|
||||||
--- Utility class for a single recipe
|
---- Utility class for a single recipe
|
||||||
--- @class Recipe
|
---- @class Recipe
|
||||||
local Recipe = {}
|
local Recipe = {}
|
||||||
|
|
||||||
--- Pass a recipe name or a recipe table to get a Recipe object
|
---- Pass a recipe name or a recipe table to get a Recipe object
|
||||||
--- @param value string|table The name of the recipe or the recipe table
|
---- @param value string|table The name of the recipe or the recipe table
|
||||||
function Recipe:new(value)
|
function Recipe:new(value)
|
||||||
local name
|
local name
|
||||||
local recipe
|
local recipe
|
||||||
|
@ -29,14 +29,14 @@ function Recipe:new(value)
|
||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Applies the recipe to the game
|
---- Applies the recipe to the game
|
||||||
function Recipe:apply()
|
function Recipe:apply()
|
||||||
data:extend({ self.prototype })
|
data:extend({ self.prototype })
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Assigns data to the recipe
|
---- Assigns data to the recipe
|
||||||
--- Shorthand for table.assign(recipe.prototype, data)
|
---- Shorthand for table.assign(recipe.prototype, data)
|
||||||
--- @param data table The data to assign
|
---- @param data table The data to assign
|
||||||
function Recipe:assign(data)
|
function Recipe:assign(data)
|
||||||
table.assign(self.prototype, data)
|
table.assign(self.prototype, data)
|
||||||
return self
|
return self
|
||||||
|
@ -148,8 +148,8 @@ function Recipe:unlockedByTechnology(technology)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Clones the recipe
|
---- Clones the recipe
|
||||||
--- @param name string The name of the new recipe
|
---- @param name string The name of the new recipe
|
||||||
function Recipe:clone(name)
|
function Recipe:clone(name)
|
||||||
local clone = table.deepcopy(self.prototype)
|
local clone = table.deepcopy(self.prototype)
|
||||||
clone.name = name
|
clone.name = name
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cf-lib",
|
"name": "cf-lib",
|
||||||
"version": "0.0.13",
|
"version": "0.0.12",
|
||||||
"title": "cackling fiends library",
|
"title": "cackling fiends library",
|
||||||
"description": "Because I'd like to have my own library :-)",
|
"description": "Because I'd like to have my own library :-)",
|
||||||
"author": "cackling fiend",
|
"author": "cackling fiend",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue