Skip to content

Adding New Stories: Fields & Custom Story Images

CheTranqui edited this page Nov 21, 2018 · 1 revision

Required Fields:

A story for publish in the Martian Tribune must contain the following structure:

{
  key = 'AUniqueKeyString', -- no translation, not displayed to the user, primary key for the story.
  title = T{123456789, "Story Headline"},
  story = T{123456790, "     This is the story content. Start with 5 spaces to line up properly."}
}

The title and story fields should be translatable strings, and you need to provide your own translation(s) for them.

Additional Optional fields:

  • colonist: A colonist to pin to the user's interface when the story is published when the story is related to that colonist in particular.
  • canPublish: A function to be called at the time of attempting to publish the story that can be used to prohibit publication. If not present, a story is considered able to be published at any time after the initial story trigger has occurred.

story.canPublish()

If a story speaks about something like "current warm weather", publishing it in the middle of a Cold Wave would be inappropriate. Due to the way that stories get added to a list of "possibles" and then selected at random from those lists, it is possible to have a story added to the lists of potential stories and then later to have the game circumstances to have changed in a way that causes a temporary "don't publish now" condition. When a story is selected for publishing, the canPublish() function is used to indicate that a different story should be selected instead.

For example, to prohibit publishing during a Cold Wave or while the warning for a Cold Wave about to start is showing.

{
  key = "AUniqueStoryKey",
  title = T{123456789, "Story Headline"},
  story = T{123456790, "     This is the story content. Start with 5 spaces to line up properly."},
  -- can only publish when no active Cold Wave and no Cold Wave Notification shown.
  canPublish = function()
    return not g_ColdWave and not IsOnScreenNotificationShown("ColdWave")
  end
}

Setting a custom image to display for the story

Any stories with custom images should set those image paths by using the MartianTribuneMod.Functions.RegisterStoryImage(story.key, image_path) function when the mods have finished loading. The Martian Tribune provides a custom message MartianTribuneModLoaded to listen for so that other mods can detect whether the user is using Martian Tribune, and therefore whether they should integrate with Martian Tribune.

Example: setting the image for a story to the in-game UI/Messages/birth.tga image:

function OnMsg.MartianTribuneModLoaded()
  -- If this message is received, the user is also using Martian Tribune.
  -- Example for a story with 'story.key = "MyBirthStory_1"'
  MartianTribuneMod.Functions.RegisterStoryImage("MyBirthStory_1", "UI/Messages/birth.tga")
end

Note that custom images are not saved into the user's save game, so all potential stories that use a custom image should register that image path inside the MartianTribuneModLoaded message handler on each game start/load. This also means that if you add an image to a story at some point in the future, existing games will show that image at publication time even if the story itself had already been added to the list of possible stories in that save game.

If providing a custom image from your own mod, the image should be pre-cropped to match the in-game "UI/Messages" image size/transparency mask shape. Images can be created/shown in png format, and are usually about 1/2 to 1/3 of the size of the same image in tga format.

Example for a custom image:

function OnMsg.MartianTribuneModLoaded()
  -- If this message is received, the user is also using Martian Tribune.
  -- Example for a story with 'story.key = "MyBirthStory_1"'
  MartianTribuneMod.Functions.RegisterStoryImage("MyBirthStory_1", CurrentModPath.."UI/custom-birth.png")
end

Clone this wiki locally