(Created page with "__FORCETOC__ This mod template customizes the starting loadout of the default Freeplay scenario. == Code == === def.json === Content<syntaxhighlight lang="json"> { "id": "ModTemplateFreeplay", "name": "Mod Template Freeplay", "version_name": "1.0", "version_code": 1, "author": "The Desynced Team", "homepage": "https://www.desyncedgame.com/", "description": "Mod Template Freeplay", "packages": { "Scenario": { "name": "S...") |
m (Bernhard moved page Modding Template Freeplay to Modding/Templates/Freeplay without leaving a redirect) |
(No difference)
|
Latest revision as of 15:26, 9 August 2023
This mod template customizes the starting loadout of the default Freeplay scenario.
Code[edit | edit source]
def.json[edit | edit source]
Content
{
"id": "ModTemplateFreeplay",
"name": "Mod Template Freeplay",
"version_name": "1.0",
"version_code": 1,
"author": "The Desynced Team",
"homepage": "https://www.desyncedgame.com/",
"description": "Mod Template Freeplay",
"packages": {
"Scenario": {
"name": "Scenario",
"entry": "scenario.lua",
"dependencies": [ "Main/Freeplay" ],
"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()
-- disable the on_player_faction_spawn function on the main package
Game.GetModPackage("Main/Freeplay").on_player_faction_spawn = nil
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")
-- show intro
faction:RunUI("OnFreeplayFactionSpawned")
-- show welcome message after 3 seconds
Map.Delay("StartOfGame", 15, { faction = faction })
end
Modding | |
Templates |