Twiger Functions is back with version 8! (find it here)
(That file/text is a scene, so just drop it in your scenes folder and you’re good)
Besides using arrays (see here) and adding checkpoint-like saving to your game (see here),
You can now make use of javascript-like string functions:
substring
This method extracts the characters in a string between two indexes.
*gosub_scene twiger_functions substring [string] [start] [end] [output variable]
The output variable should be a string of the name of your global variable, ie “name”
Example:
*create name “Mr. Markiplier”
*create nickname “”
*gosub_scene twiger_functions substring name 5 9 “nickname”
${nickname}
This would result in Marki showing in your game.
substr
A lot like substring, but instead of saying where to end, the third parameter says how many letters to include.
*gosub_scene twiger_functions substr [string] [start] [length] [output variable]
Example:
*create name “Mr. Markiplier”
*create nickname “”
*gosub_scene twiger_functions substr name 8 5 “nickname”
${nickname}
This would result in kipli showing in your game.
indexOf
This method tells you the character index of a string within another string, or -1 if it does not exist.
*gosub_scene twiger_functions indexOf [string] [string to find] [case sensitive?] [output variable]
Example:
*create name “Mr. Markiplier”
*create nickname “mark”
*gosub_scene twiger_functions indexOf name nickname true “name”
${name}
Because case sensitive is set as true, this would result in -1 showing in your game. If it had been set to false, 5 would have shown in the game because “mark” starts at the 5th character.
contains
Tells you whether or not (true or false) a string appears within another one.
*gosub_scene twiger_functions contains [string] [string to find] [case sensitive?] [output variable]
Example:
*create findme "plier"
*temp find false
*gosub_scene twiger_functions contains "Mr. Markiplier" findme false "find"
*if (find)
You found it!
This would result in You found it! showing in your game.
replaceFirst
Replaces the first instance of string B inside string A with string C.
*gosub_scene twiger_functions replaceFirst [string A] [string B] [string C] [case sensitive?] [output variable]
Example:
*create name “Mr. Markiplier”
*create nickname “”
*gosub_scene twiger_functions replaceFirst name "Mr. " “” false “nickname”
${nickname}|
*gosub_scene twiger_functions replaceFirst nickname “plier” “moo” false “nickname”
${nickname}
This would result in Markiplier|Markimoo showing in your game.
replaceAll
Replaces all instance of string B inside string A with string C.
*gosub_scene twiger_functions replaceAll [string A] [string B] [string C] [case sensitive?] [output variable]
Example:
*create sentence “Mr. Markiplier, please hand me the pliers.”
*create sentence1 “”
*gosub_scene twiger_functions replaceAll sentence “plier” “moo” false “sentence1”
*gosub_scene twiger_functions replaceFirst sentence “plier” “moo” false “sentence”
${sentence1}|${sentence}
This would result in Mr. Markimoo, please hand me the moos.|Mr. Markimoo, please hand me the pliers. showing in your game.
Important note: In order to use *gosub with parameters, the scene has to be included in the scene_list in order to pass quicktest or randomtest (I don’t remember which)