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

Help with if and updating variables.

$
0
0
So I have a problem I can't solve and reading the documentation when I'm not sure what I'm looking after have been ineffective. I have a room(guild hall) the player enters with two variables set $Introduction is 1 and $StarterGear is 0. This is a room the player is going to be entering multiple times, but the first time the player is collecting some gear.

So what I want is for the player to enter get some text have a click/button for picking up the gear and giving them some new text. Then after that they are allowed to leave through the [[head west]] passage.

Now the code below shows the "you need to pick up your gear" part and clicking on that does nothing. There was more to the code, but after fumbling around with <<replace>> and <<display>> and some <span> it wasn't working out and I decided to rebuild. 2:am is probably not the best time to learn new things :P

<<if $Introduction eq 1>>

<<if $StarterGear eq 0>>

<<click "You need to pick up your gear">><<set $StarterGear = 1>>
<</click>>


<</if>>

<<if $StarterGear eq 1>>

[[Head West]]
<</if>>
<</if>>

How to offer choices to the player (variable name)

$
0
0
Hello
I'm struggling because in my story I'd like to offer choices to the player.
I want the player to choose the name of his/her friend, but instead of asking the player "what's your friend name?"
I want to make proposal such as
"Your friend is :
John
Alex
Mark"

If anyone can help me I can't find the solution anywhere....


Thank you so much!!

Changing image size/resolution in Harlowe

$
0
0
Hi!

So nearly done on a big project I've been working on. The story itself is finished, now I'm trying to make it look pretty. I've worked out how to make a youtube dukebox so I can have music, and I know how to insert images into passages, as well as use the stylescript to change the background image of passages using tags. I just need help changing the image size.

So my css code looks like this;
html.tree {
	background-image: url("https://openclipart.org/image/2400px/svg_to_png/194965/Circle-Forset-Day-bw.png&quot;);
}

Which is working perfectly. I know there are other ways to do images, such as save images to the same file, but I'm using http://www.philome.la/ as my host, and they don't have a system for uploading other files. So I just want to use links.

The problem I have is that when the image comes up in-game, it's way too big to see the whole picture. Can I change the resolution without having to download the image and change the file, or do something similar to
(css: "font-size: 200%")[]
?

Thank you!

How I can make to integrate a random event into a history ?

$
0
0
Hello everybody! I would like to add a random event to my story but all the formulae which I found do not work. Then I question you: how can it be done?
My event includes 2 possibility : if you are lucky, you go to the good way
if you aren't lucky, you fall and die
Please, help me :/

PS : I'm french and my english is sad. I'm sorry if you see a lots of fault :/ but you can ask me :)

How do I centre a single line of text in a passage?

$
0
0
Completely bamboozled by the Harlowe documentation on this, and I can't find much on the forum either.

I want to centre single lines of text in a number of passages and I cannot for the life of me work it out.

Let's say the line of text is: Put me in the middle of this line

I am confused about whether I need to add some css to the story style sheet (which I've used to change the font and size) or if I'm just supposed to use special characters in the actual body copy (which I've used to bold and italicise).

My knowledge of CSS is absolutely zero so please bare in mind you're explaining something to someone with the understanding of a stone.

I need to centre a number of lines of text that are also bolded and italicised, if that makes any difference.

Thanks in advance.

Implementing and editing a complex object (Sugarcube)

$
0
0
Alright, so let me begin with an "I'm fairly new to Twine and most of my shenanigans so far have been tinkering. This is no exception."

So, let's say I have an object $car. A car is not made up of just one object, but of many.
So a $car would have four $wheels, one $engine, one $trunk and maybe five $seats, among other things.
Each of those $wheels, $seats, etc, would be its own object.
So we'd have something like
<<set $wheel to {
tyre : "michelin",
tyreDurability : 10
}>>
<<set $engine to {
brand : "mitsubishi",
speed : 10
}>>
/%Rest of fluff here%/
<<set $car to {
wheels : [$wheel, $wheel, $wheel, $wheel],
engine : $engine,
trunk : $trunk,
seats : [$seat, $seat, $seat, $seat, $seat]
}>>

So, my first question is: Is this the best way to implement a complex object in Twine? Is there a better way, and if so, what is that way?

Secondly, what would be the most efficient way to change parts of the car? Using
[[Accept the mechanic's offer|nextPassage][$car.engine.brand to "honda", $car.wheels[0].tyre to "square", ..., $car.wheels[3].tyre to "square"]]
takes up a huge amount of space in the passage and is very difficult to keep track of. It's easy to forget, say, a $car.wheels[2].tyreDurability to 17 when typing out about twenty other things. Additionally, if I wanted to have a cascading change, it's impossible to do that without typing it all out myself. For example, if I changed the car's overall brand from a Ford F-150 to a Reliant Robin, then in that very same section, I would have to change the engine, the wheels, etc. A better result would be that when I want to change the car's overall brand, I call a function that reads a global variable somewhere and changes anything that needs changing. Want to change the car's electronics? Function changes the GPS, Radio and heating system. Stuff like that.
I know what needs to be done, but I'm not sure how to best approach the code. Perhaps this is a result of my object being flawed in the first place, and I'm just too dumb to see it, haha.

If anyone has any ideas or any obvious stupidity on my part, it'd be great if you could help out.

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.

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!

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

[Sugarcube] Transferring Stylesheet from version 1 to Sugarcube 2.0

$
0
0
Hello all!

So this has been a problem that's been in my crosshairs for a while, but seeing as how (for me at least) it's not been a gnawing, pressing or detrimental problem I've been putting it off to rectify other issues.

I believe that now is a good time to address this however.

I am not entirely sure of the benefits of using Sugarcube 2.1.2 (my current version) over 1.0.26, but as of now I am having a modicum of trouble with my current version, as the format of the stylesheet seems to be somewhat different for both (the colours remain but everything else is different).

I really like the look of the sidebar and the general UI in Sugarcube 2.1.2 so if I can use it as a UI bar, it may be prudent for me to do so in Sugarcube 2.1.2.

Is there a difference in how Sugarcube 2.1.2 handles stylesheets or is it just a problem with mine? I can include my style sheet if necessary. Thank you :)

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

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?

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?

[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.

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

"like" or "thumbs up" passages - voting system

$
0
0
Hello everybody!

I am currently using twine in a language class, with the entire class colaborating on the same story. I have my students read the passages of the other students and continue their plots, so that ideally everybody contributes to all of the plots.

This system causes quite a bit of fragmentation, as students come up with more and more plots. In order to narrow down the amount of plots, the other day I printed the entire story on paper and represented the twine structure using lines. Afterwards, I had my students vote for the plots they liked best (each of them could spend three points in total).

This was a rather tedious process, so I thought it could be done much easier online. What I have in mind is a kind of counter which enables the reader to "like" or "heart" or whatever passages he likes. The counter should be visible to everybody. Users should have a limited amount of points they can spend. Not all the passages should be allowed to vote on, maybe a designated tag could trigger the counter.

I understand this cannot be done with javascript, my guess is php and a text file where the counts are stored should do the job. I'd be very grateful for any hint in the right direction. If somebody comes up with an idea, I can provide webspace for testing.

Cheers,

richVIE


Viewing all 1844 articles
Browse latest View live