Page 1 of 1

attempt to index global 'sounds' (a nil value)

Posted: Tue Jan 28, 2020 10:49 pm
by XIAIX
With 0.18.2, they added damaged_trigger_effect = hit_effects.entity()
to "C:\Program Files (x86)\Steam\steamapps\common\Factorio\data\base\prototypes\entity\demo-turrets.lua"

Well, I have a Gun turret mod that won't load now.

The mod has a control.lua that has these 2 lines:
local hit_effects = require ("prototypes.entity.demo-hit-effects")
local sounds = require("prototypes.entity.demo-sounds")

However, they don't seem to be working.

Is that control.lua file not pulling in the locals correctly?

Re: attempt to index global 'sounds' (a nil value)

Posted: Tue Jan 28, 2020 11:13 pm
by XIAIX
I changed this: local hit_effects = require ("prototypes.entity.demo-hit-effects")
to this: local hit_effects = game.prototype_entity["demo-hit-effects"]

and this: local sounds = require ("prototypes.entity.demo-sounds")
to this: local sounds = game.prototype_entity["demo-sounds"]

Still no go :(

Re: attempt to index global 'sounds' (a nil value)

Posted: Wed Jan 29, 2020 2:59 am
by Solinya
I think you're trying to reference the base mod's sound files, correct? If so, don't you have to point it at base? Without that, it's looking in your mod for a demo-sounds file.

From the breaking change thread:

Code: Select all

local sounds = require("__base__.prototypes.entity.demo-sounds")
This worked for me, but my mod was referencing sounds in the data stage.

Re: attempt to index global 'sounds' (a nil value)

Posted: Wed Jan 29, 2020 10:28 pm
by XIAIX
Well, that was it. Thank you!
Using "__base__." was what I needed. :D

Oh, I also took it out of the control.lua file and put it in the data.lua:

Code: Select all

local sounds = require("__base__.prototypes.entity.demo-sounds")
local hit_effects = require ("__base__.prototypes.entity.demo-hit-effects")
data:extend({
{
    type = "ammo-turret",
    name = "gun-turret",