Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all 1844 articles
Browse latest View live

How do you change variables with (if:)

$
0
0
the (if:) statement forces a hook at the end. How do I change a variable with a hook?

[Twine 2.1.1][SugarCube 2.14] Passing anonymous function to a widget/macro directly

$
0
0
Hey there,

This is more of a cosmetic questions, but still important to me. I'm trying to pass an anonymous function to a widget that would use that function to filter items in an inventory for me. Here's how the call looks like:

This doesn't work:
 <<listItemsFiltered $player function(item){return item.type === 'top'}>>

This works, but I'm passing a function that was assigned.
<<set $showTopsOnly to function(item){return item.type === 'top'}>>
<<listItemsFiltered $player $showTopsOnly>>

Any ideas of what I'm doing wrong here?

Can't find variable: random

$
0
0
Hi everyone,

Having an odd problem as of late (using Twine 2.1.1)

I have a common expressions:
(set: $variableName to random(0,10))

~or~
(set: $someVariable to $someVariable - random(0,10))

And both throw up this error:
Can’t find variable: random
I’ve used this syntax plenty of times without error, and not I can’t figure out what’s wrong.

Thanks!

[Twine 2.1.1][SugarCube 2.14] Traversing to a passage when a condition is met

$
0
0
Hey there!

I'm in the process of creating a way to automatically travel to a location without entering an infinite loop. Now, I've seen two methods of doing this. There's a topic about this, but I can't seem to find it (not even with google, the title must've been confusing). That concept showed using 'PassageHeader' (?, probably not, no idea...) and a boolean to send the player to somewhere else when an event is triggered.

I also remember TME posted a code, which enables one to override the next passage when a certain time has passed in game (event occurs):
This can be found here:
https://twinery.org/forum/discussion/8533/sugarcube-2-16-0-how-to-display-links-based-on-player-action-without-a-page-reload#latest

Does anyone know more methods of doing this?
Say, I have multiple quests going and I want to go to a passage when a quest is complete (an enemy is slain, a sword was picked up, you lost all your health and died, etc.). How do I manage these without conflicting?

I setup a quest system the following way:
<<set $equipEnchantedSilverSwordQuest =
{
	item: { name:"Enchanted Silver Sword", id: "enchanted.silver.sword" },
	character: $player
}>>
<<set $slayingCoboldSkeletonQuest =
{
	numEnemies: 8,
	enemyTypes: ["Cobold", "Skeleton"]
}>>
<<set $beThereOnTimeQuest =
{
        date: "20.12.428",
        time: "22:00"
}>>
<<set $silversword_log = 
{
	name: "Silver Sword Equip Quest Name",
	startPassage: "Quest - Equip Your Enchanted Silver Sword",
	onSuccess: {passage: "Battlegrounds", message: "Now go and slay some cobolds and skeletons"},
	questType: $equipEnchantedSilverSwordQuest,
	description: "This is a description for Quest - Equip Your Enchanted Silver Sword"
}>>
<<set $quest1_log =
{
	name: "Quest 1 Name",
	startPassage: "Quest 1 - Your Castle",
	onSuccess: {passage: "Party House", message: "congratulations for completing quest 1"},
	questType: $slayingCoboldSkeletonQuest,
	description: "This is a description for Quest 1"
}>>
<<set $returnBeforeNightfall
{
        name: "Quest - Return before nightfall",
	startPassage: "Quest 1 - Your Castle",
	onSuccess: {passage: "Couch - Resting", message: "You return your castle to rest until the morning."},
        onFailure:  {passage: "Graveyard - Game Over", message: "You've failed to return to your sanctuary before nightfall, your reward is death by cobolts and skeletons!"},
	questType: $beThereOnTimeQuest ,
	description: "This is a description for Quest - Return before nightfall"
}>>

// now of course you'd put these into an array and loop through them 

My question is, which special passage or Task Object would you use and how?

Sugarcube Disallow Certain Textbox input

$
0
0
Hello, I am new and using SugarCube 2.14.0

I was watching tutorials but i cant find one on how to make sure that u can disallow certain things to be input into a textbox. Say i am trying to ask for a name and they put numbers in the box how would i say make it not allow that? I am sorry about the newb question, but i am indeed a nebwbie.

[Twine 2.1.1][SugarCube 2.14][JS] Reading external JSON files and file names

$
0
0
Hey there,

I'm researching some way of reading files in the folder where my twine story is. I'm interested in reading my /images and /templates folders. Since my project will probably grow pretty large in time and I have no idea how to organize all the data (images of potraits, landscapes, characters, maps, etc.) that I'll be using in my game inside the Twine editor, I want to be able to extend my game through external files.

I would want to put images of my items, portraits of characters and landscapes into my /images folder and then .json templates into my /templates folder. Both folders would have their own subfolders.

I would like to specify the data such as properties of my game objects inside the .json file and then assign random image paths from the corresponding images folder to the object, then use 'new' and prototype inheritance to generate game objects when my twine game starts.

Example:
/images/Enemies/Goblins/Portraits holds the following files: GoblinPortrait1.jpg, GoblinPortrait2.jpg, GoblinPortrait3.jpg
/images/Enemies/Goblins/Characters holds the following files: GoblinStand1.jpg, GoblinStand2.jpg
/templates/Enemies/Goblins holds Goblin.json, GoblinSoldier.json, GoblinMaster.json, GoblinWorker.json

I would build a list of GoblinPortraits and another list for the GoblinStand images and then randomly assign the paths to these images to my Goblin enemy game objects. The properties of the Goblin enemy game object would be read from the .json file and then when needed instantiated using the new operator.

I'm very new to web development, but I'm very eager to learn and experiment.
My question is, is this possible locally on the users computer or do I have to host these files somewhere on the web? What are the possible solutions to this problem considering that I use Twine 2, SugarCube 2.14 and JavaScript?

I read that, I'd need JQuery to deserialize the templates of my game data, but I find no clear solution to reading filenames of a folder using JavaScript. It seems I'd need to setup Node.js or something to be able to read the file names, but that would turn my game into a server client... eh, it seems too much compared to the benefits that I'd gain from going through setting it up let alone getting it to run.

How do you regex an entire page before it outputs to reader? [Sugarcube 2.1]

$
0
0
Hi. Thanks for all your help.

I've been writing stuff using a lot of twinescript and I just realised I need to run a regex at the end to clean up some grammar mistakes.

Is the text printed into Twinescript saved to a variable somewhere before it's output to the page? I could just regex that in javascript. Alternatively, is there a way to make a replace function fire on the entire passage or an entire element right before it becomes visible to the reader using TwineScript somehow?

TLDR: This is basically my problem. How do I fix it without changing anything inside the print macro?
<<print "I want to edit this text so that an big elephant becomes a big elephant">>

How do I search/replace the passage using PassageDone? [SugarCube 2.1]

$
0
0
I just want to make sure everything following punctuation in a passage is properly capitalized, so I want to run a search/replace regex in PassageDone or postrender. Can someone tell me the name of the variable or object or whatever I need to perform the regex on?

Stories are Blank

$
0
0
Hi, I just started using Twine 2. Every time I Publish to File, the resulting story appears blank when I open it in Chrome or Safari (on Mac). The actual HTML appears to be intact, but nothing shows up in the browser. I've tried both the desktop and browser versions of Twine, and I have no problem playing the projects in Twine itself.

Does anyone know how I can get these stories to work on their own?

Harlowe What to type after an "If" variable, (:if $hassword is "false") = I want the player to lose

$
0
0
Hello everyone. I'm new to twine and am having trouble with Variables, specifically what to write after the above variable to create a link to another passage.

Also if there was a tutorial you could recommend it would be really helpful, thanks.

2.1.1 Harlowe 2 Debug window covers right side of game text--any fixes?

$
0
0
Hello all,
As the title says, the debug window in Harlowe2 lists all the variables in it, which is great, but it is placed over the right side of the text, hiding it. Is there any way to stop it from doing that? It doesn't seem to have a resize, but again, I could just be being dense.
Thanks

Is CSS really working differently with Harlowe 2.0? Help

$
0
0
So I was thinking about converting my big Path of Honors project to Harlowe 2.0 to get the hidden link benefits etc. I changed the story format from 1.2.3 to 2.0 and everything is now a mess that seems to go back the the CSS that worked in 1.2.3. For example this is the CSS I used in the 1.2.3 to color the whole screen

body{
background-image: url("https://historicalsimulations.files.wordpress.com/2016/11/bg23.png");
}

And it no longer works in 2.0

Also this

body{
background-color: #cccccc;
}

No longer works in 2.0 and it appears
tw-story won't change the whole story color
I'm probably just being dense, but any help on the specific selector for changing passage color, why the background-image no longer works, and if CSS is behaving differently in Harlowe 2.0 would be most appreciated. Trying to teach kids here.
Thanks!

Calling the Save Menu in SugarCube 2

$
0
0
Is there a simple way to call the save system in Sugarcube 2 without using the sidebar?

There was an old thread (here) that indicated that this snippet would work from the StoryInit passage, but it seems to be out of date:
/% Special code that triggers at startup %/
<<script>>
	$("body").append("<button id='save-sub' style='position:fixed; top:0; right:0;'>Inspect saved games</button>");
	UISystem.addClickHandler("#save-sub", null, function () { UISystem.buildSaves(); });
<</script>>

Thanks! Sorry if I missed something in that thread... it went over my head quickly.

How to add multiple save slots in Harlowe 2.0 and auto add save/load links on passages?

$
0
0
Is there a way to add more than one save slot using

{(link:"Save game")[
(if:(save-game:"Slot A"))[
Game saved!
](else: )[
Sorry, I couldn't save your game.
]
]}

also, is there a way to generate templates? Like, a save/load template for passages?

using symbols with If statements using variable In Harlowe 2.1.1

$
0
0
Ive been having some trouble. I don't know if twine just doesnt support what im trying to do or if there is another way to go about it. basically when a variable reaches a certain point i want something to happen. however since it deals with negatives and positives and the exact number they could have can change I can simply say
(if: $var is -1)[ blah blah blah]
Here's what ive been doing and there is not error message it just doesn't do what is after the if statement even when it is a negative.
first passage is this.
(link: "test")[(set: $affection to -1)(goto: "test2")]
this is on the second passage test2
(if: $affection is < 0)[ You are dead.]
(print: $affection)
When it prints the variable it is indeed -1 however it does not show the you are dead text. any help would be appreciated.

Traverse all passages

$
0
0
I have stuff like: <<timed 21s>> in my passages. Each one has it. Is there a way to traverse all the passages in a recursive manner and calculate the most amount of time that a user can go from passage X to passage Y ? I know there are possible issues of infinite loops, but I'll handle that. I first need to figure out if I can traverse all the passages, how to get a reference from one passage to any other that it points to and then retrieve the `timed` value.

Any ideas?

&&& || if statements.

$
0
0
sugarcube 2.17
I've notice that when I and(&&) or or(||) if statements together to make it into one if there is even a simple add or subtraction in the statements they get skipped, or not evaluated. Like
<<if (sim1.age - sim.age2 > 10) && (sim1.relationship >= 4)>> will allow the first test to pass every time, but if left as a single test if it works as it should. Is this a bug?

Change font color based on variable

$
0
0
Hello,

I want to change the color of something I write based on a story variable.

For example I could use this:
<<if $variable lt 2>><span style="color:blue">TEXT</span><<else>><span style="color:red">TEXT</span><</if>>

But I want to change the color of the text in A LOT of passages and using the above would mean a lot of repetition.

Is there some kind of Javascript with which I could do the if-check on every load of a passage and modify a CSS style element?

having trouble with basic inventory

$
0
0
Hello I am completely new to this and I have been pouring over forum links and the Harlowe wiki and for the life of me I can't figure out what is wrong.

I started with this site which gave the the basics but its an array. I am going to use just word based things so I think a data set would be better (ds:) so i added that instead.

I would like to have a thing that only displays a link if you have something in your inventory.
here is my code:
"I dont know much, but I know I am feeling like spagetti. Here is a list of ingredients."
(set: $inv to $inv + ("list"))

[[Do you have any money?|money]]
(if: $inv is in ("some money"))[[Go outside|outside]]

and I keep getting
the number 0 cannot contain any values, let alone the string "list"
and I can't figure out how to fix it. Did i get the syntax wrong?

[Harlowe 1.2.3] Startup Passage seems to break formatting on the following passage

$
0
0
Hey guys -

I've built a passage with all my initialization variables with the startup tag, and it seems to work fine and indeed establishes variables no matter where you jump into the story, but it does break the formatting on the first line of whatever passage you start at.

So for instance the Story Starting Point's first line is the title of the game using Heading markup:

#Title of the Game

Works fine without a startup passage, but with the passage it prints it as unmarked up text, showing the Hash.

Tried a few things, adding carriage returns, etc, but it seems to always close the whitespace and then disable that first line's markup. Any tips on a fix?
Viewing all 1844 articles
Browse latest View live