Page 1 of 1
unexpected symbol near ')'
Posted: Sat Apr 23, 2016 5:01 pm
by albatrosv13
deleted
Re: unexpected symbol near ')'
Posted: Sat Apr 23, 2016 5:30 pm
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?
Re: unexpected symbol near ')'
Posted: Sat Apr 23, 2016 5:32 pm
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.
Re: unexpected symbol near ')'
Posted: Sat Apr 23, 2016 5:48 pm
by albatrosv13
deleted
Re: unexpected symbol near ')'
Posted: Sat Apr 23, 2016 10:21 pm
by Adil
You replase
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.
Re: unexpected symbol near ')'
Posted: Sun Apr 24, 2016 12:02 pm
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