Guest User

Untitled

a guest
Apr 29th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.76 KB | None | 0 0
  1. local settings = settings["startup"]
  2.  
  3. local function index_to_letter(index, starting_at)
  4. return string.char(string.byte(starting_at or "a", 1) - 1 + index)
  5. end
  6.  
  7. local function AddLootToEntity(entityType, entityName, itemName, probability, countMin, countMax)
  8. if data.raw[entityType] ~= nil then
  9. if data.raw[entityType][entityName] ~= nil then
  10. if data.raw[entityType][entityName].loot == nil then
  11. data.raw[entityType][entityName].loot = {}
  12. end
  13. table.insert(data.raw[entityType][entityName].loot, {item = itemName, probability = probability, count_min = countMin, count_max = countMax})
  14. end
  15. end
  16. end
  17. local function generate_localized_name(basestring, name)
  18. if string.sub(name, 1, 5) == "tree-" then
  19. --Standard tree-xx and tree-xx-color naming
  20. local number = string.sub(name, 6, 7)
  21. local color = string.gsub(string.sub(name, 9), "^%l", string.upper)
  22. if color ~= "" then
  23. color = color .. " "
  24. end
  25. return {basestring, color, "Tree", number}
  26. elseif string.sub(name, 1, 5) == "dry-t" then
  27. --Dry Tree
  28. return {basestring, "Dry ", "Tree", ""}
  29. elseif string.sub(name, 1, 5) == "dry-h" then
  30. --Dry Hairy Tree
  31. return {basestring, "Dry Hairy ", "Tree", ""}
  32. elseif string.sub(name, -5) == "coral" then
  33. --Base game coral
  34. local color = string.gsub(string.sub(name, 1, -7), "^%l", string.upper)
  35. if color ~= "" then
  36. color = color .. " "
  37. end
  38. return {basestring, color, "Coral", ""}
  39. elseif string.sub(name, 1, 6) == "coral-" then
  40. --Coral from Alien Biomes mod
  41. local number = string.sub(name, -2)
  42. local color = string.gsub(string.sub(name, 7, -4), "^%l", string.upper)
  43. if color ~= "" then
  44. color = color .. " "
  45. end
  46. return {basestring, color, "Coral", number}
  47. end
  48. return {basestring, name, "", ""}
  49. end
  50.  
  51. --[[local function AddResToEntity(entityType, entityName, itemName, amount)
  52. if data.raw[entityType] ~= nil then
  53. if data.raw[entityType][entityName] ~= nil then
  54. if data.raw[entityType][entityName].minable.results == nil then
  55. data.raw[entityType][entityName].minable.results = {{data.raw[entityType][entityName].minable.result, data.raw[entityType][entityName].minable.count}}
  56. data.raw[entityType][entityName].minable.result=nil
  57. data.raw[entityType][entityName].minable.count=nil
  58. end
  59. table.insert(data.raw[entityType][entityName].minable.results, {itemName, amount})
  60. end
  61. end
  62. end]]
  63.  
  64. for i, tree_data in pairs(data.raw["tree"]) do
  65. --local type_number = string.format("%02d", tree_data.type)
  66. --local type_name = "tree-" .. type_number
  67.  
  68. local name = i
  69.  
  70. if not string.match(name, "termite") then -- fix
  71.  
  72. if string.find(name, "dead-") == nil and string.find(name, "planted-sapling") == nil then
  73. local saplingname = generate_localized_name("item-name.sapling", name)
  74. local seedsname = generate_localized_name("item-name.seeds", name)
  75. data:extend(
  76. {--[[
  77. {
  78. type = "tree",
  79. name = name,
  80. icon = "__base__/graphics/icons/" .. type_name .. ".png",
  81. flags = {"placeable-neutral", "placeable-off-grid", "breaths-air"},
  82. minable =
  83. {
  84. mining_particle = "wooden-particle",
  85. mining_time = 2,
  86. results = {{"raw-wood", 4},{name.."-seeds", 2}}
  87. },
  88. corpse = type_name .. "-stump",
  89. remains_when_mined = type_name .. "-stump",
  90. emissions_per_tick = -0.0005,
  91. max_health = 50,
  92. collision_box = {{-0.4, -0.4}, {0.4, 0.4}},
  93. selection_box = {{-0.9, -2.2}, {0.9, 0.6}},
  94. drawing_box = tree_data.drawing_box,
  95. subgroup = "trees",
  96. order = "a[tree]-a[regular]-" .. order,
  97. vehicle_impact_sound = { filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0 },
  98. autoplace = autoplace_settings(tree_data.autoplace_peaks, tree_data.autoplace_extra),
  99. variations = tree_variations,
  100. colors = tree_data.colors
  101. },]]
  102. {
  103. type = "item",
  104. name = name.."-sapling",
  105. localised_name = saplingname,
  106. icon = tree_data.icon,
  107. flags = {"goes-to-quickbar"},
  108. subgroup = "trees",
  109. order = "a-c["..name.."]",
  110. place_result = name,
  111. stack_size = 100
  112. },
  113. {
  114. type = "item",
  115. name = name.."-seeds",
  116. localised_name = seedsname,
  117. icon = "__base__/graphics/icons/root-a.png",
  118. flags = {"goes-to-main-inventory"},
  119. subgroup = "trees",
  120. order = "a-c["..name.."]",
  121. fuel_category = "chemical",
  122. fuel_value = "0.8MJ",
  123. fuel_acceleration_multiplier = 0.8,
  124. fuel_top_speed_multiplier = 0.8,
  125. stack_size = 500
  126. },
  127. {
  128. type = "recipe",
  129. name = name.."-sapling",
  130. localised_name = saplingname,
  131. category = "arborium",
  132. enabled = true,
  133. hidden = true,
  134. energy_required = settings["arborium-tree-time"].value or 30,
  135. ingredients =
  136. {
  137. {name.."-seeds", 1}
  138. },
  139. result=name.."-sapling",
  140. icon = tree_data.icon,
  141. subgroup = "trees",
  142. --order = "a[oil-processing]-a[basic-oil-processing]"
  143. },
  144. {
  145. type = "recipe",
  146. name = "mulch-" .. name,
  147. localised_name = generate_localized_name("recipe-name.mulching", name),
  148. enabled = true,
  149. hidden = true,
  150. category = "mulchening",
  151. energy_required = settings["arborium-mulch-time"].value or 10,
  152. ingredients =
  153. {
  154. {name.."-sapling", 1}
  155. },
  156. results=
  157. {
  158. {type = "item", name = "raw-wood", amount_min = settings['arborium-min-wood'].value or 3, amount_max = settings['arborium-max-wood'].value or 4},
  159. {type = "item", name = name.."-seeds", amount_min = settings['arborium-min-seed'].value or 1, amount_max = settings['arborium-max-seed'].value or 3}
  160. },
  161. main_product="raw-wood",
  162. subgroup = "trees",
  163. --order = "a[oil-processing]-a[basic-oil-processing]"
  164. },
  165. --[[
  166. {
  167. type = "recipe",
  168. name = name.."-seeds-to-wood",
  169. category = "smelting",
  170. enabled = true,
  171. hidden = true,
  172. energy_required = 2,
  173. ingredients =
  174. {
  175. {name.."-seeds", 4}
  176. },
  177. result = "wood"
  178. }
  179. ]]
  180. })
  181. AddLootToEntity("tree",name,name.."-seeds",.5,1,settings['arborium-tree-seed'].value or 2)
  182. if tree_data.minable.results then
  183. table.insert(data.raw["tree"][i].minable.results, {name.."-seeds", settings['arborium-tree-seed'].value or 2})
  184. else
  185. if data.raw.tree[i].minable then
  186. if data.raw.tree[i].minable.result then
  187. data.raw.tree[i].minable=
  188. {
  189. mining_particle = "wooden-particle",
  190. mining_time = data.raw.tree[i].minable.mining_time or 2,
  191. results = {{data.raw.tree[i].minable.result, data.raw.tree[i].minable.count},{name.."-seeds", settings['arborium-tree-seed'].value or 2}}
  192. }
  193. else
  194. data.raw.tree[i].minable=
  195. {
  196. mining_particle = "wooden-particle",
  197. mining_time = data.raw.tree[i].minable.mining_time or 2,
  198. results = {{name.."-seeds", settings['arborium-tree-seed'].value or 2}}
  199. }
  200. end
  201. end
  202. end
  203. end
  204. end
  205. end
Advertisement
Add Comment
Please, Sign In to add comment