unexpected symbol near ')'

Place to get help with not working mods / modding interface.
albatrosv13
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Wed Apr 30, 2014 5:36 pm
Contact:

unexpected symbol near ')'

Post by albatrosv13 »

deleted
Last edited by albatrosv13 on Thu May 19, 2016 4:25 pm, edited 1 time in total.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: unexpected symbol near ')'

Post by bobingabout »

You're openening 4 levels of blocks, but only closing 3 of them with ends.
Block 1: function(event)
Block 2: if game.player.technology["productivitylogistic"].researched == true then
Block 3: for k, v in pairs(data.raw.module) do
Block 4: if v.name:find("productivity%-module") and v.limitation then

Since all the "end"s are at the end before the last ), then you can clearly see there are only 3 of them, meaning the function is never closed, and you try to close script.on_event before it.

The error message could be clearer. Also, didn't it tell you a line number?
Last edited by bobingabout on Sat Apr 23, 2016 5:34 pm, edited 3 times in total.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: unexpected symbol near ')'

Post by Adil »

There are: function, if, for, if - 4 opening constructions, there are only 3 end's.
When error occurs, it says a number line, you should indicate which number it errorrs on to otheres when you ask for help.
Generally, when it complains about something near right bracket, the error is located anywhere between that an corresponding left bracket.

Ninja bob. :)
I'll add then that game.player is not where technologies are contained and it should be generally replaced with

Code: Select all

for _,player in pairs(game.players) do
when it is actually needed to use, for the sake of multiplayer compatibility.

And you can't do what you are trying to do this way, as the data.raw is only accessible during the game load for manipulation by data... scripts.
You may have to actually define tiers of modules of which first one can't go anywhere as you want.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
albatrosv13
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Wed Apr 30, 2014 5:36 pm
Contact:

Re: unexpected symbol near ')'

Post by albatrosv13 »

deleted
Last edited by albatrosv13 on Thu May 19, 2016 4:25 pm, edited 1 time in total.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: unexpected symbol near ')'

Post by Adil »

You replase
EVERYTHING
:P
The "game.players" passage was just a general wisdom. In your case it is not applicable, as mentioned in the post. (and surely I didn't mean that weird codething in your post)
The technologies are stored in force, and you can actually get the pointer to force from technology from the event.

As said previously, your current idea of implementation won't work, even if typed in correctly. You need to device completely new approach.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: unexpected symbol near ')'

Post by bobingabout »

Basically... itterate through all players, and go one block deeper.
Replace your line

Code: Select all

if game.player.technology["productivitylogistic"].researched == true then
with

Code: Select all

for i,player in ipairs(game.players) do
if player.force.technology["productivitylogistic"].researched == true then
and don't forget the extra end at the end!


it is looking a bit messy by now though, because your code looks like it is checking to see if the specific research has been completed on EVERY EVENT!!!, and multiple times if there are multiple players on the force!, and if it is, then it will add those things to the filters after EVERY EVENT!!! and possible end up to a memory leak, as you infinitely add the same productivity filters over and over again!

It would probably be a better solution to itterate through game.forces instead of game.players, but that still leaks.

Code: Select all

for i,force in ipairs(game.forces) do
if force.technology["productivitylogistic"].researched == true then
Although my solution specifically answers your question, you want to change from checking to see if the research has been unlocked on every event, and instead look for the event when it unlocks. for the specifics, I'd look at adil's solution, also here for how to check a specific event http://lua-api.factorio.com/0.12.30/index.html and here http://lua-api.factorio.com/0.12.30/eve ... h_finished
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”