Code for Twine
2 posters
Page 1 of 1
Code for Twine
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"
---------------------------------------------------------------------------------------------------
<<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"
Re: Code for Twine
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.
- 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.
Re: Code for Twine
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- Admin
- Posts : 1671
Join date : 2015-03-31
Age : 49
Re: Code for Twine
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.
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- Admin
- Posts : 1671
Join date : 2015-03-31
Age : 49
Re: Code for Twine
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.
I have been experimenting with some $wind variables and have a basic system set up using the Beaufort scale.
Re: Code for Twine
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]
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- Admin
- Posts : 1671
Join date : 2015-03-31
Age : 49
Re: Code for Twine
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?
Did you have any luck looking at the code from the file I sent you?
Re: Code for Twine
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- Admin
- Posts : 1671
Join date : 2015-03-31
Age : 49
Re: Code for Twine
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.
Re: Code for Twine
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.
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- Admin
- Posts : 1671
Join date : 2015-03-31
Age : 49
Re: Code for Twine
I read through that discussion and I'm still not sure what $arg is and how it works?
Re: Code for Twine
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.
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- Admin
- Posts : 1671
Join date : 2015-03-31
Age : 49
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum