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

Place to get help with not working mods / modding interface.
Post Reply
XIAIX
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Jan 28, 2020 10:43 pm
Contact:

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

Post 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?

XIAIX
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Jan 28, 2020 10:43 pm
Contact:

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

Post 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 :(

Solinya
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sun Mar 17, 2019 10:39 pm
Contact:

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

Post 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.

XIAIX
Manual Inserter
Manual Inserter
Posts: 3
Joined: Tue Jan 28, 2020 10:43 pm
Contact:

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

Post 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",

Post Reply

Return to “Modding help”