Browse Source

[WIP] Demo

Stephan Fuchs 5 months ago
parent
commit
9347c1ce07

+ 53 - 0
sugarcube/src/mods/demo/demo.tw

@@ -0,0 +1,53 @@
+:: Demo[event]
+<!-- 
+	The line above starts a new passage called Demo.
+	This name needs to be unique in the whole project.
+	The tag event inside the brackets tells the engine that this is an Event-Passage, where, among other things, the menus should be deactived.
+	Try clicking on the menu-buttons in the sidebar. You'll see that they are automatically disabled.	
+-->
+<h2>Demo</h2>
+<!--
+	The headline is always h2 for consitency
+	(it's good practive for h1 to be unique inside html-documents... the h1-element here is an invisble "Girl Life"-title inside the sidebar).
+	Adding a headline to passages is optional.
+ -->
+
+<<image "system/1_openings/splashes/splash#.jpg" 1 14>>
+<!--
+	This is the same image-defintion as on the starting screen.
+	Using the image-macro, you need to declare the path of the image you want to display relative to the images-folder.
+	The second and third parameter add a little bit of randomness.
+	They replace the # in the path with a random number between 1 and 14 (inclusive).
+ -->
+
+<p>
+	Welcome to this little demonstration that's intended to explain to you how you can create and change code of Girl Life Sugarcube.
+</p>
+<!--
+	Paragraphes should be inside p-tags.
+ -->
+
+<p>
+	It really only makes sense if you have the source code open, so you can see how it influence the game.
+	You can find this file at <pre>src/mods/demo/demo.tw</pre>
+</p>
+<!-- 
+	One new line for one sentence.
+	If one sentence becomes longer than your screen, you can also add a linebreak before or after special signs.
+	Don't break lines at other places, since the text is oftentimes needed to quickly figure out in which source file the displayed text is located.
+ -->
+
+<<act 'Continue'>>
+	<<gt 'DemoMain'>>
+<</act>>
+<!-- 
+	The act-macro adds an action to the action-bar.
+	The first parameter is the text that's displayed to the user.
+	Like the Sugarcube-macros link and button, the code inside the act-macro is executed when the button is pressed.
+	In this case, the gt-macro is called to send the user to the passage DemoMain.
+	gt is a custom version of goto that handles various custom scripts behind the curtains.
+	Always use gt when you want to send a user to another passage. 
+ -->
+
+
+

+ 80 - 0
sugarcube/src/mods/demo/demoActions.tw

@@ -0,0 +1,80 @@
+:: DemoActions[private indoors noEvents]
+<h2>Actions</h2>
+<<image 'locations/gadukino/forest/blueberry_picking_1.jpg'>>
+<!--
+	You already learned about the difference between act and actCLA.
+	Here we'll take a closer look at the additional flags those macros could have.
+ -->
+
+<<act 'Minimum arousal' undefined `{arousal:10}`>>
+	<<refresh>>
+<</act>>
+<!--
+	This action is only available if your arousal is high enough (in this case: >=10).
+ -->
+
+<<act 'Minimum mood' undefined `{mood:60}`>>
+	<<refresh>>
+<</act>>
+<!--
+	This action is only available if your mood is high enough (in this case: >=60).
+ -->
+
+<<act 'Pay 1000 cash' undefined `{cost:{cash:1000}}`>>
+	<<refresh>>
+<</act>>
+<<act 'Pay 2000 from bank' undefined `{cost:{bank:2000}}`>>
+	<<refresh>>
+<</act>>
+<<act 'Pay 3000 from either' undefined `{cost:{both:3000}}`>>
+	<<refresh>>
+<</act>>
+<!--
+	The cost-flag checks if you have the required amount of money.
+	It also automatically substracts the money from your purse or bank account if you select the action.
+	Note that the both-option is a shorthand for creating two actions.
+ -->
+
+<<act 'Incest-stuff' undefined `{fetish:['incest']}`>>
+	<<refresh>>
+<</act>>
+<!--
+	This action leads to bdsm-content.
+	If the user selected his character to be appalled by this, this action is disabled.
+ -->
+
+<<act 'Smart action' undefined `{skillRequirment:{intelligence:50}}`>>
+	<<refresh>>
+<</act>>
+<!--
+	This action requires a specific skill to have a specific level.
+ -->
+
+<<act 'Waste 10 minutes' undefined `{time:10}`>>
+	<<refresh>>
+<</act>>
+<!--
+	Obvious
+ -->
+
+<<for _demoCounter=0;_demoCounter<3;_demoCounter=_demoCounter+1>>
+	<<actCLA `'Option '+_demoCounter+' (capture)'` undefined `{capture:['_demoCounter']}`>>
+		You hit option _demoCounter.
+		<<act 'Back'>>
+			<<refresh>>
+		<</act>>
+	<</actCLA>>
+	<<actCLA `'Option '+_demoCounter+' (no capture)'`>>
+		You hit option _demoCounter.
+		<<act 'Back'>>
+			<<refresh>>
+		<</act>>
+	<</actCLA>>
+<</for>>
+<!--
+	The code of each action is executed when the action is clicked, NOT when it is defined.
+	Therefore, _democounter is set to 3 when any one of the six actions defined above is clicked.
+	Sugarcube has the capture-macro for similiar cases. This won't help us here!
+	You need to set the capture-flag to tell the action which variables it needs to create local copies of.
+	Try out the actions above: the capturing options will show the correct number, while the other three will always display 3.
+ -->

+ 101 - 0
sugarcube/src/mods/demo/demoMain.tw

@@ -0,0 +1,101 @@
+:: DemoMain[private indoors noEvents]
+<!--
+	Now we're on the passage DemoMain.
+	Not that this is no longer an event.
+	Therefore you can now use the menus again.
+	Try it. You'll see that exiting them leads you back here automatically.
+
+	Now let's take a look at the new three tags.
+	private means that you are at a private location, such as a private apartment or garden.
+	The opposite is public.
+	Some events and options only apply to either of these tags.
+
+	indoors means that you're currently not effected by the weather.
+	The opposite would be outdoors.
+	As with public/private, this has various effects on events and player-options.
+
+	Of course events can take combinations of tags into account.
+	For example, you automatically take off your shoes at private indoors locations.
+
+	The third tag just tells the engine that it shouldn't fire random events here.
+	That's added so our demo isn't interrupted.
+	You'd usually not add this tag to locations you create.
+ -->
+
+<h2>Demo Location</h2>
+<!--
+	As before: always h2.
+ -->
+
+<<image 'locations/construction/obekt.jpg'>>
+<!--
+	An image without randomness this time.
+ -->
+
+<<actCLA 'Click me'>>
+	<p>
+		Everything is gone.
+	</p>
+	<<set $finances.cash += 1000>>
+	<<act 'Refresh'>>
+		<<refresh>>
+	<</act>>
+<</actCLA>>
+<!--
+	This is the actCLA-macro.
+	It behaves just like the act-macro with one major difference: it replaces the main window with its' contents.
+	As you can see with the included act-macro, the list of available actions is also updated.
+	And, if you paid close attention to the sidebar, you might have noticed that it has been updated as well.
+	You gained 1000 cash.
+	Since you are still on the same passage, reloading your browser window (F5) will throw you back before you hit any actCLA-button.
+	Try it. You'll notice that the 1000 cash are gone again.
+	This does not apply to the refresh-macro.
+	It will reload the current passage while preserving everything that happened in the meantime.
+ -->
+
+ <<act 'I made it to the top' undefined `{priority:1000}`>>
+	<<refresh>>
+<</act>>
+<!--
+	This button has no practical use, but it shows you how you can order your actions.
+	By default, your actions appear in the order you wrote them inside the source code.
+	If you want to order them in another way, you need to set the priority-flag inside the flag-object as seen above.
+	Don't mind the second paramenter.
+	Just set it to undefined everytime you need to set the third parameter.
+ -->
+
+<p>
+	<<either 3>>
+		Welcome to the demo location.
+	<<or 1>>
+		Welcome.
+	<<or>>
+		Hello.
+	<</either>>
+	<!--
+		This is the either-or-macro.
+		It executes a random piece of code (in this case that's only displaying text, but it could be anything).
+		The numbers are the weight of each of the options.
+		If no number is specified, it defaults to 1.
+		Therefore, we have a total weight of 5 (3+1+1).
+		The chance of the first option being chosen is therefore 60% (3/5) while each of the other two has a chance of 20% (1/5).
+		This code is re-evaluated each time the passage is visited.
+		You can test it by hitting the "I made it to the top"-action several times.
+	 -->
+</p>
+
+<<ConnectedLocation 'Time' 'DemoTime' '' 'locations/gadukino/forest/gadforest4.jpg' 5>>
+<!--
+	The ConnectedLocation-macro will add a link to another location to the connected-location-bar.
+	The first parameter is the name that should be displayed to the user.
+	The second is the passage the link will lead to.
+	In this case it's DemoTime.
+	The third parameter is used to transfer additional information to the destination passage.
+	We don't need it here, that's why it's empty.
+	The fourth parameter is the image that should be displayed to the user.
+	Parameter five is the amount of time in minutes it takes to travel to the given passage.
+	You should avoid numbers greater than 90 because, among other problems, it makes handling of hunger and thirst difficult for the player.
+	Parameter six (not used here) accepts additional flags.
+ -->
+
+ <<ConnectedLocation 'Actions' 'DemoActions' '' 'locations/gadukino/forest/blueberry_picking_1.jpg' 1>>

+ 109 - 0
sugarcube/src/mods/demo/demoTime.tw

@@ -0,0 +1,109 @@
+:: DemoTime[public outdoors noEvents]
+<!--
+	public and outdoors this time.
+	Look above for the meaning of this.
+
+	You can see one effect of the combination of the public and the outdoors-tag here: the Wait-action is automatically added to the passage.
+ -->
+
+<h2>Time</h2>
+<<imageDayNight 'locations/gadukino/forest/#.jpg' 'gadforest4' 'gadforest_night1'>>
+<!--
+	Similar to random images, the imageDayNight-macro replaces the # in the images path (parameter 1) with 
+	the second parameter if it's daytime and
+	the third parameter if it's nighttime.
+	You can use the cheat menu to advance time to see the difference.
+ -->
+
+<<ConnectedLocation 'Leave' 'DemoMain' '' 'locations/construction/obekt.jpg' 5>>
+
+<p>
+	<<if $time.isWinter>>
+		It's winter.
+	<<else>>
+		It's not winter.
+	<</if>>
+	<!--
+		This executes one branch depending on whether it's currently winter.
+		That's most commonly used to decide which image to display, but it could also, like here, be used to change text or to execute other saison-dependent code.
+	 -->
+	We are at daystage <<=$time.dayStage>>.
+	<!--1 - dawn
+		2 - midday
+		3 - sunset
+		4 - the beginning of the night
+		5 - night
+		6 - the end of the night
+	-->
+</p>
+
+<p>
+	Current time (h:m d.m.y): <<=$time.hour>>:<<=$time.minutes>> <<=$time.day>>.<<=$time.month>>.<<=$time.year>> (day <<=$time.weekday>> of the week).
+	<!--
+		These are the time-informations you'll need most of the times.
+	-->
+	Or, in short: <<=$time.dateTimeString>>.
+	<!--
+		Use this if you need to display the current time.
+	-->
+</p>
+
+<p>
+	It is day <<=$time.daystart>> of your current game.
+	<!--
+		This number is oftentimes used by scripts to determine how long it has been since something happened.
+		For example, the school uses this number (comparing it with the day of your last presence) to determine how long you have been absent from school.
+	 -->
+</p>
+
+<p>
+	Only <<=$time.daysDifference(24,12,-2)>> days til X-mas!
+	<!--
+		Set the year to -2 to get the next occurence of the date (-1 would be current year and could therefore result in negative numbers).
+	-->
+</p>
+
+<<act 'Wait 10 minutes'>>
+	<<addtime 10>>
+	<<refresh>>
+<</act>>
+<!--
+	The addtime-macro adds the specified minutes to the current time.
+	The system takes care of everything you don't want to worry about, such as sleep, hunger, thirst, timed events, etc.
+ -->
+
+<<act 'Wait til 06:00'>>
+	<<run $time.advanceTo(6,0,true)>>
+	<<refresh>>
+<</act>>
+
+<!--
+	No need to calculate if you want to wait til a certain time.
+	Keep in mind that the time passes for your character as well.
+	She will most likely become hungry, thirsty and sleepy.
+	If parameter three is not set to true, this script will silently fail if it's past the given time.
+-->
+
+<<cooldown 'demoCooldown' 15>>
+	<p>
+		You can only see me every 15 minutes.
+	</p>
+<</cooldown>>
+<!--
+	The cooldown-macro executes it's code and then deactivates itself for the given number of minutes.
+	The first parameter needs to be a unique identifier.
+	You can test the code above by hitting the "Wait 10 minutes"-action several times.
+	You will see the text only every second time.
+	As with other macros, any kind of code could be included inside the cooldown-macro.
+ -->
+
+<<onceADay 'demoOnceADay'>>
+	<p>
+		You can only see me once a day.
+	</p>
+<</onceADay>>
+<!--
+	Similar to cooldown, onceADay only executes once a day.
+	You also need to use a unique identifier as a parameter here.
+ -->
+