[SOLVED] WITH RECURSIVE breaking my mod...why?

AJNoyes

Chieftain
Joined
May 20, 2023
Messages
4
I am trying to create an exponential increase in production based on population size. I tested the following code with https://sqliteonline.com/ and it produces the expected table with the expected values. However, the rest of the mod (that updates the database with this code) fails. My improvised debug strategy is to set the combat strength of the Warrior to 250 and then move that code down until it fails to modify the game. It works before this chunk of code but not directly after. Does anyone know why?

SQL:
CREATE TABLE IF NOT EXISTS Population_Bonus
    (
    Population_Size INT,
    Production_Bonus REAL
    );
  
WITH RECURSIVE pop_bonus(pop, bonus)
    AS (
        VALUES(1,1)
      UNION ALL
        SELECT
            pop + 1 AS pop,
            POWER(pop, 1.17) - POWER(pop-1, 1.17) AS bonus
      FROM pop_bonus
      WHERE pop <= 250
      )
INSERT INTO Population_Bonus (Population_Size, Production_Bonus) SELECT pop,bonus FROM pop_bonus;
 
Last edited:
Update: The Warrior statement succeeds after CREATE TABLE. So, it's the WITH RECURSIVE part that is breaking the mod.
 
For posterity:

  1. I was looking at the log files in Documents (which are no longer updated). You need to look in the log files in AppData/Local/FiraxisGames/...
  2. With the right logs, I saw: [Gameplay] ERROR: no such function: POWER. This function does not exist in SQLite.
  3. sqliteonline.com accepts functions that are not in SQLite so, despite its name, is not useful for debugging SQLite code. extendsclass.com/sqlite-browser.html worked, by the way.
  4. Here are some ways to create your own POWER function in SQLite: https://stackoverflow.com/questions/13190064/how-to-find-power-of-a-number-in-sqlite
 
Top Bottom