• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Bartazar

Private
Jun 19, 2020
12
0
hey there,

I need help to create a custom module.
I'm trying to do module for starbase, that is only possible to be built if there is an asteroid/asteroid belt in the system
So far, I can't make this working. Please can some experienced scripter have a look at this code?

Code:
## this is in my mod_l_english.yml
 mod_requires_asteroid_belt:0 "$TRIGGER_FAIL$Can only be build in systems that has a rocky asteroid belt."

## this is in the module folder/file

asteroids_advanced_mines = {
    icon = "GFX_asteroids_advanced_mines"
    section = "REFINERY_STARBASE_SECTION"
    construction_days = 120

    possible = {
        custom_tooltip = {
##            any_planet = pc_asteroid
            any_system_planet = pc_asteroid
            fail_text = "mod_requires_asteroid_belt"
        }
        custom_tooltip = {
            fail_text = "requires_starport"
            has_starbase_size >= starbase_starport
        }

    }

    possible = {
        solar_system = {
            custom_tooltip = {
                fail_text = "requires_asteroid_belt"
                any_planet = pc_asteroid
            }               
        }
    }

    resources = {
        category = starbase_buildings
        cost = {
            alloys = 200
        }

        produces = {
            minerals = 30
            alloys = 5
            rare_crystals = 0.25
        }

        upkeep = {
            energy = 30
        }
    }

    ai_build_at_chokepoint = yes
    ai_build_outside_chokepoint = yes
    ai_weight = {
        weight = 150
    }

    potential = {
        exists = owner
##        owner = { has_technology = tech_asteroids_advanced_mines }
    }

##    show_in_tech = "tech_asteroids_advanced_mines"
}

So far this don't work, I can see the module in the stabase modules list, but it can't be build, and it don't shows the cost resources or what it can produce.
 
Not entirely sure, but I don't think you can check for an asteroid belt specifically, only for whether there are any asteroids in the system.

But as far as the code goes, I'm pretty sure this syntax doesn't work:

Code:
any_planet = pc_asteroid


It must instead be:

Code:
any_planet = {
    is_planet_class = pc_asteroid
}

...but then you're still not including ice and crystal asteroids (or potential other asteroid types added by mods). So this is better:

Code:
any_planet = {
   is_asteroid = yes
}


The first 'possible' tag also forgets to switch to the solar_system scope before asking about planets. Right now it's asking whether any planet on the starbase is an asteroid, which of course doesn't work.

Overall, the code should look something like this:


Code:
asteroids_advanced_mines = {
    icon = "GFX_asteroids_advanced_mines"
    section = "REFINERY_STARBASE_SECTION"
    construction_days = 120

    possible = {
        custom_tooltip = {
            fail_text = "requires_starport"
            has_starbase_size >= starbase_starport
        }
        custom_tooltip = {
            fail_text = "requires_asteroid_belt"             
            solar_system = { # Cosmetic note: The solar_system switch should probably happen within the custom_tooltip, otherwise it will show up in the tooltip, in addition to your custom text
                any_system_planet = {
                    is_asteroid = yes
                }
            }
        }
    }

    resources = {
        category = starbase_buildings # Wrrong category btw. starbase_modules is for starbase modules.
        cost = {
            alloys = 200
        }

        produces = {
            minerals = 30
            alloys = 5
            rare_crystals = 0.25
        }

        upkeep = {
            energy = 30
        }
    }

    ai_build_at_chokepoint = yes
    ai_build_outside_chokepoint = yes
    ai_weight = {
        weight = 150
    }

    potential = {
        exists = owner
##        owner = { has_technology = tech_asteroids_advanced_mines }
    }

##    show_in_tech = "tech_asteroids_advanced_mines"
}
 
Thank you for your help, that works great!

Well, i've searched if there is anything about checking if the system has an asteroid belt, but I didn't found anything.

I've seen the solar_sytem trigger in the wiki, but I thought it was only for the solar system such as, earth, moon, mars, venus, etc.. haha

anyway, thanks again!