Skip to content

Commit

Permalink
Refactoring, localization, overlay setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetabite committed Oct 17, 2020
1 parent 3d6a928 commit 4bcad35
Show file tree
Hide file tree
Showing 14 changed files with 198 additions and 148 deletions.
28 changes: 27 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
---------------------------------------------------------------------------------------------------
Version: 0.9.2
Date: 17.10.2020
Features:
- Added german localization for Informatron intergration
- Added option to disable overlay
Changes:
- Changed some localizations
- Lowered volume of spice accelarted heartbeat/breathing
Optimizations:
- Checked for validity of entities and forces
Bugfixes:
- Fixed callback calling methods of other interfaces, that either no longer exist or name has changed
- Fixed crash when using mod without Kux Running

---------------------------------------------------------------------------------------------------
Version: 0.9.1
Date: 16.10.2020
Changes:
- Removed a debug print
Bugfixes:
- Fixed callback for spice influence

---------------------------------------------------------------------------------------------------
Version: 0.9.0
Date: 15.10.2020
Changes:
Features:
- Added interface for getting a certain players spice status
Changes:
- Rewrote most of the player regarding code, you can still play in existing worlds, but the addiction system has been resetted
Optimizations:
- Optimised codebase, should be more performant and accurate now
Bugfixes:
- Fixed crash due to an empty table when killed by alien
Expand Down Expand Up @@ -45,6 +70,7 @@ Date: 12.10.2020
- Added effect to speed up manual crafting modifier when using spice
Changes:
- Reorganized the mods player table
Optimizations:
- Split interface into smaller interfaces (specialization)
Bugfixes:
- Fixed crash when using spice in a new game
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nauvis-melange",
"version": "0.9.0",
"version": "0.9.2",
"title": "Nauvis Melange",
"author": "Zetabite",
"factorio_version": "0.18",
Expand Down
16 changes: 16 additions & 0 deletions locale/de/informatron.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[nauvis-melange]
menu_nauvis-melange=[img=fluid/spice-gas]Nauvis Melange
title_nauvis-melange=Nauvis Melange
text_welcome=Willkommen zur Nauvis Melange Mod. Um anzufangen [img=item/spice] __ITEM__spice__ zu produzieren, erforsche [img=technology/spice-processing] __ITEM__spice__ Produktion.

text_spice-processing=Um [img=item/spice] __ITEM__spice__ zu bekommen, musst du zuerst ein __ENTITY__worm-hole__ finden. Dieses kannst du erzeugen in dem du einen Wurm tötest oder eine __ITEM__sandtrout__ platzierst. Sehr selten kannst du es auch einfach mit Glück finde.\nDanach musst du darauf einen [img=item/water-injector-proxy] __ENTITY__water-injector__ platzieren, um das Loch mit Wasser zu füllen. Sobald es voll ist, wird der __ENTITY__water-injector__ explodieren und hinterlässt die __ITEM__pre-spice-mass__. Diese kannst du dann einfach abbauen.
menu_spice-processing=[img=item/spice] __ITEM__spice__ Produktion
title_spice-processing=__ITEM__spice__ Produktion

text_alien-breeding=Aliens zu züchten ist ziemlich einfach. Sobald du es erstmal erforscht hast, kannst du ein [img=item/alien-probe] __ITEM__alien-probe__ erstellen. Dieses benutzt du dann nahe in Gegenwart eines Aliens, um eine Probe ihres Bluts zu erhalten. Dieses Blut kannst du dann in der __ENTITY__alien-growth-chamber__ benutzen um Alien Larven zu züchten.
menu_alien-breeding=[img=item/alien-growth-chamber] Aliens züchten
title_alien-breeding=Aliens züchten

text_spacing-guild=Um Navigatoren auszubilden, brauchst du ein [img=technology/spacing-guild] __ENTITY__spacing-guild__n Gebäude. Dieses wirch auch benötigt um Raketen in den Orbit zu bringen, das sie Kontrolle über die Raumfahrt haben. Die [img=item/spacing-guild] __ENTITY__spacing-guild__ braucht Massen an __ITEM__spice__ gas um richtig zu funktionieren, sei vorbereitet.
menu_spacing-guild=[img=technology/spacing-guild] Die __ENTITY__spacing-guild__
title_spacing-guild=Die __ENTITY__spacing-guild__
2 changes: 2 additions & 0 deletions locale/de/nauvis-melange.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ spice-evolution-factor=__ITEM__spice__ Evolutions-Faktor
spice-direct-evolution-level=__ITEM__spice__ induzierte Stufe
spice-evolve-neighbours=Erlaube Evolution des Nachbarn
spice-evolve-neighbours-radius=Evolutions Radius
spice-overlay=Zeige __ITEM__spice__-Overlay

[mod-setting-description]
spice-evolution-factor=Immer wenn ein Alien ein Objekt zerstört, das __ITEM__spice__ im Inventar hat, wird der Evolutions-Faktor mit diesem Faktor multipliziert und als neuer Evolutions-Fackor gesetzt. Setze auf 1.0 um dies aus zu schalten.
spice-direct-evolution-level=Anzahl an Evolutions Stufen die ein Alien aufsteigt wenn es etwas tötet oder zerstört das __ITEM__spice__ enthält. 0, wenn keins aufsteigen soll, 4 wenn alle Nachbarn auf max. aufsteigen sollen.
spice-evolve-neighbours=Entscheidet ob Nachbarn des Aliens entwickelt werden, wenn es __ITEM__spice__ findet.
spice-evolve-neighbours-radius=Radius in dem Aliens als Nachbarn gesehen werden.
spice-overlay=Zeigt das __ITEM__spice__-Overlay (Blau-Transparent)

[nauvis-melange]
guild-approval-message=Die __ENTITY__spacing-guild__ erlaubt den __ENTITY__rocket__n-Start.
Expand Down
6 changes: 3 additions & 3 deletions locale/en/informatron.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ title_nauvis-melange=Nauvis Melange
text_welcome=Welcome to the Nauvis Melange mod. To get started on producing [img=item/spice] __ITEM__spice__, research [img=technology/spice-processing] __ITEM__spice__ processing.

text_spice-processing=To get hold of the [img=item/spice] __ITEM__spice__ you need to find a __ENTITY__worm-hole__, which you can create by killing a worm or placing a __ITEM__sandtrout__, or find one by sheer luck.\nAfter this you need to place a [img=item/water-injector-proxy] __ENTITY__water-injector__ on it and fill the hole with water. Once its full the __ENTITY__water-injector__ will explode, leaving the __ITEM__pre-spice-mass__ behind. This you can then simply mine.
menu_spice-processing=[img=item/spice] Spice processing
title_spice-processing=Spice processing
menu_spice-processing=[img=item/spice] __ITEM__spice__ processing
title_spice-processing=__ITEM__spice__ processing

text_alien-breeding=Breeding aliens is rather easy. Once researched, you can craft an [img=item/alien-probe] __ITEM__alien-probe__, which you then use near an alien to get a sample of their blood. This blood is then used in the __ENTITY__alien-growth-chamber__ to grow an alien leech.
menu_alien-breeding=[img=item/alien-growth-chamber] Alien breeding
title_alien-breeding=Alien breeding

text_spacing-guild=To create navigators for diverse uses, you require a [img=technology/spacing-guild] __ENTITY__spacing-guild__ building. Additionaly it is needed to launch a rocket, as they control space travel. The [img=item/spacing-guild] __ENTITY__spacing-guild__ requires massive amounts of __ITEM__spice__ gas to function.
text_spacing-guild=To create navigators for diverse uses, you require a [img=technology/spacing-guild] __ENTITY__spacing-guild__ building. Additionaly it is needed to launch a rocket, as they control space travel. The [img=item/spacing-guild] __ENTITY__spacing-guild__ requires massive amounts of __ITEM__spice__ gas to function, be prepared.
menu_spacing-guild=[img=technology/spacing-guild] Spacing guild
title_spacing-guild=Spacing guild
4 changes: 3 additions & 1 deletion locale/en/nauvis-melange.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ water-injector=Fills __ENTITY__worm-hole__s with water, to grow __ITEM__pre-spic
worm-hole=Place a __ENTITY__water-injector__ on it to fill it with water, to grow __ITEM__pre-spice-mass__

[fluid-name]
spice-gas=Spice gas
spice-gas=__ITEM__spice__ gas

[item-name]
alien-probe=Alien probe
Expand Down Expand Up @@ -53,12 +53,14 @@ spice-evolution-factor=__ITEM__spice__ evolution factor
spice-direct-evolution-level=__ITEM__spice__ induced level
spice-evolve-neighbours=Allow neighbours evolution
spice-evolve-neighbours-radius=Evolution radius
spice-overlay=Shows __ITEM__spice__-overlay

[mod-setting-description]
spice-evolution-factor=Whenever an alien destroys an object with melange, this factor will be multiplied with the current evolution factor and set to the new evolution factor. Set to 1.0 to disable this behavior.
spice-direct-evolution-level=Amount of levels an alien is evolved to when directly hitting a __ITEM__spice__ source. 0 if no alien shall level up, 4 if even the neighbouring aliens shall be evolved to max. level.
spice-evolve-neighbours=Determines if neighbouring aliens should be evolved if an alien finds __ITEM__spice__.
spice-evolve-neighbours-radius=Radius in which aliens are considered neighbours
spice-overlay=Shows __ITEM__spice__-overlay (blue transparent)

[nauvis-melange]
guild-approval-message=The __ENTITY__spacing-guild__ allows the __ENTITY__rocket__ to be launched.
Expand Down
2 changes: 1 addition & 1 deletion prototypes/entity/machines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local blank = {
height = 64,
}

function spacing_guild_fluid_box(production_type, position)
spacing_guild_fluid_box = function(production_type, position)
local base_level = {['input'] = -1, ['output'] = 1}
return {
filter = 'spice-gas',
Expand Down
2 changes: 1 addition & 1 deletion prototypes/item/capsule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ data:extend({
sound = {
{
filename = '__base__/sound/heartbeat.ogg',
volume = 1.0
volume = 0.75
}
},
},
Expand Down
91 changes: 45 additions & 46 deletions scripts/control/aliens.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function created_entity(event)
created_entity = function(event)
local entity = event.entity
if entity.name == 'alien-probe-proxy' then
if entity and entity.valid and entity.name == 'alien-probe-proxy' then
local surface = entity.surface
local position = entity.position
local radius = 5
local alien = surface.find_entities_filtered({type = 'unit', position = position, radius = radius, force = 'enemy', limit = 1})
if alien[1] then
if alien[1] and alien[1].valid then
local aliens_table = global.aliens
alien = alien[1]
local sample = nil
Expand All @@ -14,8 +14,8 @@ function created_entity(event)
elseif aliens_table.reverse['worm-turret'][alien.name] then
sample = { name = 'worm-sample', count = 1 }
end
if (sample) then
if (event.source) then
if sample then
if event.source then
local player = event.source
local inventory = player.get_main_inventory()
if inventory.can_insert(sample) then
Expand All @@ -29,61 +29,61 @@ function created_entity(event)
end
end

function destroyed_entity(event)
destroyed_entity = function(event)
local cause = event.cause
local entity = event.entity
if (cause) then
if (entity) then
if entity.type == 'turret' and string.match(entity.name, 'worm') then
create_worm_hole(entity)
else
spice_effects(cause, entity)
end
if cause and cause.valid and entity and entity.valid then
if entity.type == 'turret' and string.match(entity.name, 'worm') then
create_worm_hole(entity)
else
spice_effects(cause, entity)
end
end
end

function create_worm_hole(entity)
create_worm_hole = function(entity)
local surface = entity.surface
local pos = entity.position
pos = surface.find_non_colliding_position('worm-hole', pos, 2, 0.5, true)
if (pos) then
surface.create_entity({ name = 'worm-hole', position = pos })
local position = entity.position
position = surface.find_non_colliding_position('worm-hole', position, 2, 0.5, true)
if position then
surface.create_entity({ name = 'worm-hole', position = position })
end
end

function spice_effects(cause, victim)
spice_effects = function(cause, victim)
cause = is_spice_collector(cause, victim)
if cause then
if cause and cause.valid then
-- in case we later want to scale effect based on this
local spice_amount = has_spice_in_fluidbox(victim) or has_spice_in_inventory(victim)
if spice_amount then
local spice_settings = {
['spice-evolution-factor'] = settings.global['spice-evolution-factor'].value,
['spice-direct-evolution-level'] = settings.global['spice-direct-evolution-level'].value,
['spice-evolve-neighbours'] = settings.global['spice-evolve-neighbours'].value,
['spice-evolve-neighbours-radius'] = settings.global['spice-evolve-neighbours-radius'].value
}
local force = cause.force
force.evolution_factor = force.evolution_factor * spice_settings['spice-evolution-factor']
cause = evolve_alien(cause, spice_settings['spice-direct-evolution-level'])
apply_spice_to_alien(cause)
if spice_settings['spice-evolve-neighbours'] then
local surface = cause.surface
local position = cause.position
local aliens = surface.find_entities_filtered({ name = global.aliens.names, position = position, radius = spice_settings['spice-evolve-neighbours-radius'], force = 'enemy'})
for _, alien in pairs(aliens) do
if alien ~= cause then evolve_alien(alien, spice_settings['spice-direct-evolution-level'] - 1) end
if force.valid and force.name == 'enemy' then
local spice_settings = {
['spice-evolution-factor'] = settings.global['spice-evolution-factor'].value,
['spice-direct-evolution-level'] = settings.global['spice-direct-evolution-level'].value,
['spice-evolve-neighbours'] = settings.global['spice-evolve-neighbours'].value,
['spice-evolve-neighbours-radius'] = settings.global['spice-evolve-neighbours-radius'].value
}
force.evolution_factor = force.evolution_factor * spice_settings['spice-evolution-factor']
cause = evolve_alien(cause, spice_settings['spice-direct-evolution-level'])
apply_spice_to_alien(cause)
if spice_settings['spice-evolve-neighbours'] then
local surface = cause.surface
local position = cause.position
local aliens = surface.find_entities_filtered({ name = global.aliens.names, position = position, radius = spice_settings['spice-evolve-neighbours-radius'], force = 'enemy'})
for _, alien in pairs(aliens) do
if alien ~= cause then evolve_alien(alien, spice_settings['spice-direct-evolution-level'] - 1) end
end
end
end
end
end
end

function has_spice_in_fluidbox(victim)
has_spice_in_fluidbox = function(victim)
if victim.type ~= 'character' then
if (victim.fluidbox) then
local fluidbox = victim.fluidbox
local fluidbox = victim.fluidbox
if fluidbox and fluidbox.valid then
for i = 1, #fluidbox, 1 do
if fluidbox.get_locked_fluid(i) == 'spice-gas' then
return fluidbox.get_capacity(i)
Expand All @@ -94,7 +94,7 @@ function has_spice_in_fluidbox(victim)
return false
end

function has_spice_in_inventory(victim)
has_spice_in_inventory = function(victim)
local inventory = nil
if victim.type == 'car' then
inventory = victim.get_inventory(defines.inventory.car_trunk)
Expand All @@ -121,19 +121,18 @@ function has_spice_in_inventory(victim)
return false
end

function evolve_alien(alien, steps)
evolve_alien = function(alien, steps)
local next_level = get_next_level(alien.name, steps)
if next_level ~= alien.name then
local surface = alien.surface
local position = alien.position
local force = alien.force
alien.destroy()
alien = surface.create_entity({ name = next_level, position = position, force = force})
alien = surface.create_entity({ name = next_level, position = position, force = 'enemy'})
end
return alien
end

function get_next_level(name, steps)
get_next_level = function(name, steps)
local aliens_table = global.aliens
for type_name, entry in pairs(aliens_table.dict) do
if aliens_table.reverse[type_name][name] then
Expand All @@ -146,7 +145,7 @@ function get_next_level(name, steps)
return name
end

function apply_spice_to_alien(alien)
apply_spice_to_alien = function(alien)
local surface = alien.surface
local position = alien.position
surface.create_entity({ name = 'spice-speed-sticker', target = alien, position = position })
Expand All @@ -155,15 +154,15 @@ function apply_spice_to_alien(alien)
end

-- only allows melee units to collect spice
function is_spice_collector(cause, victim)
is_spice_collector = function(cause, victim)
local aliens_table = global.aliens
if aliens_table.melee[cause.name] then
return cause
else
local surface = victim.surface
local position = victim.position
local brutus = surface.find_entities_filtered({name = aliens_table.names, position = position, radius = 1, force = 'enemy', limit = 1})
if (brutus) then return brutus end
if brutus and brutus.valid then return brutus end
end
return false
end
Expand Down
13 changes: 6 additions & 7 deletions scripts/control/forces.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
local config = require('scripts.config')

local VICTORY_SPICE_AMOUNT = config.VICTORY_SPICE_AMOUNT
local VICTORY_CHECK_TICK = config.VICTORY_CHECK_TICK

function force_created(event)
force_created = function(event)
local force_index = event.force.index
global.forces[force_index] = config.default.forces
end

function forces_merged(event)
forces_merged = function(event)
local force_table = global.forces
local source_index = event.source_index
local force_index = event.destination.index
Expand All @@ -18,11 +17,11 @@ function forces_merged(event)
force_table[source_index] = nil
end

function force_reset(event)
force_reset = function(event)
global.forces[event.force.index] = config.default.forces
end

function checkSpiceVictory()
checkSpiceVictory = function()
for force_index, entry in pairs(global.forces) do
if entry.spice_shipped >= VICTORY_SPICE_AMOUNT then
if remote.interfaces['kr-intergalactic-transceiver'] and remote.interfaces['kr-intergalactic-transceiver']['set_no_victory'] then
Expand All @@ -34,7 +33,7 @@ function checkSpiceVictory()
end
end

function rocket_launched(event)
rocket_launched = function(event)
local force_table = global.forces
local force_index = event.rocket.force.index
local spice_count = event.rocket.get_inventory(defines.inventory.rocket).get_item_count('spice')
Expand All @@ -53,7 +52,7 @@ lib.events = {
}

lib.on_nth_tick = {
[VICTORY_CHECK_TICK] = function()
[config.VICTORY_CHECK_TICK] = function()
checkSpiceVictory()
end
}
Expand Down
Loading

0 comments on commit 4bcad35

Please sign in to comment.