Page 1 of 1
					
				[SOLVED]unexpected symbol near '='
				Posted: Wed Jan 29, 2020 11:28 am
				by CruWiT
				This is my error;
prototypes/item/gun.lua:4: unexpected symbol near '='
This is my "gun.lua" file.
Code: Select all
local deagle = table.deepcopy(data.raw["gun"]["pistol"])
deagle.name = "deagle",
deagle.icon = "__mermi__/graphics/icons/deagle.png",
deagle.icon_size = 64,
deagle.attack_parameters.cooldown = 5,
deagle.attack_parameters.movement_slow_down_factor = 0.5,
deagle.attack_parameters.range = 25,
deagle.attack_parameters.damage_modifier = 3.5,
deagle.attack_parameters.sound = 
{
	{
		filename = "__mermi__/sound/desert-eagle.ogg",
		volume = 0.3,
	}
}
data:extend({deagle})
 
			 
			
					
				Re: unexpected symbol near '='
				Posted: Wed Jan 29, 2020 11:53 am
				by steinio
				Remove the commas at the ends of the lines.
			 
			
					
				Re: unexpected symbol near '='
				Posted: Wed Jan 29, 2020 12:36 pm
				by CruWiT
				new error in technology:lua:1 line, this is technology.lua file;
Code: Select all
data:extend({
type = "technology",
effects = {
    {
        recipe = "deneme-ammo",
        type = "unlock-recipe"
    },
    {
        recipe = "deagle",
        type = "unlock-recipe"
    }
},
enabled = false,
icon = "__mermi__/graphics/technology/deagle.png",
icon_size = 144,
name = "deagle-military",
order = "z-z",
unit = {
    count = 8,
    ingredients = 
    {
        {"automation-science-pack", 1}
    },
    time = 1
}
})
 
			 
			
					
				Re: unexpected symbol near '='
				Posted: Wed Jan 29, 2020 1:08 pm
				by darkfrei
				One pair of {} more:
data:extend ({prot1, prot2, prot3})
Your wrong definition: data:extend (prot1)  where prot1 is your table.
			 
			
					
				Re: unexpected symbol near '='
				Posted: Wed Jan 29, 2020 1:41 pm
				by asdff45
				data:extend() expects a table of tables of Prototypes: `data:extend({prot1, prot2}).
In Lua you can use `{` instead of `(` to create a table as first parameter, so `data:extend{ }` equals `data:extend({ })`.
In your case, you use `data:extend(prot)`, which is not correct.
You can use:
Code: Select all
data:extend(
{
    {
        type = "technology"
        // add your prototype here
    },
    {
        type = "recipe"
        // another prototype here
    }
}
)
or 
Code: Select all
data:extend{
    {
        type = "technology"
        // add your prototype here
    },
    {
        type = "recipe"
        // another prototype here
    }
}
 
			 
			
					
				Re: unexpected symbol near '='
				Posted: Wed Jan 29, 2020 2:04 pm
				by CruWiT
				asdff45 wrote: Wed Jan 29, 2020 1:41 pm
data:extend() expects a table of tables of Prototypes: `data:extend({prot1, prot2}).
In Lua you can use `{` instead of `(` to create a table as first parameter, so `data:extend{ }` equals `data:extend({ })`.
In your case, you use `data:extend(prot)`, which is not correct.
You can use:
Code: Select all
data:extend(
{
    {
        type = "technology"
        // add your prototype here
    },
    {
        type = "recipe"
        // another prototype here
    }
}
)
or 
Code: Select all
data:extend{
    {
        type = "technology"
        // add your prototype here
    },
    {
        type = "recipe"
        // another prototype here
    }
}
 
 
İt's work thanks for your help.
 
			 
			
					
				Re: [SOLVED]unexpected symbol near '='
				Posted: Wed Jan 29, 2020 8:55 pm
				by Hiladdar
				Also consider adding something like after the icon_size:
deagle.icon_mipmaps = 1,
Reason is icons were changed between 0.17.79 and 0.18.0.  They went from mostly 32x32 png file with one image, to a 120x64 png file with 4 images.  If you use the new format.  I believe the icon_mipmaps parameter refers to the number of images contained within the icon graphic file.
Hiladdar