Quantcast
Channel: Twine Forum
Viewing all 3830 articles
Browse latest View live

How to store strings and vars inside another var

$
0
0
Sorry if I wasn't clear, maybe I don't know how to explain, only showing.
Let's suppose I have this:
You've found a shield!(click:"shield")[(set: $inventory to it + (a: $shield))]

So when the player clicks "shield", the item (set in another place) will be stored in my "items" array.
But write all this code all time where there is an item can bloat the code a bit. How can I, if possible, do something like:
You've found a $itemshield

where $itemshield is (link-reveal:"shield")[(set: $inventory to it + (a: $shield))]?

Problems with (set:) and (live:) and (transition:)

$
0
0
Hey,

I'm using Harlowe and I want to use the transition macro to make a text constantly pulse. Now as I read the transition-time command doesn't work at all, so I made it work like this:


(set: $wub to "Wub wub wub wub wub wub wub wub wub wub")


(live: 0.6s)[(transition: "pulse")[$wub]]

I'm pretty new to coding and I can't find a way to save all those attributes to $wub. There's always an error, a string can't be saved with a value, blabla.

So is there any way to have this (live: 0.6s)[(transition: "pulse")[$wub]] or maybe this (live: 0.6s)[(transition: "pulse")[Wub wub wub]] somehow saved together as one thing?

The only thing I have managed was this:

|wub>[(live: 0.6s)[(transition: "pulse")[Wub wub wub]]]
|bam>[(live: 0.6s)[(transition: "pulse")[Bam bam bam]]]
|uz>[(live: 0.6s)[(transition: "pulse")[Uz uz uz]]]


(live: 3s)[
(replace: ?uz)[(either: ?wub, ?bam, ?uz)]]

I've played around with (either:) but it usually just ignores the (live: 0.6s)[(transition: "pulse")] completely.

And then there is the problem that even if it did work I still had those lines on top because of the named hooks.

I just want [(live: 0.6s)[(transition: "pulse") assigned to a text, and this as three different $whatever, and then swap them every 3 seconds while they keep pulsing like annoying music.

I also tried doing it by hand and without setting up anything, but it seems the different live macros are interfering with each other and also it's quite confusing. I wish it was possible the way I want it with nicely assigned variables I can just shuffle.


What I want is basically this:

(set: $wub to (live: 0.6s)[(transition: "pulse")[Wub wub wub])

{(live:3s)[
(either: $wub, $uz, $Bam)
]}


Despite the fact I can't manage to put this [(live: 0.6s)[(transition: "pulse")[Wub wub]] line in one $whatever.

Please help.


Hide Header/Footer in some Harlowe passages?

$
0
0
Hi all,

I want to keep my header/footer hidden in some introductory passages (maybe 20) until the variables they contain need to be seen by players. How can I do this?

Thanks in advance.

Font changes size depending on how much text the passage is displaying

$
0
0
I couldn’t find anything on the forum about this. I’m using Harlowe. I’m trying to make my stories look pretty in mobile devices but text is always too small, even when I override the… 6 screen sizes, I think, Harlowe CSS handles by default. The weird thing is, my CSS text resizing works when the passage has enough text in it.

Replicating it: So if you create a regular Harlowe story with a single passage reading (set: $step to "")(live: 0.1s)[(set: $step to $step + " step")$step] (this will make the word “step” to be repeated over and over) and run it on a small enough phone (mine is 382x679 px), the font will look really small and after the 25th iteration or so it’ll jump to a larger, more readable size. I can’t replicate this on desktop, no matter how small I make the window running the story.

Is there a way to correct this from my end?

css background border around text

$
0
0
Hello i would love to make a background image with css, and than add a border around my text where the background of this box around the text is black and like 40% that you can look through. That all with css for all sites.
I hope you can understand what i mean, and hope for some answers.

twine 2 harlow

Strength checks?

$
0
0
Hi again.

I'm using Harlowe. I used this code in order to allow characters to set their attack:

Attack: [$Attack]<Attack| (link-repeat: "+")[(if: $points > 0)[(set: $points -= 1)(set: $Attack += 1)(replace: ?Attack)[$Attack](replace: ?points)[$points]]] / (link-repeat: "-")[(if: $Attack > 0)[(set: $Attack -= 1)(set: $points += 1)(replace: ?Attack)[$Attack](replace: ?points)[$points]]]

How do I code it so that their attack has an effect? You're meant to pass a strength check to open a chest, and I've got:

(if: $Attack is >5)[text here [[Open chest.]]]

But obviously, that's not working, and I'm not sure how to edit it.

Sorry for being such a novice!

Calling on Java script in a passage [Sugarcube, Twine 2x]

$
0
0
I'm assuming that javascript is interchangable between both versions of sugarcube here so I sincerely hope I am right x)

So I had been browsing the Sugarcube wiki for some time and still hadn't found too much relevant information to what I was looking for.

I was searching for a method to have 6 $object values that were completely randomised from a set amount from 0 - 150, but added up together would always add up to a certain amount say 600 or 150 (not both though but I havent decided on the final amount). I would also like to avoid decimals places in the concurrent values at all costs if possible.

I didn't have much luck on the twine databases I had found, but I did manage to find some javascript relating to this issue on a javascript website dubbed Stack Overflow. However, problems automatically arose as I could not find much in detail upon how to call JavaScript from the javascript section into an individual passage - whilst simultaneously using sugarcube/twine macros along with it.

I'm also wondering if this is the best method for this task, but I had no idea how to implement this with the twine/sugarcube macros (besides the random number generation really) so I was a little stuck.

Much obliged chaps :)

Here is the code in question but it might be easier just to avoid this in the first place, again - i'm not particularly sure whether this is covered in the macros or not.
var max = 36;
var r1 = randombetween(1, max-3);
var r2 = randombetween(1, max-2-r1);
var r3 = randombetween(1, max-1-r1-r2);
var r4 = max - r1 - r2 - r3;


function randombetween(min, max) {
  return Math.floor(Math.random()*(max-min+1)+min);
}
function generate(max, thecount) {
  var r = [];
  var currsum = 0;
  for(i=0; i<thecount-1; i++) {
     r[i] = randombetween(1, max-(thecount-i-1)-currsum);
     currsum += r[i];
  }
  r[thecount-1] = max - currsum;
  return r;
}

Much obliged :)

P.S Apologies for the somewhat strenuous link between the title of this question and it's content, I was hoping this would also help in benefitting the community somewhat and hopefully avoid these sort of questions being asked in future x)

Thank you.

Any method for analyzing performance?

$
0
0
I made it: my Twine (Harlowe) has become nearly unplayable due to performance. The fastest passage takes more than 4 seconds to render, it freezes the browser for most of that time, and it will surely get slower as I add more content.

Can you think of any way or tool for analyzing the performance of a game and seeing what's making it slow? One of the problems is that I actually think that the game should be way faster, since I thought that I had streamlined its "engine" from a previous version that, however, is faster than the current. So I don't even know where to look.

Kind of a stupid question, but how do i center the title of my story (SugarCube)

$
0
0
So I've been hunting around for this answer, but i can't seem to find it. So how do i center just the title of my story using the Sugarcube format of twine, because i thought that it just normally went to the left, but i've centered the story caption and story menu stuff, so someone please help me out. Thanks

[sugarcube 2.x] Selector error with if statements...

$
0
0
Ok so I am trying to create a passage that shows different text based on which passage the player came from. I watched a tutorial explaining how to use <span> in conjunction with <<replace>> to replace text and it worked for the one I put on the title page but now that I'm using if statements it is giving me this error:
Error: <<replace>>: no elements matched the selector "#xArea"

I've tried a variety of things but they all seem to give the same error. This is the code as of this moment:
<span id="xArea">Error: invalid passage access. If you are seeing this please report it.
<<if $exArea == 1>>
<<replace "#xArea">>
You stand up from your cubicle and take a look at your surroundings. A busy day in the GETTO offices.
<</replace>>
<<else>>
<<replace "#xArea">>
Error: invalid area number. If you are seeing this please report it.
<</replace>>
<</if>>
</span>

Now I know there is probably a better way to go about this but this was all I could think up to do this atm. If anyone has a better method to achieve this then I'd greatly appreciate it if you'd tell me or at the least point me in the right direction. Also please note that there are no linebreaks in the code if that's even a factor, I just added them here for readability.

Substituting/Setting A Variable's Name Using Another Variable's String (Sugarcube 2)

$
0
0
Can this be done using Twine's script, or am I going to have to use javascript? If javascript is the only way to do it, has anyone already done this, and wouldn't mind sharing?

Discrepancy between the wiki and the actual download

$
0
0
Hello Folks,

I'm posting this here instead of trying to change the wiki, because I'm new to Twine and not sure if I'm seeing something wrong or if the wiki is wrong (that is what I suspect):

The wiki says for Twine 2: "To get started, open index.html inside the folder."

But the download contains no "index.html" file. Instead there is an executable, that runs Twine, when I start it. This seems to be the case for all three operating systems.

So my question is simple (at least it seems so to me):
Is the wiki wrong or do I miss something?

Example Turn-Based RPG (Pre-Alpha v. 0.4)

$
0
0
Greetings!

An example turn-based Twine RPG has been requested a number of times on this forum and back in the old Google Groups. Recently, I threw together a rush job in about four hours for the Twine 23 Challenge. It was horribly unbalanced, but served as a rough, unfinished example with answers to a number of common questions. However, in order to meet the passage requirements of the challenge, I used several loop passages that, for those unfamiliar with them, made the game's code much harder to read than necessary.

I continued to work on it until it grew into a huge monster that far surpassed its original intent. So, I came back to the original version and created another branch. It's still rough and unfinished with unbalanced and monotonous game play, but it should better serve as a basic example of how to create a turn-based RPG in Twine. This is all Twine syntax; no script passages! (Well, the SugarCane version uses a config passage rather than StorySettings.) So, even the most novice Twine user should be able to follow this example or use it as a foundation to create his or her own basic turn-based RPG.

Again, this is not really meant to be a fun, exciting, or interesting game. It's a mapa beginners guide to the very most basic aspects of creating such a game for those in totally unfamiliar territory.

To better understand this game's code, you may wish to fist review one of my tutorials on the use of objects in Twine: Objects are Your Friends: How & Why to Use JavaScript Objects for Total Newbies

I made two editions. The first (TwineRPG-SCE) is made in SugarCube. The second is in Sugarcane, the default header. The only real difference at all is that SugarCube has saves, which are essential for this type of game. Also, the textbox macro at the start of the game uses a different syntax style than Sugarcane's, and the sidebar CSS selector is different (#ui-bar in SugarCube, #sidebar in Sugarcane). Those are really the only differences, but the ability to save from SugarCube is a big deal. The conversion back to Sugarcane was a bit of a rush job, so I hope I didn't miss anything. I noticed some minor whitespace and formatting issues, but I wasn't going to take the time to track them all down.

I doubt I'll continue to develop or release further versions of this example RPG, though I'll probably fix any reported bugs.

The full version of the game is much, much further along. It's massive. It has a lot of commissioned artwork as well as music and sound effects. It also has several features not present in this version. I have no idea when I'll finish it. Probably not this year.

If you have any questions, don't hesitate to ask. That's why I created this version in the first placeto show Twine beginners how to create a basic turn-based RPG.

Thanks for reading, playing, and commenting!



Richard D. Sharpe

[harlowe] How do you click through options?

$
0
0
I'm still not completely familiar with the terms, so I was iffy on how to phrase this question.
Anyway, I played a couple twine-made games to see what the engine could do and a lot of them used this effect where you could click through options on the same line, and when you settled on one thing, you could move on from there.

I looked around the internet for this but I couldn't find anything, or maybe I just didn't understand them.

Has anyone else gone back to Twine 1 after experimenting with Twine2?

$
0
0
Hey folks. Not sure if you guys have had the same experience as me, but after experimenting a bit with Twine 2, I've gone back to mucking about in Twine1. It just doesn't seem like the functionality is there yet to do the things I want to do (i.e. background music is extremely difficult to implement in Harlowe, but SugarCube doesn't seem to support <<timedgoto>>). Am I just a moron who's not able to realize the potential of the new version?

Twine survey: which version of Twine are we using? RESULTS (January 2016)

$
0
0
A while back I posted a survey to find out what versions of Twine everyone was using. Here, for your consideration, are the results. Thanks to everyone who filled it out and suggested updates to the questions!

(Thinking about doing this again in the future. Let me know if you have any suggestions for new questions!)

German Translation of Twine 2 Client

$
0
0
Hi! Guten Tag!
I just created a draft of a german translation for twine 2.
https://bitbucket.org/ztiromoritz/twinejs

First of all, am I the first person who has done sth. like this? There are no attempts so far?

Some open questions and TODOs:
  • Proofread, i just hacked it down once.
  • Rethink some crucial names of the general domain like (Story and Story Format ..., Geschichte und Format der Geschichte??, Absatz, Auszug, Link) . I think it's important to find a fitting and unambiguous solution here for further reuse in documentations and tutorials.
  • "Du" or "Sie", the general tone of twine seems to be "Du".
  • Translate Internal errors. I tend to leave them untranslated, as it is easier to google them and for developers to find and understand them.
Any thoughts on that?
Anybody interested in proofreading it?
I can provide a running testversion, if you like.

Feel free to contact me here or via twitter: @ztiromoritz (in en and de)

Bye bye! Alles Gute!
ztiromoritz

Adding a background image to a passage + making images responsive

$
0
0
Hello,

So this is a two parter for Harlowe:

1. How do I add an image into a passage and have it appear as the background and be responsive to the size of the screen (so it fills the screen no matter how big or small it gets - without distorting the dimensions though.)

2. How do I add a regular image into a passage and make it responsive like the text?

Thanks!

Is there a way to make a button hidden until a user clicks something?

$
0
0
I need to make sure that a user can't progress until they've selected an option from the checkbox
To make my purpose more clear, when the user enters the "Shop", they can select an item to buy using checkboxes that subtract it from their money on hand, and the button takes them to a page that determines if they have enough money to confirm the purchase, and this all works fine

Until they go back to the shop. Once they go back in, if they fail to select an option, and hit the purchase button, the function will try to subtract the price of the item from their money again, and, if they have insufficient funds, the item will be set as false and taken out of their inventory

This is a sample item as it appears in the store
<<if $Knife is "false">>\
<<checkbox "$Knife" "false" "true">> Knife $50
<<else>>\
<<endif>>\

then the confirm purchase passage
<<if $Knife is "true">>\
<<set $playMoney -= 50>>\
<<if $playMoney < 0>>\
You don't have enough for the Knife.
<<set $Knife = "false">>\
<<set $playMoney += 50>>\
<<else>>\
You have purchased the Knife
<<endif>>\
<<endif>>\

Any help would be much appreciated, as i have been pulling my hair out about this.
Thanks

Reviving old macro for Sugarcube?

$
0
0
---Using Twine 2 local/downloaded version, Sugarcube 2.2 (I think), Firefox 45.0.2,---

I am using Twine 2.0, Sugarcube 2.2 (I think), and Firefox 45.0.2

I am trying to use this old Twine 1 screen-shaking macro in Twine 2 with Sugarcube 2.2. I suspect the issue lies in how v2.0 defines things, and thus probably requires far more knowledge of Javascript that I have (next to none) to fix.

What's worse, when I copy/pasted the macro's javascript into the story's javascript section (don't pity me), it actually broke the Sugarcube Cyclinglink package, so that things such as <<timedinsert>> no longer worked until I removed the old code.

I suspect this macro was a little too obscure to get updated for the new versions of twine/sugarcube.

Any help in resuscitating this poor old macro would be much appreciated!

-Liyamu

(Original macro source: https://gist.github.com/dariusk/4651698)

Here's the screenShake Javascript:
function screenShake(time) {
  console.log(document);
  var el = document.getElementsByClassName('content');
  baz = el;
  console.log(baz[0]);
  el[0].className = el[0].className + ' shake';
  if (time > 0) {
    setTimeout(function () {
      el[0].className = 'content';
    }, time);
  }
};

// the screenShake macro. Adapted from Emmanuel Turner's article on creating Twine macros. http://eturnerx.blogspot.com/2012/12/how-to-create-custom-macros-in-twine.html
try {
  version.extensions['screenShakeMacro'] = {
    major: 1,
    minor: 0,
    revision: 0
  };
  macros['screenShake'] = {
    handler: function (place, macroName, params, parser) {
      var time = parseInt(params[0]);
      if (typeof time !== 'number') {
        time = 1000;
      }
      
      // we're overriding the fade function. It behaves as usual except it runs screenShake() if time >= 0.
      fade = function (el, options) {
        var current;
        var proxy = el.cloneNode(true);
        var direction = (options.fade == 'in') ? 1 : -1;

        el.parentNode.replaceChild(proxy, el);

        if (options.fade == 'in') {
          current = 0;
          proxy.style.visibility = 'visible';
        } else current = 1;

        setOpacity(proxy, current);
        var interval = window.setInterval(tick, 25);

        function tick() {
          current += 0.05 * direction;

          setOpacity(proxy, Math.easeInOut(current));

          if (((direction == 1) && (current >= 1)) || ((direction == -1) && (current <= 0))) {
            console.log('swapping fader proxy out');
            el.style.visibility = (options.fade == 'in') ? 'visible' : 'hidden';
            proxy.parentNode.replaceChild(el, proxy);
            delete proxy;
            window.clearInterval(interval);

            if (options.onComplete) options.onComplete();

            if (time >= 0) {
              screenShake(time);
              time = -1;
            }

          }
        };

        function setOpacity(el, opacity) {
          var percent = Math.floor(opacity * 100);

          // IE
          el.style.zoom = 1;
          el.style.filter = 'alpha(opacity=' + percent + ')';

          // CSS 3
          el.style.opacity = opacity;
        };
      };
    },
    init: function () {},
  };
} catch (e) {
  throwError(place, "screenShake Setup Error: " + e.message);
}

And here's the screenShake default CSS:
@keyframes shakeit {
  0% { transform: translate(2px, 1px) rotate(0deg); }
	10% { transform: translate(-1px, -2px) rotate(-1deg); }
	20% { transform: translate(-3px, 0px) rotate(1deg); }
	30% { transform: translate(0px, 2px) rotate(0deg); }
	40% { transform: translate(1px, -1px) rotate(1deg); }
	50% { transform: translate(-1px, 2px) rotate(-1deg); }
	60% { transform: translate(-3px, 1px) rotate(0deg); }
	70% { transform: translate(2px, 1px) rotate(-1deg); }
	80% { transform: translate(-1px, -1px) rotate(1deg); }
	90% { transform: translate(2px, 2px) rotate(0deg); }
	100% { transform: translate(1px, -2px) rotate(-1deg); }
}

@-o-keyframes shakeit {
	0% { -o-transform: translate(2px, 1px) rotate(0deg); }
	10% { -o-transform: translate(-1px, -2px) rotate(-1deg); }
	20% { -o-transform: translate(-3px, 0px) rotate(1deg); }
	30% { -o-transform: translate(0px, 2px) rotate(0deg); }
	40% { -o-transform: translate(1px, -1px) rotate(1deg); }
	50% { -o-transform: translate(-1px, 2px) rotate(-1deg); }
	60% { -o-transform: translate(-3px, 1px) rotate(0deg); }
	70% { -o-transform: translate(2px, 1px) rotate(-1deg); }
	80% { -o-transform: translate(-1px, -1px) rotate(1deg); }
	90% { -o-transform: translate(2px, 2px) rotate(0deg); }
	100% { -o-transform: translate(1px, -2px) rotate(-1deg); }
}

@-webkit-keyframes shakeit {
	0% { -webkit-transform: translate(2px, 1px) rotate(0deg); }
	10% { -webkit-transform: translate(-1px, -2px) rotate(-1deg); }
	20% { -webkit-transform: translate(-3px, 0px) rotate(1deg); }
	30% { -webkit-transform: translate(0px, 2px) rotate(0deg); }
	40% { -webkit-transform: translate(1px, -1px) rotate(1deg); }
	50% { -webkit-transform: translate(-1px, 2px) rotate(-1deg); }
	60% { -webkit-transform: translate(-3px, 1px) rotate(0deg); }
	70% { -webkit-transform: translate(2px, 1px) rotate(-1deg); }
	80% { -webkit-transform: translate(-1px, -1px) rotate(1deg); }
	90% { -webkit-transform: translate(2px, 2px) rotate(0deg); }
	100% { -webkit-transform: translate(1px, -2px) rotate(-1deg); }
}

@-moz-keyframes shakeit {
	0% { -moz-transform: translate(2px, 1px) rotate(0deg); }
	10% { -moz-transform: translate(-1px, -2px) rotate(-1deg); }
	20% { -moz-transform: translate(-3px, 0px) rotate(1deg); }
	30% { -moz-transform: translate(0px, 2px) rotate(0deg); }
	40% { -moz-transform: translate(1px, -1px) rotate(1deg); }
	50% { -moz-transform: translate(-1px, 2px) rotate(-1deg); }
	60% { -moz-transform: translate(-3px, 1px) rotate(0deg); }
	70% { -moz-transform: translate(2px, 1px) rotate(-1deg); }
	80% { -moz-transform: translate(-1px, -1px) rotate(1deg); }
	90% { -moz-transform: translate(2px, 2px) rotate(0deg); }
	100% { -moz-transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
	-webkit-animation-name: shakeit;
	-webkit-animation-duration: 0.8s;
	-webkit-transform-origin:50% 50%;
	-webkit-animation-iteration-count: infinite;
	-webkit-animation-timing-function: linear;
  -moz-animation-name: shakeit;
	-moz-animation-duration: 0.8s;
	-moz-transform-origin:50% 50%;
	-moz-animation-iteration-count: infinite;
	-moz-animation-timing-function: linear;
  -o-animation-name: shakeit;
	-o-animation-duration: 0.8s;
	-o-transform-origin:50% 50%;
	-o-animation-iteration-count: infinite;
	-o-animation-timing-function: linear;
  animation-name: shakeit;
	animation-duration: 0.8s;
	transform-origin:50% 50%;
	animation-iteration-count: infinite;
	animation-timing-function: linear;
}
.shake{
	display:inline-block
}
Viewing all 3830 articles
Browse latest View live