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

Creating If Else Statement

$
0
0
Hey!

I'm trying to use If Else statements to display particular passage text depending on the player's previous choices.

Passage C is reached by the player through Choice A or Choice B (this has a longer path).

I want to display certain text is the player reaches Passage C through Choice A and different text if reached through Choice B.

I've looked at tutorials but can't seem to figure out how to phrase my statement to make it work. I'm using Harlowe on Twine 2.

Triggering a twine sugarcube widget with javascript?

$
0
0
Hello all. Simple question... how do I trigger a twine widget from pure javascript code?
setup.enemycd = function () {
	var elem  = document.getElementById("enemycdbar");
	var width = 1;
	var id    = setInterval(frame, state.active.variables.enemy_cd2);

	function frame() {
		if (width >= 100) {
			clearInterval(id);
                        <<twine_widget>>;
		}
		else if (state.active.variables.enemy_is_stunned != 0) {}
		else {
			width++;
			elem.style.width = width + '%';
		}
	}
};

Basically once the width of the "enemycdbar" hits 100%, my <<twine_widget>> is triggered. Obviously the "<< >>" syntax is just to show what I'm trying to achieve, I know it's not the right way to do it in pure javascript >_<.

Help debugging this HTML please

$
0
0
Hey!

I'm still pretty new to Twine and teaching myself basic HTML and CSS. Wondering why this piece of code isn't working? Have tried debugging myself to no avail.

<div class="fade-in four"><i><span class="zuberitext">"Character A speech"</span></i></div>
<div class="fade-in five"><b>"Character B speech"</b></div>
<div class="fade-in six"><i><span class="zuberitext">Character A speech
<div class="fade-in seven">More of the same speech from Character A
<div class="fade-in eight">End of the same speech from Character A" </span></i></div>

<div class="fade-in nine">Do you [[choice|passage]]? Or do you think [[choice|passage]]?</div>

I removed the particulars of the story just to give an idea of the passage shape. The classes I have are a timed fade in for text and particular colour for Character A's speech.

Any ideas greatly appreciated, cheers!

Help debugging this HTML please

$
0
0
Hey!

I'm still pretty new to Twine and teaching myself basic HTML and CSS. Wondering why this piece of code isn't working? Have tried debugging myself to no avail.

<div class="fade-in four"><i><span class="zuberitext">"Character A speech"</span></i></div>
<div class="fade-in five"><b>"Character B speech"</b></div>
<div class="fade-in six"><i><span class="zuberitext">Character A speech
<div class="fade-in seven">More of the same speech from Character A
<div class="fade-in eight">End of the same speech from Character A" </span></i></div>

<div class="fade-in nine">Do you [[choice|passage]]? Or do you think [[choice|passage]]?</div>

I removed the particulars of the story just to give an idea of the passage shape. The classes I have are a timed fade in for text and particular colour for Character A's speech.

Any ideas greatly appreciated, cheers!

[SugarCube] actions macro eliminiates all links to the same passage

$
0
0
Took me a bit to figure out why all my links were disappearing:

I'm using the <<actions>> macro to give different actions (set with a variable) to use in another passage, like so:
<<actions [["Method 1 - Shake"|Experiment][$method to "shake"]] [["Method 2 - Stir"|Experiment][$method to "stir"]]>>

This lets me click on one of the actions once, but then all other actions with the same passage destination also disappear. Is there a better way to do this? Or is this just a bug in SugarCube?

(tested with SugarCube 2 in both Twine 1 and 2)

the software don't work

$
0
0
hello ! i just download the software and it's worked in first time to see how it's work ,but, it closed after 10min and now it don't want to work anymore and it give that window and close
IKzmfzX.jpg
mKUrCnD.png

Harlowe 2 Passage editor bug?

$
0
0
Help, this is driving me crazy:
5Lo7jky.png
Does it only happen to me??
That "line count dot" hides the text I'm writing it REALLY bugs me.
Only happens with Harlowe 2.
Happened to me on the online editor, with Firefox AND Chrome, and also on the offline Twine software.

How to make a time system?

$
0
0
Hi everyone, I'm having a lot of problems trying to make a time system for my game. I want a sturdy time system because I want to make a business managment simulator kind of game, so I have to keep track of the day of the week, the day of the month, the month and the year, so this are my variables.

$hour
$minute
$weekday
$monthday
$month
$year

I need the game to do the basic maths while you are playing, like not going over 59 minutes or over 23 hours. I tried setting up a conditinal.

<<if $minute > 59>>
<<set $hour += 1>>
<<set $minute -= 60>>
<<else>>
<</if>>

Its the only thing that I can think of. For days of the week, I think it would be cool to have like a string of the seven days of the week and that when $hour reaches more than 23, the hour should go down to 0 again and the day of the week and the day of the month should change.

I dont really know if this or something like this has been answered here, but i searched for a bit and didn't found anything useful.

Thank you for your time and I will be happy to listen to every piece of advice that you could give me.

Proofing Without Codes

$
0
0
I've been trying to export a pdf proof copy from twine. But it always shows the codes too:
<<set $x to 0>>
or
[[LinkText|Passage]]

Is there a way that it would just print the text in the passages and not the accompanying codes too?
(I'm following the suggestion on importing published story from offline version of twine to the web version to export to pdf.)

Using:
Twine 2 2.1.0(Downloadable)
SugarCube 2.16.0(Offline)
Mac OS El Capitan

[Sugarcube 2 2.14.0] How do I build a generic item shop?

$
0
0
Hey lads, I'm trying to build an RPG of sorts, and want the player to be able to visit a shop and buy and sell things. For this, I have created a passage called TestItems, which looks like so:
<<set $itemStrawberry = {
	name: "Strawberries",
	description: "They look so yummy!",
	categories: ["fruit", "food"],
	value: 2,
}>>
<<set $frogLiver = {
	name: "Frogman Livers",
	description: "You don't want to remember how you got these.",
	categories: ["utility"],
	value: 500,
}>>
<<set $magicPole = {
	name: "The Utdraig",
	description: "A fishing rod from the days of legend, said to always catch a fish no matter where you throw it.",
	categories: ["fishing rod", "tool", "weapon"],
	value: 500,
}>>
<<set $donut = {
	name: "Doughnut",
	description: "You're not sure what it's filled with, but it's probably fine.",
	categories: ["pastry", "food", "dish"],
	value: 5,
}>>

<<set $itemlist = [$itemStrawberry, $frogLiver, $magicPole, $donut]>>

This gets included in StoryInit, so the list is always available.

I want there to be a generic item shop, so that each individual shop the player encounters contains an array of indices corresponding to the items I want that particular shop to sell. That would look like this:
<<set $testshop = {
	name: "Random Tat",
	stock: [0, 2, 3],
}>>
Now to my problem. I want to be able to generate a list of links which each would perform the respective transaction, ie. I'd get a link for the strawberries, clicking on it would then add the strawberries to my inventory and remove my money. Thing is, the only way I can come up with to do so seems to be a for-loop building a click event for each item, but in doing so all the links would break since they'd all point to an empty object:
Welcome!
$testshop.name currently carries:

<<for _i = 0; $testshop.stock[_i] < $itemlist.length; _i++>>
	<<click $itemlist[$testshop.stock[_i]].name>>
		<<addToInv $itemlist[$testshop.stock[_i]].name>>
	<</click>>
	<<print $itemlist[$testshop.stock[_i]].description>>
	
<</for>>
Just to reiterate, I'm aware that this code doesn't work because _i is only queried after building the page, by which point it is equal to $itemlist.length.
The inventory system is currently an array which doesn't allow multiple identical objects to exist (taken straight from the link in the Twine 2 Guide, since I'm completely new to all this). This is, however, irrelevant because the issue remains that no matter which link I click I get an empty object. My question thus is, can I somehow save each iteration's number value to draw from when clicking a link, or, if not, what else could I do to make this work instead? Can I avoid to hardcode each shop's inventory?

I thank you all in advance,
vm.

Edit: Added Sugarcube version number.

Can't figure out how to remove unwanted skipped line

$
0
0
(Using Harlowe 1.2.3) I have a passage that contains text for two separate scenarios ($step 1 and $step 2). The problem is with (else-if: $step is 2), when I test or play this step, the text skips the first line and is below where the text on all my other pages start. I attempted to use the tips in the Harlowe 1.2.3 manual for 'collapsing whitespace' and 'escaped line break', but they didn't help, and any tinkering I did to my $step 1 text would only result in errors.
Is there any way to remove the line skip?

Twine is refusing to open, then quitting.

$
0
0
Just having responded to someone on this forums, having played round with a solution on twine. (Twine 2.1.0) I decided to check out Harlowe 2.0.0 and check out experimenting on format change. I accidently clicked on the language tabe, and couldn't escape it. Not working out how to escape it, I clicked on the British flag. This however seems to have caused a catastrophic failure in Twine. It can no longer open properly, al I can see is a white space and an unclickable bar with 'Twine and 'edit' at the top. I shut down my computer, restarted, still the problem persisted. I unistalled, and re-installed the latest Twine 2.1.1, that too fails to open. I fear have corrupted some underlying setting the user preferences the application relies on? Any help greatly appreciated!

Deactivating Link

$
0
0
I've been playing around choice links and it does what it does.
What about if I just want to deactivate a link once it was clicked? And the other links are not affected?
Because
<<choice ...>>
deactivates the other choice links too.

Using:
Twine 2.1.0(Download - MacOS)
SugarCube 2.16.0

Javascript with Sugarcube

$
0
0
Hi. I'm new to Twine and I've spent the last three hours trying to find something in the documentation or forum that explains my question, but I've completely failed. I'm sure this has been answered somewhere before. I'm sorry for asking again.

I want to run loops manipulate arrays in javascript using functions, and return those values for use in my normal twinecode. I really only need like three java functions for the game I'm planning on setting up, but I can't figure out how to call them from the Edit Story Javascript area. I read that for Harlowe I needed to use a global object, so I just sort of did that here for Sugarcube. IDK what I'm doing at all.

Can anyone explain to me how to make the following function run in Twine? Thank you so much for your time.
if (! window.rollevent) {
	window.rollevent = function() {
	  var sum = 0;
	  for ( i = 0; i < events_All.length; i++) {
		  var sum = sum + window['event_'+events_All[i]]
	  };

	  var i = 0;
	  var total = 0;
	  var random =  Math.floor( Math.random() * sum );
	  while (total < random) {
		  var total = total + window['event_'+events_All[i]];
		  var choice = events_All[i];
		  i++;
	  };
		return choice;
	}
}

[Dating Sim] [Twine 2.1.1] [SugarCube 2.14] Newbie. Help With Dating Simulator

$
0
0
I am making a dating sim and need to know how:
*To display images
*Add and play Music or effects
*Type in for correct answer(And change to next passage)
*Custom Naming of Character and able to post name
*make variables for love and hate
*Gauge for love/hate
*locking passages to where they can't be clicked unless love is enough

Just got into Twine and need help. Thanks for the help!

How do I get rid of the bg block/change opacity?

$
0
0
Hello!
This seems like it shouldn't be too difficult, but I can't find the answer anywhere. The default for Sugarcube is a black box with white text. I'd like to be able to do both of these things:

: get rid of the black box so I can just make it black text against a light bg image (I know how to put in the bg image)

and

: change the opacity of the box

Thanks!

Send the player to a passage without him doing something

$
0
0
I use Sugarcube 2.+ version.

I´d like to know a command that sends the user directly to a passage, without having him click on anything.

e.g. if certan criteria are met and player gets to passage x, he is directly redirected to y then. While if the condition is not met, he may stay in x.

Inventory System (Sugarcube 2.0 / Twine 2)

$
0
0
Hi all,

Right now, I've got a very makeshift inventory system going. Basically, I've created a variable for the player's weapon and armor ($player.weapon and $player.armor respectively), and I'm changing the value depending on what they've got in the slot.

However, it occurs to me that this isn't the most flexible approach I could be using, and doesn't leave a lot of growth room for different items or scenarios. E.g. Having multiple weapons in your inventory, dropping weapons, selling weapons, using one-use items, etc. Ideally, the inventory would be accessible from the side-menu - I already know how to create links in it and have already added a few.

I'm sure I could probably come up with some sort of system to do this. But I'm pretty sure given the prevalence of SugarCube games, I'd probably be reinventing the wheel.

In short, does anyone have any inventory system code that I could take and throw into my game? I've used Google to scour the site, but I haven't run across any inventory system code that seems explicitly safe to use for Sugarcube 2.0.

A link to an existing explanation is fine if I'm just doubling up on a common request, which I'm fairly sure I am. :)

[Twine 2.1.1][SugarCube 2.14]this.error propagation in JavaScript, how do you do this the right way?

$
0
0
Hey there!

So, I got one of those questions about coding.

I have the following problem:
Say, you have two JS functions, where one JS function calls (not mutually of course) the other function and a SugarCube macro that calls one of these JS functions.

So you get a call stack of:
// Use case 1
<<mySC2Macro>> -> func1() -> func2()

now, both func1() and func2() use the this.error() to output exceptions when an error occurs. This happens because sometimes func2() is called in some of my macros as is and not through func1(). So, we get the following scenario:
// Use case 2
<<myOtherSC2Macro>> -> func2()

Now, the problem is that, if we go through use case 1 (or use case 2, it doesn't matter, since the macro context is not passed) and an error occurs in func2 and we have not passed the macro's context (this) over to func1() and then over to func2(), we get an error message that says "this.error()" is undefined. Which does not help at all to find out what went wrong, even if you try to print the error prior to return this.error() that console.error() for some reason doesn't get executed (yeah, sounds like an anomally, I haven't got the slightest clue why that happens. It maybe has something to do with how the broswer executes JS and finds the error (missing error() function in 'this') before executing the actual script.).

My question is, how do you throw exceptions properly in SugarCube 2? Do you carry the macro context (this) over all your functions or do you use something fancy like "throw new Error()"? Or maybe something completely different?

Also, does anyone know a good lexer or any kind of context aware code editor for JS? I'm sometimes driven crazy by the type failures that I do while editing my code and tend to pass the wrong variables to my arguments, causing all kinds of errors that takes me hours to debug using console.error() and console.log().

Disappearing font macro effect

$
0
0
I think I may have come across a bug (but more likely its me). I've insert a font macro into one of passages, to bring up a webding.
(css:  "font-size: 0.65em")[(font: "webdings")[P]
]

So far so easy, in CSS I started styling the tw-story without issue. What I have found is that when using the CSS belowm stopped the (font:) macro from rendering.
tw-story {  
    font-size: 1.1em;
}

Changing the font-size to a percentage worked out fine however.
tw-story {  
    font-size: 125%;
}

Im guessing this has something to do with the (css: ) macro clashing with the CSS somehow.
Viewing all 1844 articles
Browse latest View live