This mod template creates a fully custom scenario, not based on the main game's Freeplay scenario.
Code[edit | edit source]
def.json[edit | edit source]
Content
{
"id": "ModTemplateScenario",
"name": "Mod Template Scenario",
"version_name": "1.0",
"version_code": 1,
"author": "The Desynced Team",
"homepage": "https://www.desyncedgame.com/",
"description": "Mod Template Scenario",
"packages": {
"Scenario": {
"name": "Scenario",
"entry": "scenario.lua",
"dependencies": [ "Main/Data" ],
"type": "Scenario"
}
}
}
scenario.lua[edit | edit source]
Content
local package = ...
-- called when starting a new game (skipped when loading a save or joining a multiplayer game)
function package:setup_scenario(settings)
end
-- called when mod is initializing
function package:init()
end
-- called when starting up a new game
function package:on_world_spawn()
end
-- called when a new player faction is spawned or respawned
function package:on_player_faction_spawn(faction, is_respawn)
-- select starting location for player faction
faction.home_location = GetPlayerFactionHomeOnGround()
local loc = faction.home_location
-- spawn a bot
local bot = Map.CreateEntity(faction, "f_bot_1s_a")
bot:Place(loc.x, loc.y)
-- unlock starter tech
faction:Unlock("t_robot_tech_basic")
end
Modding | |
Templates |