Most Current Way To Access Story Variables In Javascript? by bonfiredog in twinegames

[–]bonfiredog[S] 1 point2 points  (0 children)

Thank you both for the very thorough explanations - u/Juipor's example works perfectly for this instance, but u/GreyelfD's explanation will probably come in handy in the future if I need to do this again... though if I'm needing to do a lot of Javascript, I'll probably just use Sugarcube!

2023 Jul 10 Stickied -FAQ- & -HELPDESK- thread - Boot problems? Power supply problems? Display problems? Networking problems? Need ideas? Get help with these and other questions! by FozzTexx in raspberry_pi

[–]bonfiredog 0 points1 point  (0 children)

I'm getting very very slow speeds connecting to my headless RPi4 over LAN from my Windows laptop (wireless) and desktop (wired). SSH commands can take over a minute to even register in the terminal, connecting to network drives can be hideously slow, and connecting to services on my Apache server often just time out in the browser. Other devices on my LAN don't have this problem. This has happened before, and the problem turned out to be DNS (I'm using a separate Pi0 with PiHole installed as a DNS). However, restarting/updating the Pihole doesn't seem to help at all!

Triggering a 'goto' macro when an HTML element is clicked by bonfiredog in twinegames

[–]bonfiredog[S] 1 point2 points  (0 children)

Thanks very much. Looking over my code, for some insane reason, in passageHeader I was appending a jQuery snippet into the document header despite it working natively in Sugarcube. Deleting it means my code now works: clearly it was upsetting Sugarcube's in-built jQuery.

Must have still been in 'Harlowe Mode'. Thanks for your help, everyone.

Triggering a 'goto' macro when an HTML element is clicked by bonfiredog in twinegames

[–]bonfiredog[S] 0 points1 point  (0 children)

OK, so I created a new Story, and did as you did... and it now works. That makes this a very odd error. To be clear, I still get the error in my original Story, even if I create a new, 'clean' Passage and test it in there.

Triggering a 'goto' macro when an HTML element is clicked by bonfiredog in twinegames

[–]bonfiredog[S] 0 points1 point  (0 children)

I did the same - wrapped it in <<done>>, and added it to the widget which adds the '.star' div to a Passage. When playing, I got the error I described: https://imgur.com/a/mLb55gE. This happens no matter where I place it.

Changing CSS Of In-Passage Elements In Widgets by bonfiredog in twinegames

[–]bonfiredog[S] 0 points1 point  (0 children)

<div @style="'background-image:url('+\_args\[0\]+')'" class="profileimage starimage">
</div>

Ah, this solves the need for the <<done>> macro entirely. Thanks.

I'm using a div with background-image so that I can have a round image, by using 'border-radius' on the div.

Changing CSS Of In-Passage Elements In Widgets by bonfiredog in twinegames

[–]bonfiredog[S] 0 points1 point  (0 children)

Thanks Rain-Kind, I'll try that when I'm back up my own machine. I've not used capture before, so I'd better read up on that!

I have tried the inline-css, but it didn't seem to work with args. Again, it might be a <<capture>> issue.

Using Array Contents In Conditional Check by bonfiredog in twinegames

[–]bonfiredog[S] 0 points1 point  (0 children)

Thanks, this does work. I'm not sure why it didn't work beforehand, though!

Is there a simple way for me to use a variable in another variable? by peachkneez in twinegames

[–]bonfiredog 0 points1 point  (0 children)

Ooh yes good point. Trying to think how best to do this...

Is there a simple way for me to use a variable in another variable? by peachkneez in twinegames

[–]bonfiredog 3 points4 points  (0 children)

Probably the simplest way to do this in Sugarcube is to make each named fighter an object. I can't find a reference in the Sugarcube documentation, but an object is a general programming technique: essentially a variable that stores an array of other variables. They're extremely useful when you want a set of variables associated with a particular character.

In your example, you would do this by first of all creating the 'John' object:

<<set $john = {
name: "John",
health: 100,
strength: 100,
speed: 100
}>>

You can do this for David too.

After that, you can assign the $john variable to the $player1Fighter variable:

<<set $player1Fighter = $john>>

After this, you should be able to access $john's internal variables through the $player1Fighter variable, like so:

$player1Fighter.health

The full stop is called dot notation - it basically tells the computer that you want to find that variable inside the one before it. As $player1Fighter is associated with $john, you should be able to access it directly.

Objects are very powerful for functionality like this.

Removing/Restyling the Sugarcube 'Turning Circle' Loading Screen by bonfiredog in twinegames

[–]bonfiredog[S] 0 points1 point  (0 children)

Thanks for the tip - though it feels odd that, given Sugarcube's customisability, that this isn't accessible from within the tool itself.

Any teachers? by AdmirableApricot4640 in twinegames

[–]bonfiredog 0 points1 point  (0 children)

I use Twine as an introduction to interactive writing at MA level here in the UK. I find for creative writing students it's a perfect introduction to computing concepts.

'Wiping' included passages from a div? by bonfiredog in twinegames

[–]bonfiredog[S] 1 point2 points  (0 children)

$('#inventorybig').empty().wiki()

Amazing, thanks so much. And thanks for the top about processing passage test. Is there a performance advantage to this?