Twine Version: 2.9.0
Sugarcube 2.36.1
Hi, I’m very new to programming, I read motoslave sugarcube documentation, and twinery cookbook , when I read most of the documentation, I don’t understand at all. I decided to ask here, and ask about the introduction. If there is a resource or tutorial that is beginner friendly please share me the link.
It is said that
Type:
Property access,
dot notationSyntax:
$variable.propertyExample:
$thing.name
I understand $variable and how to use it, but what is $variable.property?
I tried to tinker around, and I keep getting error…
It seems I misunderstood what it does…
How and when to use it in real case?
I see people using $variable.(insert text here).(insert text 2)
I don’t have a clue what they are setting for…
Second question,
Type:
Index/property access,
square bracket notationSyntax:
$variable[numericIndex]
$variable[“property”]
$variable[$indexOrPropertyVariable]Example:
$thing[0]
$thing[“name”]
$thing[‘name’]
$thing[$member]
What is $variable[“property”] ?
How and when to use it?
I remember about indexing and array [0] means first item of the list, so I think $thing[0] is like this?
<<set $thing either to (“gloves”,“hat”))>>
so if I write
“I forgot to bring my $thing[0]” become “I forgot to bring my gloves”
Is this correct?
Third question is about either.
I know how to use either, the logic.
<<set _fruit to either("apple", "cherry", "banana")>>
What fruit we will have today?
<<if _fruit is "apple">>
today we will have _fruit
<</if>>
This means, the fruit will be randomized (apple,cherry, banana), and if apple was picked, the text will be
What fruit we will have today?
today we will have apple
I don’t understand the example from the site…
Using arrays; given: $pies = [“Blueberry”, “Cherry”, “Pecan”]
either($pies) → Returns a random pie from the whole array
I copy pasted this into twinnery (web), it doesn’t yield anything… how to use this?
Is it <<set $pied= ["Blueberry", "Cherry", "Pecan"]>>
Today I will have <<print either($pies)>>
But I don’t think this code will run… it will create error.
Note: I know how to use set, if, elseif , and else, and set. (not expertly, but I have a clue what it does).
I know what this mean <<set $lampswitch to false>> → it means set lamp switch to turned off
Explaination in layman’s terms with example usage is greatly appreciated!
Thanks in advance.