unexpected symbol near ')'
-
- Long Handed Inserter
- Posts: 80
- Joined: Wed Apr 30, 2014 5:36 pm
- Contact:
unexpected symbol near ')'
deleted
Last edited by albatrosv13 on Thu May 19, 2016 4:25 pm, edited 1 time in total.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: unexpected symbol near ')'
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?
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.
Re: unexpected symbol near ')'
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
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.
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
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.
I also update mods, some of them even work.
Recently I did a mod tutorial.
-
- Long Handed Inserter
- Posts: 80
- Joined: Wed Apr 30, 2014 5:36 pm
- Contact:
Re: unexpected symbol near ')'
deleted
Last edited by albatrosv13 on Thu May 19, 2016 4:25 pm, edited 1 time in total.
Re: unexpected symbol near ')'
You replase
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.
EVERYTHING
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.
I also update mods, some of them even work.
Recently I did a mod tutorial.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: unexpected symbol near ')'
Basically... itterate through all players, and go one block deeper.
Replace your line
with
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.
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
Replace your line
Code: Select all
if game.player.technology["productivitylogistic"].researched == true then
Code: Select all
for i,player in ipairs(game.players) do
if player.force.technology["productivitylogistic"].researched == true then
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