Page 1 of 1

Error when attempting to change loot of biter spawners

Posted: Sun Feb 05, 2017 2:08 am
by ATMunn
I'm trying to change the loot of the biter and spitter spawners to a new item in my mod. However, I'm getting an error saying "data.lua:3: syntax error near '-'"

Here's my data.lua:

Code: Select all

require("prototypes.item")

data.raw.demo-enemies["biter-spawner"].loot = 
{
    {
		{
			count_max = 3,
			count_min = 0,
			item = "alien-egg",
			probability = 0.5
		}
    }
}

data.raw.enemies["spitter-spawner"].loot = 
{
    {
		{
			count_max = 5,
			count_min = 1,
			item = "alien-egg",
			probability = 1
		}
    }
}
When I get rid of the - in demo-enemies it doesn't give me that specific error, but it still won't work, because as far as I know, there's no other way to refer to the __base__/prototypes/entity/demo-enemies without the dash. Any way around this? (or am I missing something?)

Re: Error when attempting to change loot of biter spawners

Posted: Sun Feb 05, 2017 2:15 am
by keyboardhack
You can't refer to a variable with a - in it like that. You have to refer to it the same way you did to the biter-spawner variable. Replace line 3 with:

Code: Select all


data.raw["demo-enemies"]["biter-spawner"].loot = 

Re: Error when attempting to change loot of biter spawners

Posted: Sun Feb 05, 2017 3:51 am
by Nexela
Also they type is not demo-enimies it is unit-spawner, and you have one too many tables

Code: Select all

data.raw["unit-spawner"]["biter-spawner"].loot = 
  {
    {
      count_max = 3,
      count_min = 0,
      item = "alien-egg",
      probability = 0.5
    }
  }

Re: Error when attempting to change loot of biter spawners

Posted: Sun Feb 05, 2017 3:02 pm
by ATMunn
Ah, I get it now. I was going off a previous example for changing recipes, and assuming that the thing after data.raw was the file in the base game it was in. That makes sense, thanks.