[SOLVED]unexpected symbol near '='

Place to get help with not working mods / modding interface.
Post Reply
CruWiT
Inserter
Inserter
Posts: 23
Joined: Wed Apr 17, 2019 6:22 pm
Contact:

[SOLVED]unexpected symbol near '='

Post 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})
Last edited by CruWiT on Wed Jan 29, 2020 2:06 pm, edited 1 time in total.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2633
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: unexpected symbol near '='

Post by steinio »

Remove the commas at the ends of the lines.
Image

Transport Belt Repair Man

View unread Posts

CruWiT
Inserter
Inserter
Posts: 23
Joined: Wed Apr 17, 2019 6:22 pm
Contact:

Re: unexpected symbol near '='

Post 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
}
})

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: unexpected symbol near '='

Post by darkfrei »

One pair of {} more:
data:extend ({prot1, prot2, prot3})

Your wrong definition: data:extend (prot1) where prot1 is your table.

asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

Re: unexpected symbol near '='

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

CruWiT
Inserter
Inserter
Posts: 23
Joined: Wed Apr 17, 2019 6:22 pm
Contact:

Re: unexpected symbol near '='

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

Hiladdar
Fast Inserter
Fast Inserter
Posts: 214
Joined: Mon May 14, 2018 6:47 pm
Contact:

Re: [SOLVED]unexpected symbol near '='

Post 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

Post Reply

Return to “Modding help”