I'm back :) For me it's the day after the last post - for you it's the week of waiting. Before I get to my 'discoveries' let me stop and talk about this series for a second.
Why am I doing this? Well, I love role-playing games, love the Lone Wolf books, like to learn new programs and ways to make games, have no friends so I need solo games I can play, and I've got waaayyy too much free time.
So this is not a professional tutorial.
I also want to remember what I've gone through. All the code and ideas start to blur after a while, so I like the idea of having a history of how this project develops. Going down the wrong path sucks, but it also teaches, and I don't want to forget any of the lessons.
So I'm going to show you something I did wrong. Well, in a way. And how I kind of fixed it (actually, re-did it).
Even though these next steps are going to be a mistake, I'm going to keep presenting all the code and screenshots - it's something of a before and after to compare. If, by some chance you have been copying and playing with my code yourself just be mindful that these aren't quite going to work right (at least they didn't for me).
Now, yesterday as I started looking into 'boxes of all types, I had a thought: what if I kept the same text list I had just worked on and simply added a counter for each discipline chosen - couldn't I keep the user from going crazy and just re-use what I had? Might be a bit simpler than adding a new kind of user input. Also, again, the documentation and tutorials online are not always the easiest for me to understand - which made the idea of using what I had more attractive. It did go a bit wonky though.
I had this list that the player could click on...
The clicks were built on this code...
<span id="ak_choose">
<<click "Learn Animal Kinship.">>
<<set $Disciplines to {"Animal Kinship": true}>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<</click>>
</span>
<<click "Learn Animal Kinship.">>
<<set $Disciplines to {"Animal Kinship": true}>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<</click>>
</span>
Easy, click on the text, set the variable, text goes to plain (non-click). What, I thought, if I added a variable tracking how many disciplines the player had clicked on, and then check that number before setting the variable. Also, I could put a message if the player went over their allotted 5 disciplines...
<<set _chosen to 0>>
You may now choose the 5 disciplines that you have learned during your training...
<span id="choose_warn"></span>
<span id="ak_choose">
<<click "Learn Animal Kinship.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"AnimalKinship": true}>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>>
<</click>>
</span>
You may now choose the 5 disciplines that you have learned during your training...
<span id="choose_warn"></span>
<span id="ak_choose">
<<click "Learn Animal Kinship.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"AnimalKinship": true}>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>>
<</click>>
</span>
Okay, so I set a variable for the number of choices made, check that it is less than 5, set the discipline and increment (add to) the count by 1 if it is - or print a warning if it isn't (without setting the choice).
Which works, and pretty well. You can't click on more than 5 disciplines, which fixes that problem, and it uses the nice, simple code I already had instead of me having to learn how to do something new (which I should, but I was feeling lazy).
Here's the final code for that page.
<<nobr>><<set $Disciplines to {"Camouflage": false, "Hunting": false,
"SixthSense": false, "Tracking": false,
"Healing": false, "Weaponskill-Dagger": false,
"Weaponskill-Spear": false, "Weaponskill-Mace": false,
"Weaponskill-ShortSword": false, "Weaponskill-Warhammer": false,
"Weaponskill-Sword": false, "Weaponskill-Axe": false,
"Weaponskill-Quarterstaff": false, "Weaponskill-Broadsword": false,
"Mindshield": false, "Mindblast": false,
"AnimalKinship": false, "MindOverMatter": false}>>
<<set _i to random (1, 9)>>
<<set _chosen to 0>>
<</nobr>>You may now choose the 5 disciplines that you have learned during your training...
<span id="choose_warn"></span>
<span id="ak_choose"><<click "Learn Animal Kinship.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"AnimalKinship": true}>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="c_choose"><<click "Learn Camouflage.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Camouflage": true}>>
<<replace #c_choose>>You know the Camouflage discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="h_choose"><<click "Learn Healing.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Healing": true}>>
<<replace #h_choose>>You know the Healing discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="hn_choose"><<click "Learn Hunting.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Hunting": true}>>
<<replace #hn_choose>>You know the Hunting discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mb_choose"><<click "Learn Mindblast.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Mindblast": true}>>
<<replace #mb_choose>>You know the Mindblast discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ms_choose"><<click "Learn Mindshield.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Mindshield": true}>>
<<replace #ms_choose>>You know the Mindshield discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mom_choose"><<click "Learn Mind Over Matter.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"MindOverMatter": true}>>
<<replace #mom_choose>>You know the Mind Over Matter discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ss_choose"><<click "Learn Sixth Sense.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"SixthSense": true}>>
<<replace #ss_choose>>You know the Sixth Sense discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="t_choose"><<click "Learn Tracking.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Tracking": true}>>
<<replace #t_choose>>You know the Tracking discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
Choose the <span id="wpn_choose"><<click "Weaponskill discipline.">>
<<if _chosen lt 5>>
<<replace #wpn_choose>>Weaponskill discipline.<</replace>>
<<if _i == 1>>
<<set $Disciplines to {"Weaponskill-Dagger": true}>>
<<replace #wpn_prof>> You are proficient with the Dagger<</replace>>
<<elseif _i == 2>>
<<set $Disciplines to {"Weaponskill-Spear": true}>>
<<replace #wpn_prof>> You are proficient with the Spear<</replace>>
<<elseif _i == 3>>
<<set $Disciplines to {"Weaponskill-Mace": true}>>
<<replace #wpn_prof>> You are proficient with the Mace<</replace>>
<<elseif _i == 4>>
<<set $Disciplines to {"Weaponskill-ShortSword": true}>>
<<replace #wpn_prof>> You are proficient with the Short Sword<</replace>>
<<elseif _i == 5>>
<<set $Disciplines to {"Weaponskill-Warhammer": true}>>
<<replace #wpn_prof>> You are proficient with the Warhammer<</replace>>
<<elseif _i == 6>>
<<set $Disciplines to {"Weaponskill-Sword": true}>>
<<replace #wpn_prof>> You are proficient with the Sword<</replace>>
<<elseif _i == 7>>
<<set $Disciplines to {"Weaponskill-Axe": true}>>
<<replace #wpn_prof>> You are proficient with the Axe<</replace>>
<<elseif _i == 8>>
<<set $Disciplines to {"Weaponskill-Quarterstaff": true}>>
<<replace #wpn_prof>> You are proficient with the Quarterstaff<</replace>>
<<elseif _i == 9>>
<<set $Disciplines to {"Weaponskill-Broadsword": true}>>
<<replace #wpn_prof>> You are proficient with the Broadsword<</replace>>
<</if>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span><span id="wpn_prof"></span>
[[Review and Continue->discipline verify]]
"SixthSense": false, "Tracking": false,
"Healing": false, "Weaponskill-Dagger": false,
"Weaponskill-Spear": false, "Weaponskill-Mace": false,
"Weaponskill-ShortSword": false, "Weaponskill-Warhammer": false,
"Weaponskill-Sword": false, "Weaponskill-Axe": false,
"Weaponskill-Quarterstaff": false, "Weaponskill-Broadsword": false,
"Mindshield": false, "Mindblast": false,
"AnimalKinship": false, "MindOverMatter": false}>>
<<set _i to random (1, 9)>>
<<set _chosen to 0>>
<</nobr>>You may now choose the 5 disciplines that you have learned during your training...
<span id="choose_warn"></span>
<span id="ak_choose"><<click "Learn Animal Kinship.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"AnimalKinship": true}>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="c_choose"><<click "Learn Camouflage.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Camouflage": true}>>
<<replace #c_choose>>You know the Camouflage discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="h_choose"><<click "Learn Healing.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Healing": true}>>
<<replace #h_choose>>You know the Healing discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="hn_choose"><<click "Learn Hunting.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Hunting": true}>>
<<replace #hn_choose>>You know the Hunting discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mb_choose"><<click "Learn Mindblast.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Mindblast": true}>>
<<replace #mb_choose>>You know the Mindblast discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ms_choose"><<click "Learn Mindshield.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Mindshield": true}>>
<<replace #ms_choose>>You know the Mindshield discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mom_choose"><<click "Learn Mind Over Matter.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"MindOverMatter": true}>>
<<replace #mom_choose>>You know the Mind Over Matter discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ss_choose"><<click "Learn Sixth Sense.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"SixthSense": true}>>
<<replace #ss_choose>>You know the Sixth Sense discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="t_choose"><<click "Learn Tracking.">>
<<if _chosen lt 5>>
<<set $Disciplines to {"Tracking": true}>>
<<replace #t_choose>>You know the Tracking discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
Choose the <span id="wpn_choose"><<click "Weaponskill discipline.">>
<<if _chosen lt 5>>
<<replace #wpn_choose>>Weaponskill discipline.<</replace>>
<<if _i == 1>>
<<set $Disciplines to {"Weaponskill-Dagger": true}>>
<<replace #wpn_prof>> You are proficient with the Dagger<</replace>>
<<elseif _i == 2>>
<<set $Disciplines to {"Weaponskill-Spear": true}>>
<<replace #wpn_prof>> You are proficient with the Spear<</replace>>
<<elseif _i == 3>>
<<set $Disciplines to {"Weaponskill-Mace": true}>>
<<replace #wpn_prof>> You are proficient with the Mace<</replace>>
<<elseif _i == 4>>
<<set $Disciplines to {"Weaponskill-ShortSword": true}>>
<<replace #wpn_prof>> You are proficient with the Short Sword<</replace>>
<<elseif _i == 5>>
<<set $Disciplines to {"Weaponskill-Warhammer": true}>>
<<replace #wpn_prof>> You are proficient with the Warhammer<</replace>>
<<elseif _i == 6>>
<<set $Disciplines to {"Weaponskill-Sword": true}>>
<<replace #wpn_prof>> You are proficient with the Sword<</replace>>
<<elseif _i == 7>>
<<set $Disciplines to {"Weaponskill-Axe": true}>>
<<replace #wpn_prof>> You are proficient with the Axe<</replace>>
<<elseif _i == 8>>
<<set $Disciplines to {"Weaponskill-Quarterstaff": true}>>
<<replace #wpn_prof>> You are proficient with the Quarterstaff<</replace>>
<<elseif _i == 9>>
<<set $Disciplines to {"Weaponskill-Broadsword": true}>>
<<replace #wpn_prof>> You are proficient with the Broadsword<</replace>>
<</if>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span><span id="wpn_prof"></span>
[[Review and Continue->discipline verify]]
The next thing I wanted was to have a page where you could kind of review your choices and make sure you were happy with them. Why? Well, for the heck of it really. You can see the choices already on this Passage, so I could have just added a ‘Reset’ button or the like. I don't know, it sounded like a good idea at the time.
So on the next Passage I wanted to go through the list of all the disciplines and check each one with an <<if>> to print the ones you knew - then have a way to reset all the variables if you wanted to go back and choose something different (huh, maybe I was channeling the old days of rolling D&D scores set after set trying to get a good combination). The check seemed like a really simple <<if>>, the same one I used in the Passage before to check for the “Sixth Sense.”
Here are the disciplines that you are proficient with...
<<if $Disciplines["AnimalKinship"]>><br>You know the Animal Kinship discipline<</if>>
<<if $Disciplines["Camouflage"]>><br>You know the Camouflage discipline<</if>>
<<if $Disciplines["Healing"]>><br>You know the Healing
...
<<if $Disciplines["AnimalKinship"]>><br>You know the Animal Kinship discipline<</if>>
<<if $Disciplines["Camouflage"]>><br>You know the Camouflage discipline<</if>>
<<if $Disciplines["Healing"]>><br>You know the Healing
...
Simple, so you click 5 disciplines on the first passage...
And then you see them listed on the next Passage...
Ummm.... what? I did click on 5 right, why am I only seeing 1 listed on the next Passage?
So here's where I started looking over my code, playing with it, wondering where I was going wrong and not seeing it. I added all the variable definitions to the second Passage that's supposed to print them out - and it worked perfect; as soon as I moved the variables back to the first Passage the print was down to only 1 again. Saved it to a file and it did the same thing (in case it was from me being in ‘writing mode’ and not ‘playing mode’ so to speak). No idea what was wrong (still don't know). If you're curious, here's the full code for the second Passage...
Here are the disciplines that you are proficient with...
<<nobr>><<if $Disciplines["AnimalKinship"]>><br>You know the Animal Kinship discipline<</if>>
<<if $Disciplines["Camouflage"]>><br>You know the Camouflage discipline<</if>>
<<if $Disciplines["Healing"]>><br>You know the Healing discipline<</if>>
<<if $Disciplines["Hunting"]>><br>You know the Hunting discipline<</if>>
<<if $Disciplines["Mindblast"]>><br>You know the Mindblast discipline<</if>>
<<if $Disciplines["Mindshield"]>><br>You know the Mindshield discipline<</if>>
<<if $Disciplines["MindOverMatter"]>><br>You know the Mind Over Matter discipline<</if>>
<<if $Disciplines["SixthSense"]>><br>You know the Sixth Sense discipline<</if>>
<<if $Disciplines["Tracking"]>><br>You know the Tracking discipline<</if>>
<<if $Disciplines["Weaponskill-Dagger"]>><br>You are proficient with the Dagger<</if>>
<<if $Disciplines["Weaponskill-Spear"]>><br>You are proficient with the Spear<</if>>
<<if $Disciplines["Weaponskill-Mace"]>><br>You are proficient with the Mace<</if>>
<<if $Disciplines["Weaponskill-ShortSword"]>><br>You are proficient with the Short Sword<</if>>
<<if $Disciplines["Weaponskill-Warhammer"]>><br>You are proficient with the Warhammer<</if>>
<<if $Disciplines["Weaponskill-Sword"]>><br><br>You are proficient with the Sword<</if>>
<<if $Disciplines["Weaponskill-Axe"]>><br>You are proficient with the Axe<</if>>
<<if $Disciplines["Weaponskill-Quarterstaff"]>><br>You are proficient with the Quarterstaff<</if>>
<<if $Disciplines["Weaponskill-Broadsword"]>><br>You are proficient with the Broadsword<</if>><</nobr>>
Do you want to keep these disciplines?
Yes
No
I decided to start doing some research and see what other ways I could write this (without starting over from the beginning). After a while I found something - but I need to go back again to explain it.<<nobr>><<if $Disciplines["AnimalKinship"]>><br>You know the Animal Kinship discipline<</if>>
<<if $Disciplines["Camouflage"]>><br>You know the Camouflage discipline<</if>>
<<if $Disciplines["Healing"]>><br>You know the Healing discipline<</if>>
<<if $Disciplines["Hunting"]>><br>You know the Hunting discipline<</if>>
<<if $Disciplines["Mindblast"]>><br>You know the Mindblast discipline<</if>>
<<if $Disciplines["Mindshield"]>><br>You know the Mindshield discipline<</if>>
<<if $Disciplines["MindOverMatter"]>><br>You know the Mind Over Matter discipline<</if>>
<<if $Disciplines["SixthSense"]>><br>You know the Sixth Sense discipline<</if>>
<<if $Disciplines["Tracking"]>><br>You know the Tracking discipline<</if>>
<<if $Disciplines["Weaponskill-Dagger"]>><br>You are proficient with the Dagger<</if>>
<<if $Disciplines["Weaponskill-Spear"]>><br>You are proficient with the Spear<</if>>
<<if $Disciplines["Weaponskill-Mace"]>><br>You are proficient with the Mace<</if>>
<<if $Disciplines["Weaponskill-ShortSword"]>><br>You are proficient with the Short Sword<</if>>
<<if $Disciplines["Weaponskill-Warhammer"]>><br>You are proficient with the Warhammer<</if>>
<<if $Disciplines["Weaponskill-Sword"]>><br><br>You are proficient with the Sword<</if>>
<<if $Disciplines["Weaponskill-Axe"]>><br>You are proficient with the Axe<</if>>
<<if $Disciplines["Weaponskill-Quarterstaff"]>><br>You are proficient with the Quarterstaff<</if>>
<<if $Disciplines["Weaponskill-Broadsword"]>><br>You are proficient with the Broadsword<</if>><</nobr>>
Do you want to keep these disciplines?
Yes
No
The disciplines seemed really simple, there is just a list of 10 (-ish) that either you have or don't. Before I even started on this documentation I had seen something somewhere about how to define the whole group of them - which I adapted to produce my variable...
<<set $Disciplines to {"Camouflage": false,
"Hunting": false,
"SixthSense": false,
"Tracking": false,
"Healing": false,
"Weaponskill-Dagger": false,
"Weaponskill-Spear": false,
"Weaponskill-Mace": false,
"Weaponskill-ShortSword": false,
"Weaponskill-Warhammer": false,
"Weaponskill-Sword": false,
"Weaponskill-Axe": false,
"Weaponskill-Quarterstaff": false,
"Weaponskill-Broadsword": false,
"Mindshield": false,
"Mindblast": false,
"AnimalKinship": false,
"MindOverMatter": false}>>
Using the same (now forgotten) source I had found, I had my way to check for a discipline in the list...
<<if $Disciplines["SixthSense"]>>
And my way to add a discipline to the list, changing it to ‘true’ from ‘false’...
<<set $Disciplines to {"SixthSense": true}>>
All of which had seemed to be working just fine. But as I was researching (again) I found that there might be an even easier way to do this.
I think, if my limited understanding is right, what I was doing was creating a JavaScript Object, that list of every discipline and it's true/false flag. Which, looking at it the second time, kind of seemed like overkill. I only really cared about the disciplines that the character actually had, the ones they didn't was basically irrellevent. So all I needed was some container for the known disciplines. Which, my research suggested, was best handled with an array.
I already kind of had an array, the list of disciplines, but with a second array, the true/false bits. All I needed was just one of those. So I changed my code(s) to this..
Again, I need to set the array, but this time to something blank (after all, the player hasn't chosen any disciplines yet)...
<<set $Disciplines to []>>
Then, to add a discipline is just a ‘push’...
<<set $Disciplines.push ("AnimalKinship")>>
And to check for one is a ‘contains’...
<<if $Disciplines.contains("AnimalKinship")>>
All of which seemed pretty easy, so I changed the code of those last two pages to...
<<nobr>><<set $Disciplines to []>>
<<set _i to random (1, 9)>>
<<set _chosen to 0>>
<</nobr>>You may now choose the 5 disciplines that you have learned during your training...
<span id="choose_warn"></span>
<span id="ak_choose"><<click "Learn Animal Kinship.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("AnimalKinship")>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="c_choose"><<click "Learn Camouflage.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Camouflage")>>
<<replace #c_choose>>You know the Camouflage discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="h_choose"><<click "Learn Healing.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Healing")>>
<<replace #h_choose>>You know the Healing discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="hn_choose"><<click "Learn Hunting.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Hunting")>>
<<replace #hn_choose>>You know the Hunting discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mb_choose"><<click "Learn Mindblast.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Mindblast")>>
<<replace #mb_choose>>You know the Mindblast discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ms_choose"><<click "Learn Mindshield.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Mindshield")>>
<<replace #ms_choose>>You know the Mindshield discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mom_choose"><<click "Learn Mind Over Matter.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("MindOverMatter")>>
<<replace #mom_choose>>You know the Mind Over Matter discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ss_choose"><<click "Learn Sixth Sense.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("SixthSense")>>
<<replace #ss_choose>>You know the Sixth Sense discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="t_choose"><<click "Learn Tracking.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Tracking")>>
<<replace #t_choose>>You know the Tracking discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
Choose the <span id="wpn_choose"><<click "Weaponskill discipline.">>
<<if _chosen lt 5>>
<<replace #wpn_choose>>Weaponskill discipline.<</replace>>
<<if _i == 1>>
<<set $Disciplines.push ("Weaponskill-Dagger")>>
<<replace #wpn_prof>> You are proficient with the Dagger<</replace>>
<<elseif _i == 2>>
<<set $Disciplines.push ("Weaponskill-Spear")>>
<<replace #wpn_prof>> You are proficient with the Spear<</replace>>
<<elseif _i == 3>>
<<set $Disciplines.push ("Weaponskill-Mace")>>
<<replace #wpn_prof>> You are proficient with the Mace<</replace>>
<<elseif _i == 4>>
<<set $Disciplines.push ("Weaponskill-ShortSword")>>
<<replace #wpn_prof>> You are proficient with the Short Sword<</replace>>
<<elseif _i == 5>>
<<set $Disciplines.push ("Weaponskill-Warhammer")>>
<<replace #wpn_prof>> You are proficient with the Warhammer<</replace>>
<<elseif _i == 6>>
<<set $Disciplines.push ("Weaponskill-Sword")>>
<<replace #wpn_prof>> You are proficient with the Sword<</replace>>
<<elseif _i == 7>>
<<set $Disciplines.push ("Weaponskill-Axe")>>
<<replace #wpn_prof>> You are proficient with the Axe<</replace>>
<<elseif _i == 8>>
<<set $Disciplines.push ("Weaponskill-Quarterstaff")>>
<<replace #wpn_prof>> You are proficient with the Quarterstaff<</replace>>
<<elseif _i == 9>>
<<set $Disciplines.push ("Weaponskill-Broadsword")>>
<<replace #wpn_prof>> You are proficient with the Broadsword<</replace>>
<</if>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span><span id="wpn_prof"></span>
[[Review and Continue->disciplines 2 verify]]
<<set _i to random (1, 9)>>
<<set _chosen to 0>>
<</nobr>>You may now choose the 5 disciplines that you have learned during your training...
<span id="choose_warn"></span>
<span id="ak_choose"><<click "Learn Animal Kinship.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("AnimalKinship")>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="c_choose"><<click "Learn Camouflage.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Camouflage")>>
<<replace #c_choose>>You know the Camouflage discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="h_choose"><<click "Learn Healing.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Healing")>>
<<replace #h_choose>>You know the Healing discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="hn_choose"><<click "Learn Hunting.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Hunting")>>
<<replace #hn_choose>>You know the Hunting discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mb_choose"><<click "Learn Mindblast.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Mindblast")>>
<<replace #mb_choose>>You know the Mindblast discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ms_choose"><<click "Learn Mindshield.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Mindshield")>>
<<replace #ms_choose>>You know the Mindshield discipline.<</replace>><<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="mom_choose"><<click "Learn Mind Over Matter.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("MindOverMatter")>>
<<replace #mom_choose>>You know the Mind Over Matter discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="ss_choose"><<click "Learn Sixth Sense.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("SixthSense")>>
<<replace #ss_choose>>You know the Sixth Sense discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
<span id="t_choose"><<click "Learn Tracking.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("Tracking")>>
<<replace #t_choose>>You know the Tracking discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
Choose the <span id="wpn_choose"><<click "Weaponskill discipline.">>
<<if _chosen lt 5>>
<<replace #wpn_choose>>Weaponskill discipline.<</replace>>
<<if _i == 1>>
<<set $Disciplines.push ("Weaponskill-Dagger")>>
<<replace #wpn_prof>> You are proficient with the Dagger<</replace>>
<<elseif _i == 2>>
<<set $Disciplines.push ("Weaponskill-Spear")>>
<<replace #wpn_prof>> You are proficient with the Spear<</replace>>
<<elseif _i == 3>>
<<set $Disciplines.push ("Weaponskill-Mace")>>
<<replace #wpn_prof>> You are proficient with the Mace<</replace>>
<<elseif _i == 4>>
<<set $Disciplines.push ("Weaponskill-ShortSword")>>
<<replace #wpn_prof>> You are proficient with the Short Sword<</replace>>
<<elseif _i == 5>>
<<set $Disciplines.push ("Weaponskill-Warhammer")>>
<<replace #wpn_prof>> You are proficient with the Warhammer<</replace>>
<<elseif _i == 6>>
<<set $Disciplines.push ("Weaponskill-Sword")>>
<<replace #wpn_prof>> You are proficient with the Sword<</replace>>
<<elseif _i == 7>>
<<set $Disciplines.push ("Weaponskill-Axe")>>
<<replace #wpn_prof>> You are proficient with the Axe<</replace>>
<<elseif _i == 8>>
<<set $Disciplines.push ("Weaponskill-Quarterstaff")>>
<<replace #wpn_prof>> You are proficient with the Quarterstaff<</replace>>
<<elseif _i == 9>>
<<set $Disciplines.push ("Weaponskill-Broadsword")>>
<<replace #wpn_prof>> You are proficient with the Broadsword<</replace>>
<</if>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span><span id="wpn_prof"></span>
[[Review and Continue->disciplines 2 verify]]
And to print the ones chosen...
Here are the disciplines that you are proficient with...
<<nobr>><<if $Disciplines.contains("AnimalKinship")>><br>You know the Animal Kinship discipline<</if>>
<<if $Disciplines.contains("Camouflage")>><br>You know the Camouflage discipline<</if>>
<<if $Disciplines.contains("Healing")>><br>You know the Healing discipline<</if>>
<<if $Disciplines.contains("Hunting")>><br>You know the Hunting discipline<</if>>
<<if $Disciplines.contains("Mindblast")>><br>You know the Mindblast discipline<</if>>
<<if $Disciplines.contains("Mindshield")>><br>You know the Mindshield discipline<</if>>
<<if $Disciplines.contains("MindOverMatter")>><br>You know the Mind Over Matter discipline<</if>>
<<if $Disciplines.contains("SixthSense")>><br>You know the Sixth Sense discipline<</if>>
<<if $Disciplines.contains("Tracking")>><br>You know the Tracking discipline<</if>>
<<if $Disciplines.contains("Weaponskill-Dagger")>><br>You are proficient with the Dagger<</if>>
<<if $Disciplines.contains("Weaponskill-Spear")>><br>You are proficient with the Spear<</if>>
<<if $Disciplines.contains("Weaponskill-Mace")>><br>You are proficient with the Mace<</if>>
<<if $Disciplines.contains("Weaponskill-ShortSword")>><br>You are proficient with the Short Sword<</if>>
<<if $Disciplines.contains("Weaponskill-Warhammer")>><br>You are proficient with the Warhammer<</if>>
<<if $Disciplines.contains("Weaponskill-Sword")>><br><br>You are proficient with the Sword<</if>>
<<if $Disciplines.contains("Weaponskill-Axe")>><br>You are proficient with the Axe<</if>>
<<if $Disciplines.contains("Weaponskill-Quarterstaff")>><br>You are proficient with the Quarterstaff<</if>>
<<if $Disciplines.contains("Weaponskill-Broadsword")>><br>You are proficient with the Broadsword<</if>><</nobr>>
Do you want to keep these disciplines?
Yes
No
<<nobr>><<if $Disciplines.contains("AnimalKinship")>><br>You know the Animal Kinship discipline<</if>>
<<if $Disciplines.contains("Camouflage")>><br>You know the Camouflage discipline<</if>>
<<if $Disciplines.contains("Healing")>><br>You know the Healing discipline<</if>>
<<if $Disciplines.contains("Hunting")>><br>You know the Hunting discipline<</if>>
<<if $Disciplines.contains("Mindblast")>><br>You know the Mindblast discipline<</if>>
<<if $Disciplines.contains("Mindshield")>><br>You know the Mindshield discipline<</if>>
<<if $Disciplines.contains("MindOverMatter")>><br>You know the Mind Over Matter discipline<</if>>
<<if $Disciplines.contains("SixthSense")>><br>You know the Sixth Sense discipline<</if>>
<<if $Disciplines.contains("Tracking")>><br>You know the Tracking discipline<</if>>
<<if $Disciplines.contains("Weaponskill-Dagger")>><br>You are proficient with the Dagger<</if>>
<<if $Disciplines.contains("Weaponskill-Spear")>><br>You are proficient with the Spear<</if>>
<<if $Disciplines.contains("Weaponskill-Mace")>><br>You are proficient with the Mace<</if>>
<<if $Disciplines.contains("Weaponskill-ShortSword")>><br>You are proficient with the Short Sword<</if>>
<<if $Disciplines.contains("Weaponskill-Warhammer")>><br>You are proficient with the Warhammer<</if>>
<<if $Disciplines.contains("Weaponskill-Sword")>><br><br>You are proficient with the Sword<</if>>
<<if $Disciplines.contains("Weaponskill-Axe")>><br>You are proficient with the Axe<</if>>
<<if $Disciplines.contains("Weaponskill-Quarterstaff")>><br>You are proficient with the Quarterstaff<</if>>
<<if $Disciplines.contains("Weaponskill-Broadsword")>><br>You are proficient with the Broadsword<</if>><</nobr>>
Do you want to keep these disciplines?
Yes
No
And now everything worked !
I did wrap everything in a <<nobr>> macro with a <br> HTML tag for the print page, that way there weren't blank lines for the disciplines that the player didn't choose.
Okay, so how can we let the player change his mind and reset his discipline choices? Well, really easy at the moment. I declared the empty array for the disciplines on the last page, so if I just back up and reload the last page everything will go back to being squeaky clean. Which is a simple macro...
<<back "No">>
Again, the click-able text is in the macro itself. All this does is go back one Passage. Now, if I decide to move the variable declaration for the $Disciplines array to another page, then I will need to just re-declare it as being empty. I can remove elements, but I don't need to worry about that for now - once the player chooses their disciplines I'm not going to change them again anywhere in the story. I might try to work out some more options and a better system after I get done figuring out how to implement the book itself.
Let's do one more random thing here, just to take a break from all the data. Back on that Passage that lets the player choose their disciplines there was a warning if they chose more than the allotted 5...
Why don't we make that a little more prominent? Like this...
What we need is called CSS (short for Cascading Style Sheets). There are 3 big things that make up Twine / SugarCube - HTML is the code that displays a webpage, CSS is the code that handles how that page looks, and JavaScript (which SugarCube is, ifI understand right) handles how that page acts/ moves/ changes. So we can use some CSS of our own to change the default way that things look.
CSS is pretty easy, really it is just 3 things - what you want to change, what you're changing about it, and what the new look should be. First we need 'what to change' or as I believe it is properly called, a 'selector.' Looking at our code for that page, we already have one...
<</nobr>>You may now choose the 5 disciplines that you have learned during your training...
<span id="choose_warn"></span>
<span id="ak_choose"><<click "Learn Animal Kinship.">>
<<if _chosen lt 5>>
<<set $Disciplines.push ("AnimalKinship")>>
<<replace #ak_choose>>You know the Animal Kinship discipline.<</replace>>
<<set _chosen++>>
<<else>>
<<replace #choose_warn>>You have already chosen the maximum number of disciplines!<</replace>>
<</if>><</click>></span>
Okay, so we have two selectors in the code I copied above, both in bold. They are the <span> HTML tags, and the id=" name" element. We use the #name to target those selectors with our <<replace>> code (in italics).
The code for the Passage all goes here, but the CSS is in a different place. If we click on the title of our story at the bottom-left we get a menu, with the option to ‘Edit Story Stylesheet’...
And that opens where we put our CSS..
And this is going to be our code..
#choose_warn { says what we are going to change. The ‘Cascading’ part of CSS means that one ‘style sheet’ will overwrite the ones before it. So Twine (or, SugarCube I think) has styled everything for us (the dark grey background, white text, all that stuff) in their own CSS style sheet. Now, we can make changes to this one, that I've opened, and our changes will overwrite SugarCube's default CSS. This is great, since SugarCube made the CSS for us we have something to start with that we don't have to worry about - but we can still change anything that we want to look different.
background-color: red; means put a dark red color behind out text (and only where the text is, you'll notice it doesn't cover the whole line - we could do that though if we wanted to)
color: white; means to change the text color to white, which it already is - I'm just putting that to show you some of the different parts that we can change
} and the final curly-brace just says that we're finished with our changes.
There are a ton of different things that we can do to change how the story looks, from the smallest to the largest elements. I'm not going to go into all of it right now, or any of it really - this was just a little break for me to talk about something else. When I'm done writing all this code, however, I am going to go through the story and change how some things look. I just think it's easier to wait until I have everything working to worry about how pretty it is.
Okay, so now we know all the disciplines we have to deal with, we know how to check for them, and we got the player to choose them. We should have a pretty good handle on that. Using them is going to come a bit later, when we finish the rest of the rules and start actually working on Passages/ story. Now there are just two sections of the rules left to work out, Equipment and Combat. I have a feeling our arrays and all the macros we've been using are going to get used again in those sections - along with some new tricks.
No comments:
Post a Comment