Your browser lacks required capabilities. Please upgrade it or switch to another to continue.
Loading…
There are many different ways to approach procedural generation of content in Twine. This example covers using //passages// as storage and JavaScript functions as a method of generating content.
<blockquote>
This example uses the SugarCube 2.21.0 story format.
It also heavily based on the work of Tony Veale from the following paper:
Veale, T. (2016). A Rap on the Knuckles and a Twist in the Tale: From Tweeting Affective Metaphors to Generating Stories with a Moral. In Proceedings of the AAAI Spring Symposium on Ethical and Moral Considerations in Non-Human Agents.
Additional information can be found on the GitHub page: <a href="https://github.com/prosecconetwork/Scealextric">Scealextric</a>
</blockquote>
[[Using Story.get()]]In SugarCube, the //Story.get()// function is used to get a Passage object representing the passage by name.
Passage objects have properties like //text// and //title// to get their contents.
<<set $storyContent to Story.get("A and B Story")>>
<<set $passageText to $storyContent.text>>
$passageText
[[Using Passage.text]]abandon
are feared by
underestimate
turn against
are inspired by
are bought off by
turn against
take up with
pursue
take up with
are manipulated by
kill
are lured by
turn against
are moved by
indoctrinate
sympathize with
release
seek forgiveness from
enlist
fall in love with
abuse
enlist
look for
supervise
are obeyed by
supervise
are obeyed by
disfigure
fall in love with
admire
campaign against
spy on
blackmail
turn against
disagree with
disagree with
beg forgiveness from
love
underestimate
condescend to
underestimate
condescend to
are lectured by
complain to
underestimate
resent
resent
are bored by
tune out
are lectured by
tune out
are chastised by
interview
argue with
interview
are impressed by
interview
interview
turn against
interview
share stories with
praise
surrender to
surrender to
surrender to
surrender to
argue with
pine for
cry for
stand up to
are disillusioned by
are deflowered by
are kissed by
are attracted by
attack
kiss up to
elude
lick up to
suck up to
curry favor with
sympathize with
are favored by
lie for
are favored by
are inspired by
sue
are appointed by
are rewarded by
kiss up to
fear
resent
are haunted by
despise
are haunted by
hate
beg forgiveness from
seek forgiveness from
stalk
stalk
argue with
argue with
arrest
are insulted by
are attacked by
cede power to
deceive
cede power to
bow down to
resist
trick
learn from
taunt
listen to
are attracted by
are attracted by
are interviewed by
are attracted by
identify with
are snatched by
are interviewed by
seek advice from
lay a trap for
overthrow
disgust
learn from
confer with
are interviewed by
are advised by
look up to
are accompanied by
disappoint
disagree with
abduct
abduct
are escorted by
are followed by
listen to
are lectured by
read the works of
read the works of
stalk
argue with
are enticed by
bow down to
cede power to
appeal to
negotiate with
cede power to
stand up to
beg forgiveness from
seek forgiveness from
are evaluated by
are chosen by
welcome
are chosen by
trust
are interviewed by
lick up to
are coached by
impress
are coached by
kiss up to
impress
flatter
are enchanted by
are studied by
are taught by
inspire
praise
are tutored by
are assisted by
are molded by
are taught by
are taught by
harden toward
threaten
sleep with
fall in love with
favor
are probed by
are prosecuted by
imprison
fear
are worshipped by
are worshipped by
seek forgiveness from
trust
cede power to
seek forgiveness from
confer with
talk to
mimic
obtain sympathy from
beg forgiveness from
seek forgiveness from
are lectured by
are lectured by
flirt with
sleep with
agree with
identify with
laugh at
hire
are escorted by
flirt with
are seduced by
are feared by
eject
are feared by
are feared by
testify against
cede power to
are retained by
surrender to
surrender to
sue
conspire with
are photographed by
are popularized by
sue
buy off
are impersonated by
coach
are baptized by
argue with
are advised by
appeal to
are fielded by
are trained by
impress
write to
are photographed by
resent
are dispatched by
are dispatched by
cede power to
are reviewed by
are sought by
are photographed by
are admired by
flirt with
are monitored by
are monitored by
disagree with
are read by
identify with
hate
learn from
are supported by
respect
sympathize with
anger
steal from
listen to
listen to
believe in
observe
pray to
are forgiven by
facilitate
facilitate
are corrupted by
are favored by
are feared by
manipulate
profit from
blackmail
bow down to
labor for
bow down to
fear
fear
labor for
labor for
are feared by
feel sorry for
grow suspicious of
hate
work for
work for
spy on
spy on
spy on
divorce
are exploited by
lose to
overwork
are upstaged by
are seduced by
are misrepresented by
are hired by
believe in
cheat on
are lectured by
lose favor with
are sued by
lose favor with
lose favor with
are interrogated by
negotiate with
commit to
compete against
compete with
forgive
conquer
support
help
play for
play for
rule over
subjugate
whip
whip
summon
are obeyed by
confer with
confer with
summon
are trusted by
visit
are welcomed by
are lectured by
consult
are counselled by
consult
are advised by
lose control over
entertain
assist
assist
counsel
disagree with
are lectured by
are corrupted by
are feared by
are painted by
follow
confess to
are pushed too far by
inherit from
nurture
are chastised by
are scolded by
disobey
flatter
lay a trap for
are underestimated by
dump
dump
dump
flatter
are welcomed by
rule
marry
marry
seduce
kiss up to
rescue
exploit
sign up
work for
are pursued by
date
date
are charmed by
listen to
listen to
are entertained by
paint
rescue
are worshipped by
seek advice from
sleep with
travel with
work with
are saved by
baptize
negotiate with
search for
chat with
chat with
flirt with
chat with
talk to
travel with
woo
incarcerate
learn from
compete with
are inspired by
remember
sign with
are obeyed by
are inspired by
sign with
charge
appoint
minister to
raise
raise
teach
tend
train
are protected by
are impressed by
lead
are disgusted by
lick up to
catch
catch
curse
detain
guard
are manipulated by
date
date
seek advice from
pander to
chase
chase after
search for
mentor
mentor
preach to
rouse
sign up
translate for
work with
let go of
let go of
are deceived by
let in
let in
diagnose
testify before
summon
listen to
are obeyed by
are profiled by
charm
convert
convert
cross examine
guide
mystify
observe
serve
summon
date
propose to
observe
are coached by
act for
negotiate with
interview
pamper
propagandize for
receive
reward
cast out
review
review
review
worship
appoint
are impressed by
appoint
are flattered by
entertain
select
sell through
sell via
tip off
delegate to
deploy
hire
hire
manage
prosecute
take as prisoner
evaluate
evaluate
are feared by
interview
arrest
borrow from
owe
owe to
influence
are feared by
run against
run against
molest
seduce
worship
read the works of
appeal to
wait onare pursued by
overthrow
are suppressed by
are attacked by
imitate
settle with
are beaten by
are impressed by
are taunted by
are flattered by
cede power to
are cursed by
surrender to
are underestimated by
fall in love with
are trusted by
fall in love with
are forgotten by
are pitied by
are trusted by
are worshipped by
are bitten by
are respected by
are trusted by
are trusted by
lead astray
are respected by
profit from
are disgusted by
are concerned about
are encouraged by
are deceived by
are shocked by
are bought off by
are killed by
are arrested for hurting
are arrested for killing
are pitied by
are energized by
are manipulated by
are insulted by
are bitten by
are humiliated by
are bored by
are ejected by
are upstaged by
are feared by
are distrusted by
alienate
are lectured by
alienate
are chastised by
alienate
are impressed by
are driven mad by
are entertained by
fall in love with
are intrigued by
are trusted by
are threatened by
are respected by
are trusted by
are trusted by
are exploited by
are humiliated by
are cheated by
are mocked by
are abandoned by
are pitied by
are pitied by
are respected by
are pushed too far by
fall in love with
sleep with
trust
are banished by
are favored by
are forgotten by
are favored by
are favored by
are favored by
are inspired by
lie for
are corrupted by
spread lies about
learn from
are bought off by
lie for
become dependent upon
are appointed by
are driven mad by
are driven mad by
despise
are driven mad by
hate
are driven mad by
are forgiven by
are forgiven by
are arrested for killing
are arrested for hurting
are arrested for killing
are arrested for hurting
are insulted by
are arrested for killing
are arrested for killing
are humiliated by
are underestimated by
are exploited by
are exploited by
are hardened by
are underestimated by
are hardened by
are attacked by
are attracted by
worship
impress
blackmail
fall in love with
are respected by
cede power to
seek advice from
are diagnosed by
kill
are obeyed by
are killed by
are attracted by
are diagnosed by
flatter
look up to
are attracted by
fall in love with
are betrayed by
are betrayed by
are arrested for killing
are arrested for hurting
sleep with
confide in
are lectured by
read the works of
admire
are impressed by
are taunted by
are disillusioned by
bow down to
are bought off by
are enslaved by
are freed by
are bought off by
are brainwashed by
are promoted by
are promoted by
are promoted by
impress
welcome
are enticed by
trust
are enticed by
impress
are coached by
impress
are handled by
look up to
are coached by
are coached by
are coached by
welcome
inspire
impress
are impressed by
are kissed by
impress
fall in love with
conspire with
worship
mimic
are corrupted by
are obeyed by
are deflowered by
are deflowered by
are deflowered by
lie to
threaten
spread lies about
are toppled by
mentor
inspire
are censured by
are treated by
are treated by
are recalled by
are evaluated by
are evaluated by
are radicalized by
are pitied by
are lectured by
are lectured by
trust
look up to
are enchanted by
are enchanted by
are entertained by
are entertained by
are booed by
are escorted by
flirt with
are seduced by
fall in love with
bully
are lectured by
oppress
abuse
are savaged by
are pushed too far by
condescend to
are investigated by
are censured by
are hardened by
are hardened by
criticize
condescend to
are mocked by
are obeyed by
coach
are impressed by
pray with
are intimidated by
cede power to
are pitied by
impress
impress
are seduced by
are pursued by
impress
are pushed too far by
impress
show loyalty to
are ruled by
condescend to
trust
fall in love with
flirt with
are stalked by
trust
confide in
are stalked by
identify with
are stalked by
are taunted by
are trusted by
inspire
are impressed by
are thanked by
are humiliated by
are reported by
are energized by
are flattered by
are inspired by
are impressed by
are rewarded by
fall in love with
are trusted by
are respected by
betray
manipulate
profit from
profit from
are sued by
are paid by
are oppressed by
are respected by
are persecuted by
are mocked by
are abused by
are appreciated by
are rewarded by
kidnap
are seduced by
are pushed too far by
are disgusted by
are appreciated by
are respected by
are intrigued by
are impressed by
are disgusted by
are forgotten by
cede power to
are humiliated by
are upstaged by
cede power to
cede power to
cede power to
impress
are promoted by
are stalked by
seek forgiveness from
are rebuffed by
lose control over
are spurned by
are ignored by
seek forgiveness from
are feared by
are concerned about
are impressed by
are challenged by
are respected by
are feared by
are thanked by
are thanked by
are complimented by
are flattered by
are unimpressed by
are worshipped by
are begged by
are cursed by
are obeyed by
confer with
are coached by
are trusted by
are trusted by
confer with
are welcomed by
consult
obey
are counselled by
obey
are advised by
obey
are disrespected by
are worshipped by
are inspired by
are impressed by
are respected by
are challenged by
lose favor with
destroy
devour
fall in love with
are molded by
are forgiven by
disappoint
are inspired by
are worshipped by
lose favor with
lose favor with
are humiliated by
are worshipped by
are underestimated by
kill
are insulted by
are attacked by
are cursed by
are welcomed by
enchant
are trusted by
are loved by
are worshipped by
are worshipped by
are trusted by
are trusted by
are disgusted by
are trusted by
are trusted by
fall in love with
are impressed by
are charmed by
fall in love with
are moved by
are entertained by
fall in love with
are inspired by
are moved by
fall in love with
are inspired by
are impressed by
are entertained by
are saved by
fall in love with
are moved by
are respected by
are underestimated by
are impressed by
are attracted by
are kissed by
are flattered by
are attracted by
are attracted by
are kissed by
are bitten by
are impressed by
are impressed by
upstage
are inspired by
are respected by
rule over
impress
are rewarded by
are threatened by
are worshipped by
are trusted by
are worshipped by
are trusted by
are trusted by
are worshipped by
are respected by
are impressed by
inspire
are respected by
interrogate
are respected by
are insulted by
are attacked by
are mocked by
are insulted by
are disrespected by
kill for
are seduced by
are intrigued by
are impressed by
are respected by
are taunted by
are taunted by
are taunted by
are worshipped by
are trusted by
are obeyed by
are obeyed by
are obeyed by
are trusted by
are trusted by
are thanked by
are forgotten by
let in
are flattered by
are seduced by
are concerned about
are interrogated by
are flattered by
are inspired by
receive
obtain sympathy from
are trusted by
are worshipped by
are trusted by
are trusted by
are trusted by
are worshipped by
are trusted by
are trusted by
are feared by
are deflowered by
are favored by
are coached by
mimic
are trusted by
are impressed by
are bought off by
are rewarded by
are rewarded by
are flattered by
are flattered by
are forgotten by
are impressed by
are moved by
are entertained by
are inspired by
are impressed by
profit from
are flattered by
profit from
are tipped by
are rewarded by
are trusted by
are trusted by
are rewarded by
are impressed by
are impressed by
are impressed by
are seduced by
are impressed by
are threatened by
are disrespected by
are flattered by
are feared by
rank
are flattered by
are begged by
are humiliated by
are threatened by
are threatened by
are obeyed by
rule over
are insulted by
are mocked by
are bitten by
are entertained by
are rewarded by
are moved by
are saved by
are rewarded byThe //text// property of Passage object is a string. Using the //split()// function, a string can be broken into an array containing the contents of the string "split" according to some other string.
<<set $contents to Story.get("Before Actions")>>
<<set $passageText to $contents.text>>
<<set $splitContents to $passageText.split("\n")>>
Using the third entry in the array: A $splitContents[3] B
Using the 125th entry of the array: A $splitContents[125] B
[[Random array entries]]This is a story about A and B.To get a random entry within an array, use the length of the array as a maximum when using the //random()// function in SugarCube.
<<set $contents to Story.get("Before Actions")>>
<<set $passageText to $contents.text>>
<<set $splitContents to $passageText.split("\n")>>
<<set $randomNumber to random(0, $splitContents.length)>>
<<set $randomEntry to $splitContents[$randomNumber]>>
Using a random entry: A $randomEntry B
[[Using the Include macro]]
The include macro is used to "call" or "include" the contents of one passage in another. In Twine, it is a common way to create modular content.
<<include "Before Action Generation">>
Before action: A $randomBeforeAction B
<<include "After Action Generation">>
After action: B $randomAfterAction A
<<include "Closure Point Generation">>
Closure Point: A $randomClosurePoint B
<<set $contents to Story.get("Before Actions")>>
<<set $passageText to $contents.text>>
<<set $splitContents to $passageText.split("\n")>>
<<set $randomNumber to random(0, $splitContents.length)>>
<<set $randomBeforeAction to $splitContents[$randomNumber]>><<set $contents to Story.get("After Actions")>>
<<set $passageText to $contents.text>>
<<set $splitContents to $passageText.split("\n")>>
<<set $randomNumber to random(0, $splitContents.length)>>
<<set $randomAfterAction to $splitContents[$randomNumber]>>abandon
turn against
take aim at
testify against
abuse
kill
alienate
indoctrinate
admire
beg forgiveness from
are shocked by
are bought off by
humiliate
condescend to
write about
share stories with
spread lies about
testify against
argue with
spy on
are abandoned by
are abducted by
are appointed by
are arrested for killing
are cursed by
are attacked by
are attracted by
are banished by
are beaten by
are betrayed by
are bitten by
are blackmailed by
are booed by
are bored by
are bought off by
are brainwashed by
are captured by
are captured by
are censured by
are challenged by
are cheated by
are chosen by
are coached by
are conquered by
are copied by
are corrupted by
are cursed by
are cut off by
are deceived by
are deflowered by
are defrocked by
are denounced by
are humiliated by
are deposed by
are deposed by
are despised by
are uncovered by
are diagnosed by
are disillusioned by
sacrifice
are disillusioned by
are haunted by
are disillusioned by
are radicalized by
are dismissed by
are disqualified by
are driven mad by
are dumped by
are dumped by
are ejected by
are enchanted by
are enslaved by
are entertained by
are enticed by
are escorted by
are evaluated by
are evicted by
are excommunicated by
are exorcized by
are expelled by
are exploited by
are misrepresented by
are pushed too far by
are favored by
are feared by
are fired by
are forgotten by
are found by
are freed by
are handled by
are handled by
are hardened by
are hardened by
are haunted by
are helped by
are hindered by
are humiliated by
are forgotten by
are investigated by
are censured by
are humiliated by
are booed by
are respected by
are ignored by
are banished by
are imitated by
are impressed by
are incarcerated by
are indoctrinated by
are interviewed by
are intimidated by
are investigated by
are kidnapped by
are killed by
are kissed by
are lectured by
are manipulated by
are misrepresented by
are mocked by
are molded by
are moved by
are nominated by
are obeyed by
are overthrown by
are pitied by
are promoted by
are punished by
are pursued by
are humiliated by
are pushed too far by
are rebuffed by
are recalled by
are taunted by
are recalled by
are killed by
are recalled by
are recruited by
are released by
are repaid by
are resisted by
are respected by
are rewarded by
are ruined by
are ruled by
are savaged by
are saved by
are seduced by
are shielded by
are snatched by
are sought by
are spurned by
are killed by
are sued by
are spurned by
are stalked by
are subdued by
are supplanted by
are suppressed by
are taunted by
are threatened by
are toppled by
are trusted by
are underestimated by
are unimpressed by
are upstaged by
are worshipped by
argue with
attack
attend
beg forgiveness from
believe in
betray
write about
blackmail
bow down to
brainwash
break free of
break up with
break with<<set $contents to Story.get("Closure Points")>>
<<set $passageText to $contents.text>>
<<set $splitContents to $passageText.split("\n")>>
<<set $randomNumber to random(0, $splitContents.length)>>
<<set $randomClosurePoint to $splitContents[$randomNumber]>>