0 votes
by (490 points)

Hello, I have begun playing around with some concepts for a game, and decided to doodle on a small RPG style game based on the NES game Sweet Home.

In Sweet Home, there are 5 playable characters. Each of these characters have a unique special ability that allows them to solve various puzzles in the over world. The player organizes these characters into parties of up to 3 characters (for a minimum of 2 parties and a maximum of 5 parties). The player can switch between parties at any point in time. During a battle, one of the player characters can call for help, which allows the player to control another party for a certain number of steps. If that party makes it too the location where battle is occuring, then they join the battle as well.

I've dabbled in twine before, but never implemented something as complicated as this before. How would I go about tracking the location of the various parties, and switching between them? I am using Twine 2 and SugarCube 2.21.0. 

1 Answer

0 votes
by (23.6k points)
selected by
Best answer

While what you are planning to do might sound complicated at first, it should be pretty easy to implement. Put something like this into your StoryInit:

<<set $char1 to {
name: "Tom",
location: "start",

<<set $char2 to {
name: "Linda",
location: "start",

<<set $char3 to {
name: "James",
location: "start",

<<set $chars to [$char1 , $char2 , $char3]>>

<<set $player to $char1>>

Then create a widget to allow the swap in a passage with the tag "widget":

<<widget "swap">><<nobr>>

<<for _i to 0; _i lt $chars.length; _i++>>
	<<if $player.name == $chars[_i].name>>
		<<set $chars[_i].location to passage()>>
		<<capture _i>>
			<<link "Switch to $chars[_i].name">>
				<<set $player.name to $chars[_i].name>>
				<<goto $chars[_i].location>>


Now enter the following into the PassageHeader or PassageFooter passage depending on where you want your switch options to appear on every page:


And that's it.