more-descriptions/data-final-fixes.lua

changeset 16
2cdb59ae5fcf
parent 7
023ee666a3d6
child 17
df60e9144d82
equal deleted inserted replaced
15:9dba62aa8083 16:2cdb59ae5fcf
1 ---@type data.FeatureFlags
2 feature_flags = feature_flags
3
1 local function seconds(x) 4 local function seconds(x)
2 return {"time-symbol-seconds", tostring(x)} 5 return {"time-symbol-seconds", tostring(x)}
3 end 6 end
4 7
5 local function build_new_description(main_description, new_descriptions) 8 local energy_zero_table = {
6 local new_localised_description = { 9 ["0W"] = 1,
7 "", 10 ["0kW"] = 1,
8 main_description, 11 ["0MW"] = 1,
9 } 12 ["0GW"] = 1,
10 for i, k in pairs(new_descriptions) 13 ["0TW"] = 1,
14 }
15
16 ---@type table<string, 1>
17 local recipes_that_have_productivity_research = {}
18
19 for _, technology in pairs(data.raw["technology"] or {})
20 do
21 for _, effect in pairs(technology.effects or {})
11 do 22 do
12 if i ~= 1 23 if effect.type == "change-recipe-productivity"
13 then 24 then
14 table.insert(new_localised_description, "\n") 25 recipes_that_have_productivity_research[effect.recipe] = 1
15 end 26 end
16 table.insert(new_localised_description, k) 27 end
17 end 28 end
18 return new_localised_description 29
30 ---@param x string
31 local function energy_zero(x)
32 return x == nil or energy_zero_table[x]
33 end
34
35 ---@param x LocalisedString
36 -- localised string containing too many entries? snap it into many pieces and catenate them
37 local function snap(x)
38 if type(x) == "table" and #x > 20 and x[1] == ""
39 then
40 local max_per_part = math.ceil((#x - 1) / 18)
41 local result = {""}
42 local segment = {""}
43 for k, v in pairs(x)
44 do
45 if k > 1
46 then
47 if #segment >= max_per_part + 1
48 then
49 table.insert(result, snap(segment))
50 segment = {""}
51 end
52 table.insert(segment, v)
53 end
54 end
55 if #segment > 1
56 then
57 table.insert(result, snap(segment))
58 end
59 return result
60 else
61 return x
62 end
19 end 63 end
20 64
21 local item_categories = 65 local item_categories =
22 { 66 {
23 "item", 67 "item",
171 "market", 215 "market",
172 "capture-robot", 216 "capture-robot",
173 "solar-panel", 217 "solar-panel",
174 } 218 }
175 219
220 -- Find all entity categories that contain prototypes that can freeze.
221 -- If a prototype in such a category cannot freeze, that's worth pointing out.
222 -- However, it's not worth pointing out that the steel chest cannot freeze,
223 -- since no container freezes (in vanilla anyway).
224 local freezable_entity_categories = {}
225 if feature_flags.freezing
226 then
227 for _, category in pairs(entity_categories)
228 do
229 for _, entity in pairs(data.raw[category] or {})
230 do
231 if not energy_zero(entity.heating_energy)
232 then
233 freezable_entity_categories[entity.type] = 1
234 break
235 end
236 end
237 end
238 end
239
176 local function find_entity(name) 240 local function find_entity(name)
177 for _, entity_category in pairs(entity_categories) 241 for _, entity_category in pairs(entity_categories)
178 do 242 do
179 if data.raw[entity_category] and data.raw[entity_category][name] 243 if data.raw[entity_category] and data.raw[entity_category][name]
180 then 244 then
182 end 246 end
183 end 247 end
184 return nil 248 return nil
185 end 249 end
186 250
251 -- @type table<string, string>
187 local ammo_categories = {} 252 local ammo_categories = {}
188 253
189 for _, ammo in pairs(data.raw.ammo) 254 for _, ammo in pairs(data.raw.ammo)
190 do 255 do
191 if not ammo_categories[ammo.ammo_category] 256 if not ammo_categories[ammo.ammo_category]
197 ammo_categories[ammo.ammo_category] = ammo_categories[ammo.ammo_category].."[item="..ammo.name.."]" 262 ammo_categories[ammo.ammo_category] = ammo_categories[ammo.ammo_category].."[item="..ammo.name.."]"
198 elseif string.sub(ammo_categories[ammo.ammo_category], -3, -1) ~= "..." 263 elseif string.sub(ammo_categories[ammo.ammo_category], -3, -1) ~= "..."
199 then 264 then
200 ammo_categories[ammo.ammo_category] = ammo_categories[ammo.ammo_category] .. "..." 265 ammo_categories[ammo.ammo_category] = ammo_categories[ammo.ammo_category] .. "..."
201 end 266 end
267 end
268
269 ---@param proto data.Prototype
270 ---@param tooltip_field LocalisedString
271 local function generic_add_description(proto, tooltip_field)
272 if not proto.custom_tooltip_fields
273 then
274 proto.custom_tooltip_fields = {}
275 end
276 table.insert(proto.custom_tooltip_fields, tooltip_field)
202 end 277 end
203 278
204 for _, item_type in pairs(item_categories) 279 for _, item_type in pairs(item_categories)
205 do 280 do
206 for _, item in pairs(data.raw[item_type] or {}) 281 for _, item in pairs(data.raw[item_type] or {})
207 do 282 do
208 local new_descriptions = {}
209 local recycling_recipe = data.raw.recipe[item.name.."-recycling"] 283 local recycling_recipe = data.raw.recipe[item.name.."-recycling"]
210 284
211 local add_description = function(x) 285 ---@param tooltip_field data.CustomTooltipField
212 table.insert(new_descriptions, x) 286 local function add_description(tooltip_field)
287 generic_add_description(item, tooltip_field)
213 end 288 end
214 289
215 local add_ammo_from_attack_parameters = function(attack_parameters) 290 local add_ammo_from_attack_parameters = function(attack_parameters)
216 if attack_parameters.ammo_category and ammo_categories[attack_parameters.ammo_category] 291 if attack_parameters.ammo_category and ammo_categories[attack_parameters.ammo_category]
217 then 292 then
218 add_description{"more-descriptions-mod.gun-accepts-ammo", ammo_categories[attack_parameters.ammo_category]} 293 add_description{
294 name = {"more-descriptions-mod.gun-accepts-ammo"},
295 value = ammo_categories[attack_parameters.ammo_category]}
219 end 296 end
220 for _, category in pairs(attack_parameters.ammo_categories or {}) 297 for _, category in pairs(attack_parameters.ammo_categories or {})
221 do 298 do
222 if ammo_categories[category] 299 if ammo_categories[category]
223 then 300 then
224 add_description{"more-descriptions-mod.gun-accepts-ammo", ammo_categories[category]} 301 add_description{
302 name = {"more-descriptions-mod.gun-accepts-ammo"},
303 value = ammo_categories[category]}
225 end 304 end
226 end 305 end
227 end 306 end
228 307
229 if recycling_recipe ~= nil 308 if recycling_recipe ~= nil
232 for _, result in pairs(recycling_recipe.results) 311 for _, result in pairs(recycling_recipe.results)
233 do 312 do
234 table.insert(recycling_results, "[img="..result.type.."."..result.name.."]") 313 table.insert(recycling_results, "[img="..result.type.."."..result.name.."]")
235 end 314 end
236 add_description{ 315 add_description{
237 "more-descriptions-mod.recycling", 316 name = {"more-descriptions-mod.recycling"},
238 seconds(recycling_recipe.energy_required), 317 value = {
239 recycling_results 318 "more-descriptions-mod.recycling-results",
319 seconds(recycling_recipe.energy_required),
320 snap(recycling_results),
321 },
240 } 322 }
241 end 323 end
242 324
243 if mods["promethium-quality"] 325 if mods["promethium-quality"]
244 then 326 then
245 local refining_recipe = data.raw.recipe[item.name.."-refining"] 327 local refining_recipe = data.raw.recipe[item.name.."-refining"]
246 if refining_recipe ~= nil 328 if refining_recipe ~= nil
247 then 329 then
248 add_description{ 330 add_description{
249 "more-descriptions-mod.refining-cost", 331 name = {"more-descriptions-mod.refining-cost"},
250 tostring(refining_recipe.energy_required), 332 value = seconds(refining_recipe.energy_required),
251 } 333 }
252 elseif recycling_recipe ~= nil 334 elseif recycling_recipe ~= nil
253 then 335 then
254 add_description{"more-descriptions-mod.cannot-be-refined"} 336 add_description{
337 name = {"more-descriptions-mod.cannot-be-refined"},
338 value = ""}
255 end 339 end
256 end 340 end
257 341
258 if item.type == "ammo" and (item.reload_time or 0) > 0 342 if item.type == "ammo" and (item.reload_time or 0) > 0
259 then 343 then
260 add_description{ 344 add_description{
261 "more-descriptions-mod.reload-time", 345 name = {"more-descriptions-mod.reload-time"},
262 seconds(tostring(item.reload_time / 60.0)), 346 value = seconds(tostring(item.reload_time / 60.0)),
263 } 347 }
264 end 348 end
265 349
266 if item.type == "active-defense-equipment" and item.automatic 350 if item.type == "active-defense-equipment" and item.automatic
267 then 351 then
268 add_description{"more-descriptions-mod.fires-automatically"} 352 add_description{
353 name = {"more-descriptions-mod.fires-automatically"},
354 value = "",
355 }
269 end 356 end
270 357
271 if item.type == "armor" and item.provides_flight 358 if item.type == "armor" and item.provides_flight
272 then 359 then
273 add_description{"more-descriptions-mod.armor-provides-flight"} 360 add_description{
361 name = {"more-descriptions-mod.armor-provides-flight"},
362 value = "",
363 }
274 end 364 end
275 365
276 if item.type == "gun" 366 if item.type == "gun"
277 then 367 then
278 add_ammo_from_attack_parameters(item.attack_parameters) 368 add_ammo_from_attack_parameters(item.attack_parameters)
285 then 375 then
286 local cb = entity.collision_box 376 local cb = entity.collision_box
287 local width = math.ceil(cb[2][1] - cb[1][1]) 377 local width = math.ceil(cb[2][1] - cb[1][1])
288 local height = math.ceil(cb[2][2] - cb[1][2]) 378 local height = math.ceil(cb[2][2] - cb[1][2])
289 add_description{ 379 add_description{
290 "more-descriptions-mod.size", 380 name = {"more-descriptions-mod.entity-size"},
291 tostring(width), 381 value = {
292 tostring(height), 382 "more-descriptions-mod.size",
383 tostring(width),
384 tostring(height),
385 },
293 } 386 }
294 end 387 end
295 388
296 if entity.drops_full_belt_stacks 389 if entity.drops_full_belt_stacks
297 then 390 then
298 add_description{"more-descriptions-mod.drops-full-belt-stacks"} 391 add_description{
392 name = {"more-descriptions-mod.drops-full-belt-stacks"},
393 value = ""}
299 end 394 end
300 395
301 if entity.heat_buffer and entity.heat_buffer.specific_heat 396 if entity.heat_buffer and entity.heat_buffer.specific_heat
302 then 397 then
303 add_description{ 398 add_description{
304 "more-descriptions-mod.specific-heat", 399 name = {"more-descriptions-mod.specific-heat"},
305 entity.heat_buffer.specific_heat, 400 value = {
401 "more-descriptions-mod.energy-per-degrees-celsius",
402 entity.heat_buffer.specific_heat,
403 },
306 } 404 }
307 elseif entity.energy_source 405 elseif entity.energy_source
308 and entity.energy_source.type == "heat" 406 and entity.energy_source.type == "heat"
309 and entity.energy_source.specific_heat 407 and entity.energy_source.specific_heat
310 then 408 then
311 add_description{ 409 add_description{
312 "more-descriptions-mod.specific-heat", 410 name = {"more-descriptions-mod.specific-heat"},
313 entity.energy_source.specific_heat, 411 value = entity.energy_source.specific_heat,
314 } 412 }
315 end 413 end
316 414
317 if entity.is_military_target 415 if entity.is_military_target
318 then 416 then
319 add_description{"more-descriptions-mod.is-military-target"} 417 add_description{
418 name = {"more-descriptions-mod.is-military-target"},
419 value = "",
420 }
421 end
422
423 if not energy_zero(entity.heating_energy or "0W")
424 then
425 local value = entity.heating_energy
426 if entity.type == "underground-belt" or entity.type == "pipe-to-ground"
427 then
428 value = {"more-descriptions-mod.value-per-end", value}
429 end
430 add_description{
431 name = {"more-descriptions-mod.heating-energy"},
432 value = value,
433 }
434 elseif freezable_entity_categories[entity.type]
435 then
436 add_description{
437 name = {"more-descriptions-mod.no-heating-energy"},
438 value = "",
439 }
320 end 440 end
321 441
322 if entity.type == "agricultural-tower" 442 if entity.type == "agricultural-tower"
323 then 443 then
324 local cb = entity.collision_box 444 local cb = entity.collision_box
326 local w = (entity.growth_grid_tile_size or 3) 446 local w = (entity.growth_grid_tile_size or 3)
327 -- width of the "buffer" area around the agricultural tower 447 -- width of the "buffer" area around the agricultural tower
328 local z = (2 * w * math.ceil((W - w) / 2 / w)) + w 448 local z = (2 * w * math.ceil((W - w) / 2 / w)) + w
329 -- num of growth cells extending from the edges of the tower 449 -- num of growth cells extending from the edges of the tower
330 local r = math.floor(entity.radius) -- why is it double..? 450 local r = math.floor(entity.radius) -- why is it double..?
331 add_description{"more-descriptions-mod.agricultural-tower-num-inputs", 451 add_description{
332 tostring(entity.input_inventory_size) 452 name = {"more-descriptions-mod.agricultural-tower-num-inputs"},
333 } 453 value = tostring(entity.input_inventory_size)
334 add_description{"more-descriptions-mod.agricultural-tower-growth-cell-size", 454 }
335 tostring(w) 455 add_description{
336 } 456 name = {"more-descriptions-mod.agricultural-tower-growth-cell-size"},
337 add_description{"more-descriptions-mod.agricultural-tower-growth-cell-count", 457 value = {
338 tostring(4 * r * (r + (z / w))) 458 "more-descriptions-mod.size",
339 } 459 tostring(w),
340 add_description{"more-descriptions-mod.agricultural-tower-total-size", 460 tostring(w),
341 tostring(z + 2 * r * w) 461 }
462 }
463 add_description{
464 name = {"more-descriptions-mod.agricultural-tower-growth-cell-count"},
465 value = tostring(4 * r * (r + (z / w)))
466 }
467 total_size = tostring(z + 2 * r * w)
468 add_description{
469 name = {"more-descriptions-mod.agricultural-tower-total-size"},
470 value = {
471 "more-descriptions-mod.size",
472 total_size,
473 total_size,
474 },
342 } 475 }
343 elseif entity.type == "ammo-turret" 476 elseif entity.type == "ammo-turret"
344 then 477 then
345 if entity.energy_per_shot ~= nil 478 if entity.energy_per_shot ~= nil
346 then 479 then
347 add_description{"more-descriptions-mod.energy-per-shot-fired", 480 add_description{
348 entity.energy_per_shot} 481 name = {"more-descriptions-mod.energy-per-shot-fired"},
482 value = entity.energy_per_shot}
349 end 483 end
350 add_ammo_from_attack_parameters(entity.attack_parameters) 484 add_ammo_from_attack_parameters(entity.attack_parameters)
351 elseif entity.type == "beacon" 485 elseif entity.type == "beacon"
352 then 486 then
353 add_description{"more-descriptions-mod.beacon-supply-area-distance", 487 add_description{
354 tostring(entity.supply_area_distance) 488 name = {"more-descriptions-mod.beacon-supply-area-distance"},
489 value = tostring(entity.supply_area_distance)
355 } 490 }
356 elseif entity.type == "car" 491 elseif entity.type == "car"
357 then 492 then
358 local immunities = "" 493 local immunities = ""
359 if (entity.immune_to_tree_impacts or false) 494 if (entity.immune_to_tree_impacts or false)
368 then 503 then
369 immunities = immunities.."[entity=cliff]" 504 immunities = immunities.."[entity=cliff]"
370 end 505 end
371 if immunities ~= "" 506 if immunities ~= ""
372 then 507 then
373 add_description{"more-descriptions-mod.car-immune-to-impacts", immunities} 508 add_description{
509 name = {"more-descriptions-mod.car-immune-to-impacts"},value = immunities}
374 end 510 end
375 elseif entity.type == "constant-combinator" 511 elseif entity.type == "constant-combinator"
376 then 512 then
377 -- used by pushbutton mod 513 -- used by pushbutton mod
378 if (entity.pulse_duration or 0) > 60 514 if (entity.pulse_duration or 0) > 60
379 then 515 then
380 add_description{"more-descriptions-mod.constant-combinator-pulse-duration", 516 add_description{
381 seconds(entity.pulse_duration / 60.0)} 517 name = {"more-descriptions-mod.constant-combinator-pulse-duration"},
518 value = seconds(entity.pulse_duration / 60.0),
519 }
382 elseif (entity.pulse_duration or 0) > 0 520 elseif (entity.pulse_duration or 0) > 0
383 then 521 then
384 add_description{"more-descriptions-mod.constant-combinator-pulse-duration", 522 add_description{
385 {"more-descriptions-mod.ticks", tostring(entity.pulse_duration)}} 523 name = {"more-descriptions-mod.constant-combinator-pulse-duration"},
524 value = {
525 "more-descriptions-mod.ticks",
526 tostring(entity.pulse_duration),
527 },
528 }
386 end 529 end
387 elseif (entity.type == "container" or entity.type == "logistic-container") 530 elseif (entity.type == "container" or entity.type == "logistic-container")
388 then 531 then
389 if entity.inventory_type == "with_filters_and_bar" 532 if entity.inventory_type == "with_filters_and_bar"
390 then 533 then
391 add_description{"more-descriptions-mod.container-filters"} 534 add_description{
535 name = {"more-descriptions-mod.container-filters"},
536 value = "",
537 }
392 end 538 end
393 elseif entity.type == "cargo-wagon" 539 elseif entity.type == "cargo-wagon"
394 then 540 then
395 -- all cargo wagons support filters 541 -- all cargo wagons support filters
396 add_description{"more-descriptions-mod.container-filters"} 542 add_description{
543 name = {"more-descriptions-mod.container-filters"},
544 value = "",
545 }
397 elseif entity.type == "display-panel" 546 elseif entity.type == "display-panel"
398 then 547 then
399 add_description{"more-descriptions-mod.display-panel-max-text-width", 548 add_description{
400 tostring(entity.max_text_width or 400)} 549 name = {"more-descriptions-mod.display-panel-max-text-width"},
550 value = tostring(entity.max_text_width or 400),
551 }
401 elseif entity.type == "logistic-robot" or entity.type == "construction-robot" 552 elseif entity.type == "logistic-robot" or entity.type == "construction-robot"
402 then 553 then
403 if entity.speed_multiplier_when_out_of_energy > 0 554 if entity.speed_multiplier_when_out_of_energy > 0
404 then 555 then
405 add_description{"more-descriptions-mod.robot-speed-multiplier-when-out-of-energy", 556 add_description{
406 tostring(entity.speed_multiplier_when_out_of_energy * 100)} 557 name = {"more-descriptions-mod.robot-speed-multiplier-when-out-of-energy"},
558 value = tostring(entity.speed_multiplier_when_out_of_energy * 100),
559 }
407 else 560 else
408 add_description{"more-descriptions-mod.robot-crashes-when-out-of-energy"} 561 add_description{
562 name = {"more-descriptions-mod.robot-crashes-when-out-of-energy"},
563 value = "",
564 }
409 end 565 end
410 elseif entity.type == "inserter" 566 elseif entity.type == "inserter"
411 then 567 then
568 if entity.bulk
569 then
570 add_description{
571 name = {"more-descriptions-mod.inserter-bulk"},
572 value = tostring(entity.filter_count),
573 }
574 end
412 if entity.wait_for_full_hand 575 if entity.wait_for_full_hand
413 then 576 then
414 add_description{"more-descriptions-mod.inserter-wait-for-full-hand", 577 add_description{
415 tostring(entity.filter_count)} 578 name = {"more-descriptions-mod.inserter-wait-for-full-hand"},
579 value = "",
580 }
581 end
582 if entity.enter_drop_mode_if_held_stack_spoiled
583 then
584 add_description{
585 name = {"more-descriptions-mod.inserter-enters-drop-mode-if-held-stack-spoils"},
586 value = "",
587 }
416 end 588 end
417 elseif entity.type == "land-mine" 589 elseif entity.type == "land-mine"
418 then 590 then
419 add_description{"more-descriptions-mod.land-mine-timeout", 591 add_description{
420 seconds((entity.timeout or 120) / 60.0)} 592 name = {"more-descriptions-mod.land-mine-timeout"},
593 value = seconds((entity.timeout or 120) / 60.0),
594 }
421 elseif entity.type == "radar" 595 elseif entity.type == "radar"
422 then 596 then
423 if entity.connects_to_other_radars ~= false 597 if entity.connects_to_other_radars ~= false
424 then 598 then
425 add_description{"more-descriptions-mod.radar-connection"} 599 add_description{
600 name = {"more-descriptions-mod.radar-connection"},
601 value = "",
602 }
426 end 603 end
427 end 604 end
428 if entity.filter_count 605 if entity.filter_count
429 then 606 then
430 add_description{"more-descriptions-mod.filter-count", 607 add_description{
431 tostring(entity.filter_count)} 608 name = {"more-descriptions-mod.filter-count"},
609 value = tostring(entity.filter_count),
610 }
432 end 611 end
433 for _, flag in pairs(entity.flags or {}) 612 for _, flag in pairs(entity.flags or {})
434 do 613 do
435 if flag == "no-automated-item-insertion" 614 if flag == "no-automated-item-insertion"
436 then 615 then
437 table.insert(new_descriptions, {"more-descriptions-mod.no-automated-item-insertion"}) 616 add_description{
438 end 617 name = {"more-descriptions-mod.no-automated-item-insertion"},
439 end 618 value = "",
440 end 619 }
441 620 end
442 if #new_descriptions > 0 621 end
443 then
444 local main_description = item.localised_description
445 and {"", item.localised_description, "\n"}
446 or {
447 "?",
448 {"", {"entity-description."..item.name}, "\n"},
449 {"", {"item-description."..item.name}, "\n"},
450 ""
451 }
452 item.localised_description = build_new_description(main_description, new_descriptions)
453 end 622 end
454 end 623 end
455 end 624 end
456 625
457 for _, recipe in pairs(data.raw.recipe) 626 for _, recipe in pairs(data.raw.recipe)
458 do 627 do
459 local new_descriptions = {} 628 ---@param tooltip_field data.CustomTooltipField
460 629 local function add_description(tooltip_field)
630 generic_add_description(recipe, tooltip_field)
631 end
461 if recipe.allow_productivity 632 if recipe.allow_productivity
462 then 633 then
463 table.insert(new_descriptions, {"more-descriptions-mod.allows-productivity"}) 634 add_description{
464 end 635 name = {"more-descriptions-mod.allows-productivity"},
465 636 value = "",
466 if #new_descriptions > 0
467 then
468 local main_description = recipe.localised_description
469 and {"", recipe.localised_description, "\n"}
470 or {
471 "?",
472 {"", {"recipe-description."..recipe.name}, "\n"},
473 ""
474 } 637 }
475 recipe.localised_description = build_new_description(main_description, new_descriptions) 638 end
639
640 if recipes_that_have_productivity_research[recipe.name]
641 then
642 add_description{
643 name = {"more-descriptions-mod.recipe-has-productivity-research"},
644 value = "",
645 }
646 end
647
648 if recipe.result_is_always_fresh
649 then
650 add_description{
651 name = {"more-descriptions-mod.recipe-result-is-always-fresh"},
652 value = "",
653 }
654 end
655 if recipe.reset_freshness_on_craft
656 then
657 add_description{
658 name = {"more-descriptions-mod.recipe-result-freshness-reset"},
659 value = "",
660 }
476 end 661 end
477 end 662 end
478 663
479 -- Stuff mostly specific for entities that you don't place with items (like biters) 664 -- Stuff mostly specific for entities that you don't place with items (like biters)
480 for _, entity_category in pairs(entity_categories) 665 for _, entity_category in pairs(entity_categories)
481 do 666 do
482 for _, entity in pairs(data.raw[entity_category] or {}) 667 for _, entity in pairs(data.raw[entity_category] or {})
483 do 668 do
484 local new_descriptions = {} 669 ---@param tooltip_field data.CustomTooltipField
670 local function add_description(tooltip_field)
671 generic_add_description(entity, tooltip_field)
672 end
485 673
486 if entity.minable 674 if entity.minable
487 then 675 then
488 table.insert(new_descriptions, {"more-descriptions-mod.mining-time", 676 add_description{
489 seconds(entity.minable.mining_time)}) 677 name = {"more-descriptions-mod.mining-time"},
678 value = seconds(entity.minable.mining_time),
679 }
490 end 680 end
491 681
492 for _, flag in pairs(entity.flags or {}) 682 for _, flag in pairs(entity.flags or {})
493 do 683 do
494 if flag == "breaths-air" 684 if flag == "breaths-air"
495 then 685 then
496 table.insert(new_descriptions, {"more-descriptions-mod.breathes-air"}) 686 add_description{
687 name = {"more-descriptions-mod.breathes-air"},
688 value = "",
689 }
497 end 690 end
498 end 691 end
499 692
500 if entity.type == "unit-spawner" 693 if entity.type == "unit-spawner"
501 then 694 then
502 if (entity.time_to_capture or 0) > 0 695 if (entity.time_to_capture or 0) > 0
503 then 696 then
504 table.insert(new_descriptions, {"more-descriptions-mod.unit-spawner-time-to-capture", 697 add_description{
505 seconds(entity.time_to_capture / 60.0)}) 698 name = {"more-descriptions-mod.unit-spawner-time-to-capture"},
506 end 699 value = seconds(entity.time_to_capture / 60.0),
507 end 700 }
508 701 end
509 if #new_descriptions > 0 702 end
510 then 703 end
511 local main_description = entity.localised_description 704 end
512 and {"", entity.localised_description, "\n"} 705
513 or { 706 if feature_flags.space_travel
514 "?", 707 then
515 {"", {"entity-description."..entity.name}, "\n"}, 708 for _, category in pairs{"space-location", "planet"}
516 "" 709 do
517 } 710 for _, space_location in pairs(data.raw[category])
518 entity.localised_description = build_new_description(main_description, new_descriptions) 711 do
519 end 712 ---@param tooltip_field data.CustomTooltipField
520 end 713 local function add_description(tooltip_field)
521 end 714 generic_add_description(space_location, tooltip_field)
522 715 end
523 for _, space_location in pairs(data.raw["space-location"]) 716 ---@cast space_location data.SpaceLocationPrototype
524 do 717 local new_descriptions = {}
525 local new_descriptions = {} 718 if (space_location.fly_condition or false)
526 719 then
527 if (space_location.fly_condition or false) 720 add_description{
528 then 721 name = {"more-descriptions-mod.space-location-fly-condition"},
529 table.insert(new_descriptions, {"more-descriptions-mod.space-location-fly-condition"}) 722 value = "",
530 end 723 }
531 724 end
532 if space_location.auto_save_on_first_trip == false -- (nil=true) 725 if space_location.auto_save_on_first_trip == false -- (nil=true)
533 then 726 then
534 table.insert(new_descriptions, {"more-descriptions-mod.space-location-no-autosave"}) 727 add_description{
535 end 728 name = {"more-descriptions-mod.space-location-no-autosave"},
536 729 value = "",
537 if #new_descriptions > 0 730 }
538 then 731 end
539 local main_description = space_location.localised_description 732 end
540 and {"", space_location.localised_description, "\n"} 733 end
541 or { 734 end
542 "?",
543 {"", {"space-location-description."..space_location.name}, "\n"},
544 ""
545 }
546 space_location.localised_description = build_new_description(main_description, new_descriptions)
547 end
548 end

mercurial