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

Okay seriously last question.

$
0
0
I feel so bad for asking so many questions but this is the first time I ever took a project in twine so seriously
<<if $Level >= 2>><<set $EnemyName to either("Strong Bandit","Feral Orc","Mechanical monster","HyenaThief")>> <<else>> <<set $EnemyName to either("Rookie","Thief","Contraption","Drunk Dwarf")>> <<endif>>
for some reason this code keeps getting either a missing
child tag <<endif>> was found outside of a call to its parent macro <<if>> or the <<else>> was outside macro
Any solutions?
sorry to bug

Make a variable appear in a link

$
0
0
Hey everyone. First off, I'm using Twine 2.1.1 with SugarCube 2.14.0

I've got a section in my StoryCaption passage where I want to have a popup link (I've already set the java and css for it, and they work fine) display the inventory of the player.

However, before I set this as a popup I just had it list in the StoryCaption. A neat trick I did was ask the player their name, and then changed 'Your Inventory' to '$self's Inventory' with $self being the variable for storing their entered name. EG: Hank's Inventory.

Now, it displays as '$self's Inventory' and does NOT display the entered text, but the actual variable name. How can I make it display the name?
<<if $self is "Nobody">><<popup "Your Inventory" "Inventory">>
<<elseif $self isnot "Nobody">><<popup "$self 's Inventory" "Inventory">>
<</if>>

I've also tried writing it as
<<popup $self "'s Inventory" "Inventory">>
and it works...but it does NOT display 'Inventory'...just the name variable.

Drag and drop bug, 2.1.1

Booleans as numeric values

$
0
0
Hi all,
in twine, are the numeric values of "true" and "false" guaranteed to be 1 and 0 respectively? I know that in some other languages, you only know that "true" is nonzero.

The reason I'm asking is that I'm trying to do something like this:
<<set $kindness to $walked_dog + 2*$fed_horse + 5*$rescued_kitten>>
and I would like to be sure that the result will be 8 if those three things are true, no matter what computer this game is played on.

The alternative would be to do
<<set $kindness to 0>>
<<if $walked_dog>><<set $kindness += 1>><</if>>
and so on, but that's horrendous and I'd rather not have to.

I am using Twine 2.0.11 and Sugarcube 2.14 if that matters.

[SugarCube 2.12.1] Cleanest way to handle JavaScript intervals and window properties on restart?

$
0
0
Hello again,

I have run into a bug with my internal game loop, and while I've already come up with a couple of ways I could fix it, I'd still like some advice on the cleanest way to go about it.

For the curious, a WIP of the engine mechanics I'm working on can be seen here: http://rokiyo.net/games/cetacea/Story%20Engine.html

@TheMadExile, I would really appreciate your thoughts on the below, though I also welcome any advice anyone else has to offer too.

Issue summary
To start an internal game loop at around 30 ticks per second, I run the following code within StoryInit (because it seems to be one of the last things executed during story loading):
<<run window.tickTimer = window.setInterval(window.gametick, 33)>>

When calling UI.restart(), the restart is performed without a page load, which means the above timer is not cleared. This causes two primary issues:
  • Multiple timers running at once, all of them calling window.gametick more often than expected.
  • window.gametick getting called during story initialization, before specific story variables and DOM elements have started existing.

Potential solutions
I can think of several ways to address some of these issues (though none of them strike me as ideal):
  • A singleton-style approach: <<run window.tickTimer = window.tickTimer || window.setInterval(window.gametick, 33)>>
  • Hook into an Engine.restart() to clear the interval, possibly by rebuilding a custom UI.restart() dialog via the API to call some cleanup code if the user confirms the restart (e.g. clearInterval(window.tickTimer)).
  • Wrap window.gametick in a try/catch block to silently discard any errors that occur from it running on load.
  • Something involving the options parameter on UI.restart()? I don't understand the documentation within Dialog.addClickHandler() enough to know if I've missed something obvious here.

Conclusion
So yeah, there are a few ways to go about it, but all of them strike me as a little bit "hacky". I'd really appreciate a second opinion on a better approach to this.

The other thought on my mind is... If intervals aren't being cleared during Engine.restart(), does that mean all the other stuff I'm attaching to window isn't getting cleaned up either? I mean, I guess it all gets overwritten when the story JavaScript gets rerun, but I'm wondering if it would be cleaner to have some kind of shutdown task object that only gets called during a restart?

iterate through an object sugarcube 2

$
0
0
I know how to iterate through arrays with for loops, but is it possible to do it with objects such as?
<<set $char={
	stats:{
		health:{name:"health",val:90,max:100,min:0,type:0},
		mana:{name:"mana",val:10,max:50,min:0,type:0},
		str:{name:"str",val:8,max:10,min:0,type:0},
		int:{name:"int",val:2,max:10,min:0,type:0}
	},
	desc:{
		name:{name:"name",val:"bob"},
		age:{name:"age",val:29}
	}
}>>

How can you iterate through that object and get the val for all of the objects in stats for example? I have tried using Object.keys, but once i get the name of the object i am stuck.

Thanks

Back to last passage and random generation

$
0
0
Twine version 2.1.0
Sugarcube 2.21.1

I'm currently writing a Twine game for my University assignment but I've got a few obstacles I can't overcome.

Within some of my passages, I've got descriptive passages which appear in multiple locations. I'm having trouble creating a "Back" link which returns to the previous passage.

The other query, I'm trying to create a passage which randomly generates a street of buildings using some basic parts.

StoryInit
<<set $Shops to either("Large grocery store","A small brothel")>>
<<set $House to either("A single room apartment","An unlit dormitory")>>
Streets
While walking through the alleys, you pass <<print $Houses,$Shops,$Houses>>

If someone could be kind enough to help, I'd really appreciate it.

Many thanks

Time System

$
0
0
Using the below time system, how would I set the current hour to a specific hour without changing any other fields (days, years, months, etc.)?

/* A method to change a date using intervals */
if (! setup.changeDate) {
setup.changeDate = function(date, interval, units) {

var d = new Date(date); // Don't change original date.

switch(interval.toLowerCase()) {
case 'years':
d.setFullYear(d.getFullYear() + units);
break;
case 'quarters':
d.setMonth(d.getMonth() + 3 * units);
break;
case 'months':
d.setMonth(d.getMonth() + units);
break;
case 'weeks':
d.setDate(d.getDate() + 7 * units);
break;
case 'days':
d.setDate(d.getDate() + units);
break;
case 'hours':
d.setTime(d.getTime() + units * 3600000);
break;
case 'minutes':
d.setTime(d.getTime() + units * 60000);
break;
case 'seconds':
d.setTime(d.getTime() + units * 1000);
break;
default:
break;
}

return d;
};
}

[Harlow 2.1.1] There is something wrong with the editing passage

$
0
0
So I was using Twine 2.0.0 until it stopped displaying colours. And then for some reason it wouldn't let me copy and paste through keyboard and instead I had to manually copy and paste with a mouse. But for some reason when I did that, it forces the layout of the passages to move right against the left side of the layout. Which was annoying since I needed to copy and paste to the right side of the layout.

So I decided to uninstall Twine. Then reinstall it with Twine 2.1.1 and this happens: the edge of the left of the passage window has this bar with dots on it.

7Psswub.png

Is this intentional? I checked with the other formats and all it is is that the text is forced to be close to the edge as possible.

faMb59N.png

The reason I'm asking for help is that I like being able to see my text and code, but with that sidebar thing, I can barely make out what is the first letter or symbol. I was wondering if it's just me or there are others who are affected by it. My temporary solution is to switch to another format to edit, then switch back to play the game.

Adding something dynamically to the current passage

$
0
0
Hi, everybody!
How can I set up in the current passage a link (to another passage) that is created or becomes visible when a certain condition becomes true? A pseudo-code would look like:
if $myvar >= 14 then the link to passage B is created or becomes visible

I use Twine 2.1 and Harlowe 2.2.
Thanks in advance.

Anchor linking within a passage sugarcube2 and in general

$
0
0
I'm trying to do a back to the top link.
I did manage to do it by saying [[Back to the top|first passage]].
However when I switched to another story format(protagonist) it didn't work.
I'm wondering if there's a general type of scripting that might work across most story format.

Randomized backgrounds per passage

$
0
0
Hello! I've been trying to add backgrounds to specific passages in a Harlowe Twine 2 project using javascript. It's fairy easy to show a random background image from a directory attached to <body onload="..") but that would only randomize the background when reloading the game, which is not what I want.

The closest thing to a solution I have seen is this- http://twinery.org/forum/discussion/2529/harlowe-1-0-1-javascript-dynamic-background-images which is doing something with hidden inline images that doesn't quite make sense to me.

Is there another way to do this? Again, what I am attempting is to pick a random numbered image from images/ as a page background, but only for specific passages.

Thanks in advance!

"While" loops

$
0
0
Hi, all!

With Harlowe, how can I exit a "for" loop based on a certain condition, thus simulating a "while" loop?

Thanks in advance.

Background Music in Harlowe

$
0
0
Hi all, I've made a few Twine fictions using Twine 2 (whatever the most recent is, it's all updated on my computer) and Harlowe 1.2.1. I am fairly dedicated to using Harlowe, since I do well with the macros and don't have time right now to teach myself a whole new story format.

I am looking to include just one sound in my story if possible. I just want an ambient soundtrack of "space noises" in the background of the passages. It is about 14 minutes long, so if the reader continues to play I would like the soundtrack to loop if possible. It doesn't need to change based on passage, just keep playing in the background. Is there a way to do this in Harlowe? I know that everyone here argues that SugarCube is better for sound, but I'm hoping that since this is fairly straightforward, someone can help me manage it in Harlowe.

Thanks!

using font-face in Twine and exported HTML file

$
0
0
Hi everybody,
I'm using font-face with multiple fonts, on Twine 2.1.0. The fonts are stored on a server and the link specified in CSS url is with an absolute path to this server. I'm absolutely sure it works cause fonts aren't installed on the system, It has to download it from the server.
It works fine in Twine but once I export a HTML file, font-face doesn't work anymore in the browser (Firefox).
Any idea ?
Thanx,

PS : So, I get a black blank screen on Edge with some Twine HTML exported files (Yes I know it's popular to bash MS browsers, but Edge isn't IE anymore and really do pretty fine on a lot of things, so...)

Find and Replace not Replacing Anything

$
0
0
Hello,
I'm a newbie using twine 2.0 with Harlowe version 1.2.3 (the default story format). I'm trying to use find and replace. Whether I try to say replace all or select a particular passage and choose to replace within it, the function seems to have exactly zero effect. If it matters, I'm using a downloaded version in Mac OS.
Thanks,
Sam

Twine (Sugarcube 2) has stopped creating new passages with new links. Is there a simple solution?

$
0
0
Basically, when I type standard links into a passage eg [[linkylinky]] and [[linky2]], twine sometimes will only creae one passage, and sometimes will create neither. If I manually create the passage, it then links them. Have I done something weird with a setting somewhere? Should I uninstall and reinstall? Would love some advice if anyone recognises this problem.

Twine 2, Sugarcube 2, Linux version (running on Mint).

Statement with "(If: $value1 is false OR $value2 is false)"

$
0
0
Hello everyone !

I'm completely new to Twine. I tried a first simple story, but then of course I wanted to complicate it a bit, and that's when everything went wrong :)

Here's my problem : I created a story with 3 rooms to look into. The player has to go into the 3 rooms or into 2 specific one of them to continue with the journey. Let's call the rooms $room1, $room2 and $room3.

So basically :
- The player goes to $room1 and $room2 (or $room2 and $room1) then $room3 --> He follows the journey
- Or he can go to $room3 first, then $room1 and $room2 (or $room2 and $room1) and at this point he is forced to go back to $room3 again to continue (a text "come back to $room3" appears when this is the path chosen).

What I want Twine to understand is this :
If the player went to $room1 <b>OR</b> $room2 when he gets to $room3, then a specific text appears <b>AND</b> he can visit [[room1]] if that's the room he didn't go into, <b>OR</b> [[room2]] if that's the other one.

I thought this could work :
(if: $room1 is false or $room2 is false)[Specific text]
(if: $room1 is false)[ [[Go to room1]] ]
(elseif : $room2 is false)[ [[Go to room2]] ]

But it doesn't work... I'm wondering if this can be linked to the fact that there is a lot of different conditions according to the path the player chooses ?

Cause there are 3 possible ways :
(If: $room1 is true <b>OR</b> $room2 is false)[specific text 1]
(If: $room1 is true <b>AND</b> $room2 is true) [specific text 1 + <b>[[New path]]</b> ]
(if : $room1 is true AND $room2 is true <b>AND</b> $room3 is true] [specific text 2 + [[New path]] ]

I'm sorry if I don't explain very well ! I'd really, REALLY appreciate if you could give me your ideas about how to make it work ! Thanks a lot !!! :D


Moving passages around in the new version of Harlowe

$
0
0
As you may know, Harlow was recently updated with a new look. One side effect of this new look (for me, anyway), however, is being unable to move passages. I move passages around in my story to help keep things organized when I'm adding to it. Now, I am unable to move passages, and thus unable to continue my story because I cannot keep track of everything. So, here's my question.

How do you move passages around in the updated version of Harlowe, if you can at all? Thanks in advance!

Adding onclick script to a link in a passage on Harlowe - getting syntax errors

$
0
0
Hi all,

I am trying to add the below to a link in a passage on Harlowe. I either want the script to execute when that passage loads or when they click on a specific tag. I'm having trouble because I keep getting syntax errors. Anyone know how to solve this?

Here is the one that I did onclick, it's on an a tag but I would prefer to do it on a link in Harlowe:

<a href="www.google.com" Onclick="javascript:xapistatement('experienced','http://google/linked','something about this','this a description that I won't see right in the LRS')" >Clicked</a>

Anyone have any ideas on how to do this?
Viewing all 1844 articles
Browse latest View live