Stardew Valley
0 of 0

File information

Last updated

Original upload

Created by

Platonymous

Uploaded by

Platonymous

Virus scan

Safe to use

Tags for this mod

About this mod

Allows adding dialogues and events via the ink Scripting Language

Requirements
Permissions and credits
Changelogs
Donations

Ink Stories

by Platonymous

Allows adding dialogues and events via the ink Scripting Language..

ink is a scripting language built around the idea of marking up pure-text with flow in order to produce interactive scripts.
At its most basic, it can be used to write a Choose Your Own-style story, or a branching dialogue tree. But its real strength is in writing dialogues with lots of options and lots of recombination of the flow.
ink offers several features to enable non-technical writers to branch often, and play out the consequences of those branches, in both minor and major ways, without fuss.
The script aims to be clean and logically ordered, so branching dialogue can be tested "by eye". The flow is described in a declarative fashion where possible.
It's also designed with redrafting in mind; so editing a flow should be fast.

Documentatation for ink: https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md
Inky - A Tool for writing ink: https://www.inklestudios.com/ink/ 


For players: Just add this mod and any contentpack that requires it to the Mods folder.
Ink Stories does nothing on it's own, it just enables other mods to use ink.

Example:
Under Optionale Files you can download an example that adds dialogue to Emily on the 13th and 14th of spring.
After the dialogue with Emily it also adds new dialogue to Alex.
The latest example also changes the flowerfestival event, it requires the latest version of InkStories.

For Modders:

First, write your ink script (and test it in Inky). Save normaly as .ink or export to json, both work.


Important: This section changed with 1.2.0, the old way still works but now only one contentpack is required.

Create a content pack for Content Patcher:

manifest.json
{
  "Name": "NAME OF YOUR MOD",
  "Author": "NAME OF THE AUTHOR",
  "Version": "1.0.0",
  "Description": "YOUR DESCRIPTION",
  "UniqueID": "Your.Unique.Id",
  "MinimumApiVersion": "3.18.0",
  "UpdateKeys": [ "Nexus:" ],
  "ContentPackFor": {
    "UniqueID": "Pathoschild.ContentPatcher"
  },
  "Dependencies": [
    {
      "UniqueID": "Platonymous.InkStories"
    }
  ]
}

content.json
{
  "Format": "1.28.0",
  "Changes": [
    {
      "Action": "Load",
      "Target": "{{Platonymous.InkStories/Story:Your.Story.Id}}",
      "FromFile": "PATH/TO/FILE.ink"
    },
    {
      "Action": "EditData",
      "Target": "Characters/Dialogue/NPCNAME",
      "Entries": {
        "SEASON_DAY": "INK Your.Story.Id"
     },
    {
      "LogName": "InkStories Example Event/Festival",
      "Action": "EditData",
      "Target": "Data/Festivals/spring24",
      "Entries": {
        "mainEvent": "speak NPCNAME \"INK Your.Story.Id\"/pause 200/INKCALL Your.Story.Id YOUR PARAMETERS OR NOTHING"
      }
    }
  ]
}


(You can add as many stories as you want and use it in as many Dialogues as you want)

INK Your.Story.Id used as dialogue will start the Inkstory dialogue.
INKCALL Your.Story.Id calls the "EventSetup" function in your ink-code (if defined) and provides everything that follows as parameters.
(if you use INKCALL for the setup phase in your event (third entry) the function needs to return a string of the actual setup)

-- Tags:

In Addition to the functionality of ink as described in the documentation, the Ink Stories Mod handles specific tags as commands you can use:

# BREAK
Ends the dialogue after this line

# READD
Re-adds the story to the same NPC so the player can continue the story

# BR
Shortform of "# BREAK  # READD"

# ADD [NPCNAME] [STORY ID]
Adds the specified story to the current dialogues of the npc (instead of the Story ID you can also put THIS, which will use the current story)

# ADDNEXT [NPCNAME] [STORY ID]
Same as # ADD, but the story is added the next day

# RESET
Resets the current story

# LOG [TYPE] [TEXT]
Logs the text to the console with the specified type (INFO,DEBUG,WARN,ERROR,ALERT,TRACE)


-- External functions:

Ink Stories also provides you with optional external functions that you can implement if you need them:

EXTERNAL ADD(npc,ink)
EXTERNAL ADDNEXT(npc,ink)
EXTERNAL RESET()
EXTERNAL LOG(text,type)
EXTERNAL SDVCHARS(text,npcname)
EXTERNAL HASMOD(id)
EXTERNAL SPEAKER()
EXTERNAL FRIENDSHIP(npcname, change)
EXTERNAL CHECK(conditions)
EXTERNAL COMMAND(command)
EXTERNAL ADDCOMMAND(command)
EXTERNAL SIN(num)
EXTERNAL COS(num)
EXTERNAL TAN(num)
EXTERNAL STEXT(id,key)
EXTERNAL SNUM(id,key)
EXTERNAL SCOUNT(key,change,isFixed)
EXTERNAL SETSTEXT(key,value,isFixed)
EXTERNAL SETSNUM(key,num,isFixed)
EXTERNAL CONTINUE()
EXTERNAL CPTEXT(key)
EXTERNAL CPNUM(key)
EXTERNAL CPBOOL(key)

=== function CONTINUE() ===
~ return

=== function ADD(npc,ink) ===
~ return

=== function ADDNEXT(npc,ink) ===
~ return

=== function RESET() ===
~ return

=== function LOG(text,type) ===
~ return

=== function SDVCHARS(text,npcname) ===
~ return text

=== function HASMOD(id) ===
~ return true

=== function SPEAKER ===
~ return "Emily"

=== function FRIENDSHIP(npcname, change) ===
~ return 250

=== function CHECK(conditions) ===
~ return true

=== function COMMAND(command) ===
~ return

=== function ADDCOMMAND(command) ===
~ return

=== function SIN(num) ===
~ return 0

=== function COS(num) ===
~ return 0

=== function TAN(num) ===
~ return 0

=== function STEXT(id,key) ===
~ return key

=== function SNUM(id,key) ===
~ return 0

=== function SCOUNT(key,change,isFixed) ===
~ return change

=== function SETSTEXT(key,value,isFixed) ===
~ return

=== function SETSNUM(key,num,isFixed) ===
~ return

=== function CPTEXT(key) ===
~ return ""

=== function CPNUM(key) ===
~ return 0

=== function CPBOOL(key) ===
~ return false

(the lower "=== function ... ===" declarations are fallbacks so the external functions don't throw erros in Inky, they aren't requiered ingame,
and in general you only need to include externals that you actually use in your script)

ADD, ADDNEXT, RESET, LOG
Do the same as their Tag-Counterparts

SDVCHARS
Parses the special dialouge characters in a text. Those are getting parsed by the game anyway, but with this you can get the results early and perform checks on them if you need to.

HASMOD
True if the player has the specified mod installed

SPEAKER
Returns the name of the current speaker

FRIENDSHIP
Changes the friendshippoints by the set amount and returns the total

CHECK
Checks eventconditions and returns true or false

COMMAND
Executes an event command

ADDCOMMAND
Adds an event command to the current event

SIN, COS, TAN
Math functions

STEXT, SETSTEXT, SNUM, SETSNUM
Gets or sets text or int values that can be accessed from other stories, setting isFixed to true will mean it's value doesn't get reset even if the story does.
You can only set values from the same story, but you can get values from any story by id (if it has set a value yet, otherwise returns "" or 0);
You can use "THIS" instead of the id if you want to access values from the same story.

SCOUNT
Accesses a SNUM value and adds the change value to it (use negative number for substraction), returns its new value.

CONTINUE
Steps to the next command in the ongoing event. Only needed from an INKCALL.

CPTEXT, CPNUM, CPBOOL
Let's you access data stored under your story Id throgh CP.
e.g.:

{
"Action": "EditData",
"Target": "{{Platonymous.InkStories/Store:Your.Story.Id}",
"Entries": {
  "your.key.1": "Anything"
}
}

Then you can access that data for example with: {CPTEXT("your.key.1")}

The text stored will be auto parsed if using CPNUM (to float) or CPBOOL.

-- Internal functions:

Ink Stories calls internal functions at certain times if they are implemented in your ink story:

=== function ShouldShow(npcname,path,day,season,year) ===
~ return true

=== function Fallback() ===
~ return "My Fallback Dialogue"

=== function DayEnding(day,season,year) ===
~ return true

=== function EventSetup(parameter1,parameter2,parameter3,...) ===
~ return "farmer -30 30 0"

ShouldShow(npcname,path,day,season,year) & Fallback()
Is checked before a story is displayed, if false the story will instead show the text returned in the Fallback function

DayEnding(day,season,year)
Is called on stories that have been loaded (shown at least once and not reset). The returnvalue (true of false) determines wether or not the story should be reset. The default is true, so any story not implementing the function will be reset at the end of the day.

EventSetup
Is called when using "INKCALL Your.Event.Id parameter 1 parameter2 parameter3 ..." as an event command.
You can have as many or as few parameters as you need, as long as you provide them when calling it.
The return value is only used if the call is made from the setup entry (3rd) in an event description.



If you have any questions or feature requests you can usually find me on the Stardew Valley Discord under the username Routine#8715

If you like my mods and want to support me, you can do so via Paypal or on Patreon.