0 votes
by (750 points)

I've been revamping my main TWINE Project, heh. Well. I'm having some issues. And it's probably something obvious or inefficient. I now am trying to sort of do a psuedo-time system - where it's mostly superficial - it affects the 'events' in the game, and who the bouncer 'might' be through the 'either' macro. It keeps insisting there's a bad 'set' evaluation in StoryInit, but I have no idea why or how.  It essentially picks the 'day' at random at first startup, and SHOULD pick the bouncer at random, and one of four events that may happen that day. (There's sometimes 4 events in one day, others only one.) 

<<set $Days to {
		sunday: {
		        day: "Sunday",
				obouncer: "Gahlan",
				hbouncer: "Jonas",
				sbouncer: "Anwyn",
				gbouncer: "Leon",
				1event: "Zorcoball Brawling Night",
				2event: "Dwarf Blood Ball Games"
		},
		monday: {
		        day: "Monday",
				obouncer: "Anwyn",
				hbouncer: "Jonas",
				gbouncer: "Gahlan", /* May not have him here */
				1event: "Horns and Hooves",
				2event: "Satyr's Blessings",
				3event: "Bonding with the Family"
				},
		tuesday: {
		        day: "Tuesday",
				hbouncer: "Jonas",
				sbouncer: "Anwyn",
				obouncer: "Gahlan",
				1event: "Open Karoke Mic Night"
				},
		wednesday: {
		        day: "Wednesday",
				hbouncer: "Jonas",
				obouncer: "Gahlan",
				sbouncer: "Anwyn",
				1event: "Diety's Gatherings",
				2event: "Etheral Competition",
				3event: "Bear Cuddles"
				},
		thursday: {
		        day: "Thursday",
				hbouncer: "Jonas",
				obouncer: "Gahlan",
				sbouncer: "Anwyn",
				1event: "Gaming Night",
				},
		friday: {
		        day: "Friday",
				sbouncer: "Anwyn",
				hbouncer: "Jonas",
				obouncer: "Gahlan",
				gbouncer: "Leon",
				1event: "Unity of Bands"
				},
		saturday: {
		        day: "Saturday",
				hbouncer: "Jonas",
				obouncer: "Gahlan",
				sbouncer: "Anwyn",
				gbouncer: "Leon",
				1event: "Dreams of the Shifters",
				2event: "Orc Pridehood Feast",
				3event: "Centaurs and Cowboys",
				4event: "Gathering of the Cloaked Clans"
				},
	}>>

And this is what I was doing to 'check' what day it was, and the bouncer in question, and events. 

Plus I was setting the day with this code - in StoryInit. 

<<set $today to either($Days["sunday"].day, $Days["monday"].day, $Days["tuesday"].day, $Days["wednesday"].day, $Days["thursday"].day, $Days["friday"].day, $Days["saturday"].day)>>

 And this below is supposed to be a 'condition' check. If it's Sunday, set particular event to 1 to 4 events. And if conditions to pick particular 'bouncers'. 

<<if $today is $Days["sunday"].day>>
	<<set $event to either($Days["sunday"].1event, $Days["sunday"].2event)>>
	<<if $event is $Days["sunday"].1event>>
		<<set $bouncer to either($Days["sunday"].hbouncer, $Days["sunday"].sbouncer, $Days["sunday"].gbouncer)>>\
	<<elseif $bouncer is $Days["sunday"].2event>>\
		<<set $bouncer to $Days["sunday"].obouncer>>
	<</if>>\
<<elseif $today is $Days["monday"].day>>
	<<set $event to either($Days["monday"].1event, $Days["monday"].2event, $Days["monday"].3event)>>
	     <<if $event is $Days["monday"].1event>>
		     <<set $bouncer to either($Days["monday"].sbouncer, $Days["monday"].hbouncer, $Days["monday"].obouncer)>>\
	      <<elseif $event is $Days["monday"].3event>>
	                <<set $bouncer to $Days["monday"].sbouncer>>
	       <<elseif $event is $Days["monday"].2event>>
	             <<set $bouncer to either($Days["monday"].sbouncer, $Days["monday"].obouncer)>>
	        <</if>>\
<<elseif $today is $Days["tuesday"].day>>
		<<set $event to $Days["tuesday"].1event>>
		<<set $bouncer to either($Days["tuesday"].obouncer, $Days["tuesday"].hbouncer, $Days["tuesday"].sbouncer)>>
<<elseif $today is $Days["wednesday"].day>>
	<<set $event to either($Days["wednesday"].1event, $Days["wednesday"].2event, $Days["wednesday"].3event)>>
	    <<if $event is $Days["wednesday"].1event>>
		    <<set $bouncer to either($Days["wednesday"].sbouncer, $Days["wednesday"].hbouncer, $Days["wednesday"].obouncer)>>\
	    <<elseif $event is $Days["wednesday"].2event>>
	             <<set $bouncer to either($Days["wednesday"].sbouncer, $Days["wednesday"].hbouncer, $Days["wednesday"].obouncer)>>\
	<<elseif $event is $Days["wednesday"].3event>>
	             <<set $bouncer to either($Days["wednesday"].sbouncer, $Days["wednesday"].hbouncer, $Days["wednesday"].obouncer)>>\
	 <</if>>\
<<elseif $today is $Days["thursday"].day>>
	<<set $event to Days["thursday"].1event>> 
	<<set $bouncer to either($Days["thursday"].sbouncer, $Days["thursday"].hbouncer, $Days["thursday"].obouncer)>>\
<<elseif $today is $Days["friday"].day>>
	<<set $event to Days["thursday"].1event>> 
	<<set $bouncer to either($Days["friday"].sbouncer, $Days["friday"].hbouncer, $Days["friday"].obouncer, $Days["friday"].gbouncer)>>\
<<elseif $today is $Days["saturday"].day>>
	<<set $event to either($Days["saturday"].1event, $Days["saturday"].2event, $Days["saturday"].3event, $Days["saturday"].4event)>>
	<<if $event is $Days["saturday"].1event>>
		<<set $bouncer to either($Days["saturday"].sbouncer, $Days["saturday"].hbouncer, $Days["saturday"].obouncer, $Days["saturday"].gbouncer)>>\
	<<elseif $event is $Days["saturday"].2event>>
	         <<set $bouncer to $Days["saturday"].obouncer>>\
	<<elseif $event is $Days["saturday"].3event>>
	          <<set $bouncer to either($Days["saturday"].sbouncer, $Days["saturday"].hbouncer, $Days["saturday"].obouncer,  $Days["saturday"].gbouncer)>>\
	<<elseif $event is $Days["saturday"].4event>>
		<<set $bouncer to either($Days["saturday"].sbouncer, $Days["saturday"].hbouncer,  $Days["saturday"].gbouncer)>>
	<</if>>\
<</if>>

Everything 'seems' to look OK to me, but I could be doing the IF conditions 'wrong', like it can't be $event is $Days...etc. I hope this can be cleared up - I'd love to get this working. 

1 Answer

0 votes
by (68.6k points)

In the future, please provide the entire error message.

In your object literals, your event property names (e.g. 1event) are invalid as identifiers, as identifiers may not start with a numeral.  You will need to either change their names, to make them valid identifiers, or change how you're working with them, if you'd prefer to keep the current names.

 

1. Change their names to valid identifiers

Simply rename them (e.g. 1event to event1):

	sunday: {
		day: "Sunday",
		obouncer: "Gahlan",
		hbouncer: "Jonas",
		sbouncer: "Anwyn",
		gbouncer: "Leon",
		event1: "Zorcoball Brawling Night",
		event2: "Dwarf Blood Ball Games"
	},

Don't forget to update their names where you're accessing them in the rest of your code.

 

2. Change how you're working with them

You need to quote their names in your object literals:

	sunday: {
		day: "Sunday",
		obouncer: "Gahlan",
		hbouncer: "Jonas",
		sbouncer: "Anwyn",
		gbouncer: "Leon",
		"1event": "Zorcoball Brawling Night",
		"2event": "Dwarf Blood Ball Games"
	},

And use the square bracket notation to access them:

$Days["sunday"]["1event"]

 

by (750 points)
I will next time :) And thank you so much for the help. It seems like it was simply changing the 1event, etc etc to event1 that did the trick. Now I have a randomized day, event, and bouncer that works there at the time of the playthrough. :)

Thank you so much again :D

Does the either() macro need to have $Days["monday"]["day"] as a value to pick from or is $Days["monday"].day still valid? I changed it to the double bracket example and it still works.
by (68.6k points)
You may always use the square bracket notation.  The dot notation may be used whenever the property name is also a valid identifier (meaning: the first, mandatory, character must be either a letter, dollar sign, or underscore; subsequent, optional, characters may any allowed as the first character and digits).
...