Lumber Mill Adjacency

WitchyStella

Chieftain
Joined
May 19, 2020
Messages
7
Hey folks! I've tried to create this mod in the past and failed, and figured I'd try again today (knowing more about modding than I did then)

Unfortunately, I still can't seem to get it to work. What I'm trying to do is:
  • disable building lumber mills adjacent to each other
  • grant lumber mills +1 production for each adjacent forest / rainforest
I'd be extremely thankful if you could help me out with this. I am still fairly new to modding, so it's entirely possible there is something very obvious that I'm just not seeing.

Code:
UPDATE     Improvements
SET        SameAdjacentValid = 0
WHERE    ImprovementType = 'IMPROVEMENT_LUMBER_MILL';

--

INSERT INTO        Improvement_Adjacencies
        (ImprovementType,            YieldChangeId)
VALUES    ('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionForest'),
VALUES    ('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionJungle');

--

INSERT INTO        Adjacency_YieldChanges
        (ID,                                Description,    YieldType,            YieldChange,    TilesRequired,    AdjacentFeature)
VALUES    ('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1                1            'FEATURE_FOREST'),
VALUES    ('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1                1            'FEATURE_JUNGLE');

I'm wondering if I'm forgetting something in the beginning of the code, since it seems to just start out of nowhere (I'm still used to xml-modding, I'm just starting with sql), but I haven't seen anything in the sql tutorials I've looked at.

Thanks in advance!
 
Incorrect syntax
Code:
INSERT INTO        Improvement_Adjacencies
        (ImprovementType,            YieldChangeId)
VALUES    ('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionForest'),
VALUES    ('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionJungle');

--

INSERT INTO        Adjacency_YieldChanges
        (ID,                                Description,    YieldType,            YieldChange,    TilesRequired,    AdjacentFeature)
VALUES    ('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1                1            'FEATURE_FOREST'),
VALUES    ('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1                1            'FEATURE_JUNGLE');
Needs to be
Code:
INSERT INTO        Improvement_Adjacencies
        (ImprovementType,            YieldChangeId)
VALUES 	('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionForest'),
	('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionJungle');

--

INSERT INTO        Adjacency_YieldChanges
        (ID,                                Description,    YieldType,            YieldChange,    TilesRequired,    AdjacentFeature)
VALUES 	('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1,                1,           'FEATURE_FOREST'),
	('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1 ,               1,            'FEATURE_JUNGLE');
 
Thank you so much! I just tried that and unfortunately, it still doesn't work. In the modinfo file, what InGameActions do I need to specify?
Code:
  <InGameActions>
    <UpdateDatabase id="Gameplay">
      <File>No_Lumber_Mill_Spam.sql</File>
    </UpdateDatabase>
  </InGameActions>
This is what I have, which works fine for a different mod I've made that adds a modifier to some buildings (specifically wonders)

I'm sure I'm just being slow and it's fairly obvious, so I'm sorry about that!
 
(a) That is the correct action-type
(b) What is in Database.log ?

Besides the extra VALUES commands you were also missing needed commas.

And I just spotted another error here which I did not see before
Code:
INSERT INTO        Adjacency_YieldChanges
        (ID,                                Description,    YieldType,            YieldChange,    TilesRequired,    AdjacentFeature)
VALUES 	('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1,                1,           'FEATURE_FOREST'),
	('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1 ,               1,            'FEATURE_JUNGLE');
You listed "WS_Lumber_Mill_ProductionForest" twice in table "Adjacency_YieldChanges" instead of one row with "WS_Lumber_Mill_ProductionForest" and the other with "WS_Lumber_Mill_ProductionJungle". This mistake will be treated as a fatal syntax error and the entire INSERT into the table will be ignored.
 
Code:
[2137021.948] [Localization]: StartupErrorMessages.xml
[2137021.948] [Localization]: Input XML does not contain database entry tags. GameData, GameInfo or Database
[2137026.868] [Localization]: Validating Foreign Key Constraints...
[2137026.868] [Localization]: Passed Validation.
[2137026.908] [Configuration]: Validating Foreign Key Constraints...
[2137026.908] [Configuration]: Passed Validation.
[2137033.867] [FullTextSearch]: Initializing FullTextSearch
[2137042.738] [Gameplay]: Validating Foreign Key Constraints...
[2137042.750] [Gameplay]: Passed Validation.
[2137053.758] [Configuration]: Validating Foreign Key Constraints...
[2137053.759] [Configuration]: Passed Validation.
[2137094.203] [HallofFame]: Database found. Checking versions...
[2137094.207] [HallofFame]: Database is up-to-date!
[2137100.929] [FullTextSearch]: FTS - Creating Context
[2137105.679] [FullTextSearch]: FTS - Creating Context
[2137218.064] [Configuration]: Validating Foreign Key Constraints...
[2137218.065] [Configuration]: Passed Validation.
[2137249.888] [Configuration]: Validating Foreign Key Constraints...
[2137249.888] [Configuration]: Passed Validation.
[2137260.172] [Gameplay] ERROR: near "": syntax error
[2137282.833] [Gameplay]: Validating Foreign Key Constraints...
[2137282.868] [Gameplay]: Passed Validation.
[2137308.635] [FullTextSearch]: FTS - Creating Context
[2137308.636] [FullTextSearch]: FTS - Creating Context
[2137309.160] [FullTextSearch]: FTS - Creating Context
[2137309.775] [FullTextSearch]: FTS - Creating Context
[2137311.775] [FullTextSearch]: FTS - Creating Context
[2137532.838] [Configuration]: Validating Foreign Key Constraints...
[2137532.838] [Configuration]: Passed Validation.
[2137537.674] [Gameplay] ERROR: near "": syntax error
[2137556.611] [Gameplay]: Validating Foreign Key Constraints...
[2137556.640] [Gameplay]: Passed Validation.
[2137568.474] [Configuration]: Validating Foreign Key Constraints...
[2137568.474] [Configuration]: Passed Validation.
[2137576.061] [FullTextSearch]: FTS - Creating Context
[2137707.809] [Configuration]: Validating Foreign Key Constraints...
[2137707.810] [Configuration]: Passed Validation.
[2137712.639] [Gameplay] ERROR: near "": syntax error
[2137729.712] [Gameplay]: Validating Foreign Key Constraints...
[2137729.763] [Gameplay]: Passed Validation.
[2137752.521] [FullTextSearch]: FTS - Creating Context
[2137752.522] [FullTextSearch]: FTS - Creating Context
[2137752.829] [FullTextSearch]: FTS - Creating Context
[2137753.348] [FullTextSearch]: FTS - Creating Context
[2137754.924] [FullTextSearch]: FTS - Creating Context

There are two syntax errors here, but I can't tell what they're referring to when they say "ERROR: near "" "
I've fixed the duplicate and the commas, as well
 
This code does not create syntax errors for me
Code:
UPDATE     Improvements
SET        SameAdjacentValid = 0
WHERE    ImprovementType = 'IMPROVEMENT_LUMBER_MILL';

--

INSERT INTO        Improvement_Adjacencies
        (ImprovementType,            YieldChangeId)
VALUES 	('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionForest'),
	('IMPROVEMENT_LUMBER_MILL',    'WS_Lumber_Mill_ProductionJungle');

--

INSERT INTO        Adjacency_YieldChanges
        (ID,                                Description,    YieldType,            YieldChange,    TilesRequired,    AdjacentFeature)
VALUES 	('WS_Lumber_Mill_ProductionForest',    'Placeholder',    'YIELD_PRODUCTION',    1,                1,           'FEATURE_FOREST'),
	('WS_Lumber_Mill_ProductionJungle',    'Placeholder',    'YIELD_PRODUCTION',    1 ,               1,            'FEATURE_JUNGLE');

"Near" in Database.log means "before" the specified character in the file. "" in these cases generally means the game cannot parse out the previous character in the code. You can get this syntax error if any of your Action ID names in the modinfo file contain a space character, as these are not allowed. You can also get this error when the file itself has been corrupted -- usually this occurs when an app like Word is used to edit and save the file, since Word and similar programs always seem to want to add hidden file formatting commands which the game cannot interpret, even though you may specify to save the file as text only with no formatting commands. I always use the modbuddy editor, or else one of Notepad or Notepad++ to edit my code files (SQL, XML, LUA).
 
That is bizarre. I am using the exact same code, there are no spaces in any Action ID names, and I use Notepad++ as well. I'm going to try recreating the mod (using the same code) from scratch just to see if the file got corrupted some other way during the process.
Thank you for your patience so far!
 
Back
Top Bottom