R2N
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Code for Twine

2 posters

Go down

Code for Twine Empty Code for Twine

Post by Reb Thu 2 Jun 2016 - 20:15

Here is a sample code I was working on. There is some interesting potential even with a few simple commands. The "-----" is just a separator to indicate a new passage box.
---------------------------------------------------------------------------------------------------
<<set $good to either("cod", "lobster", "seal skins")>>
<<set $traffic to either("busy", "quiet")>>
<<set $weather to either("rainy", "foggy", "sunny", "overcast")>>
<<set $wind to either("calm", "breezy", "gale force")>>

St. John's harbour is <<print $traffic>> today. It is <<print $weather>> with <<print $wind>> winds.

<<if $good is "cod">>There is the smell of fish in the air<<endif>>

A fresh load of <<print $good>> sits on a dock. A man is standing beside it.


[[Talk to man]]


---------------------------------------------------------------------------------------------------

<<if $weather is "foggy">>"She's some foggy today b'y!"<<endif>>
<<if $weather is "sunny">>"Finally getting some sun eh b'y!"<<endif>>

<<if $wind is "gale force">>"This wind is some rough"<<endif>>

"can I interest you in some <<print $good>> today?"

<<choice [[Yes I do]]>>

------------------------------------------------------------------------------------------------------

"The $good is extremely fresh. It will cost <<print random(10+5) >> dollars"

Reb
Reb
Admin

Posts : 604
Join date : 2015-03-30

https://roadtonowhere.forumotion.org

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Reb Sat 4 Jun 2016 - 5:29

Ok I have changed a lot of code. I think I may have a very early working prototype for:
- ship movement
- a weather system
- a steam engine needed for movement
- sonar
- radio
- images

I have emailed you the prototype. It won't have the images included so an "x" will appear where I put them. I will explain how it works when I talk to you.
Reb
Reb
Admin

Posts : 604
Join date : 2015-03-30

https://roadtonowhere.forumotion.org

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Hobb Sat 4 Jun 2016 - 16:57

If you can randomly <set> $variables and then <if> check those $variables that's pretty good. For the <if> check does it just keep checking them until one fits? Will discuss.
Hobb
Hobb
Admin

Posts : 1671
Join date : 2015-03-31
Age : 49

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Hobb Tue 7 Jun 2016 - 22:09

A note of caution: Setter-links (i.e links that also change variables) do not seem to work in Twine2.

http://twinery.org/forum/discussion/4648/is-there-a-way-to-properly-use-twine-2-i-can-t-alter-var-when-player-clicks-on-links-to-passage

https://twinery.org/forum/discussion/2103/setter-links-in-twine-2

I thought I was going crazy in not being able to get this simple code to work - but now I'm just working around it.
Hobb
Hobb
Admin

Posts : 1671
Join date : 2015-03-31
Age : 49

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Reb Tue 7 Jun 2016 - 23:40

I had been looking into this as well. Have you have any luck with a work around?

I have been experimenting with some $wind variables and have a basic system set up using the Beaufort scale.
Reb
Reb
Admin

Posts : 604
Join date : 2015-03-30

https://roadtonowhere.forumotion.org

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Hobb Wed 8 Jun 2016 - 17:22

I've been trying to use the <<click>> marco but without much luck.
http://www.motoslave.net/sugarcube/2/docs/macros.html#macros-click

The special rooms 'PassageReady' & 'PassageDone' might also be a work-around as any code in them is run before/after any time you move passages.
http://www.motoslave.net/sugarcube/2/docs/special-names.html

It depends on what you want out of it. Let me know the specific puzzle.


Here are my basic documents:

TWINE2
http://twinery.org/wiki/twine2:guide

Sugarcube2
Basic- http://www.motoslave.net/sugarcube/2/
Marco - http://www.motoslave.net/sugarcube/2/docs/macros.html

Today I was focusing on appearance and playing with the CSS style sheet page and it pretty cool. The simplicity of having two places just to insert CSS or javascript is seductively easy. Here is a great site for cut'n'paste CSS: https://www.glorioustrainwrecks.com/node/5163 [check out the 'porthole' format]

Hobb
Hobb
Admin

Posts : 1671
Join date : 2015-03-31
Age : 49

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Reb Wed 8 Jun 2016 - 17:33

Right now all I wanted to do is when you move passages to have movement points reduce. In the prototype I sent you I had engine psi as a movement point allowance. Once I can get numbers to reduce or increase when moving passages it would open up a lot more freedom.

Did you have any luck looking at the code from the file I sent you?
Reb
Reb
Admin

Posts : 604
Join date : 2015-03-30

https://roadtonowhere.forumotion.org

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Hobb Wed 8 Jun 2016 - 18:06

The pages you sent were HTML so it was hard to extract the code - could you post the movement code to the forum? Unless I missed something.
Hobb
Hobb
Admin

Posts : 1671
Join date : 2015-03-31
Age : 49

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Reb Wed 8 Jun 2016 - 19:17

I'm trying to post something that makes sense, but when I post the "proofing" code it puts things in an odd order and it is really hard to follow. I will keep trying to find a way to post it.
Reb
Reb
Admin

Posts : 604
Join date : 2015-03-30

https://roadtonowhere.forumotion.org

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Hobb Mon 13 Jun 2016 - 20:34

I have tried using the different 'Special Passage' names (PassageDone/PassageFooter/PassageReady/PassageHeader) with some success - but I beginning to suspect making certain parts of the rules into 'widgets' might be easier.

You have to create a separate passage for widgets and TAG it as "widget" - then you can code in some Sugarcube <<widget>> macro on that page and the widgets are available to any page.

this give an example that I have tried and found it works:

https://twinery.org/forum/discussion/2643/sugarcube-is-there-an-easier-simpler-way-to-dol-this-randomized-risk-reward

This also allowed me to understand what the mysterious "$arg" values mean.



Hobb
Hobb
Admin

Posts : 1671
Join date : 2015-03-31
Age : 49

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Reb Mon 13 Jun 2016 - 23:18

I read through that discussion and I'm still not sure what $arg is and how it works?
Reb
Reb
Admin

Posts : 604
Join date : 2015-03-30

https://roadtonowhere.forumotion.org

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Hobb Tue 14 Jun 2016 - 17:45

In the example, the 'ore widget' is coded to use $arg0, $arg1, $arg2 but never defines them, so it seems mysterious. But when you call up that widget in a passage (type in <<ore>>) than any numbers included beside "ore" are automatically assumed to be $arg0, $arg1, $arg2, ect.... So if you put in <<ore 20 40 60>> than the code takes that as $arg0 = 20 $arg1 = 40 $arg2 = 60.

So $arg values seem like 'automatic variables' that can be read after any input without explicit definition. The first one being $arg0 and than increasing by 1.

So we could create a Wind widget where arg0 = speed category and arg1 = direction category. Then coding <<wind 3 north>> into a passage would bring up a category 3 speed from some northerly direction.

These values could be modified by a larger variable called $season that reflected the overall severity of that season, that variable world be kept in its' own passage and rarely modified.
Hobb
Hobb
Admin

Posts : 1671
Join date : 2015-03-31
Age : 49

Back to top Go down

Code for Twine Empty Re: Code for Twine

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum