Please specify version and format if asking for help, or apply optional tags above:
Twine Version: version 2.3.7
Story Format: SugarCube 2.31.1
Hi there, I am trying to figure out how to get certain people to be in a location on different days. i.e if Monday morning/ Wednesday Evening/ Friday midday. John is at the bar. if Tuesday all day Mary is a the bar. if Friday afternoon Alan is also at the bar. Here is the code I am using for my time and date system. Any help would be appreciated.
/% The names of the Days of the Week. %/ <<set setup.DAYS to ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>> /% The names of the Time Periods of a Day. %/ <<set setup.PERIODS to ["Asleep", "Morning", "Noon", "Afternoon", "Evening", "Night"]>> /% The current Game Day: Monday. %/ <<set $day to 1>> /% The current Time Period: Morning. %/ <<set $period to 1>>
/* * <<now>> * * Displays the current Day of Week, Period of Day and Day Number. */ <<widget "now">> \It is <<print setup.DAYS[$day % 7]>>, <<print setup.PERIODS[$period]>>, Day $day. <</widget>> /* * <<AdvancePeriod [number of periods]>> * * Advance current Time Period by a set number of periods, if no number * if pass to widget then current Time Period is advanced by 1 unit. * * <<AdvancePeriod>> Advances time period by 1 unit. * <<AdvancePeriod 1>> Advances time period by 1 unit. * <<AdvancePeriod 2>> Advances time period by 2 units. * * If the current day's time boundary is exceeded then the Day Number * will also be updated. */ <<widget "AdvancePeriod">> \<<silently>> <<set _offset to 1>> <<set _periodsInDay to setup.PERIODS.length>> <<if $args.length > 0>> <<set _offset to $args>> <</if>> <<set $period += _offset>> /% Update the Day Number as necessary. %/ <<if $period >= _periodsInDay>> <<set $day += Math.trunc($period / _periodsInDay)>> <<set $period to ($period % _periodsInDay)>> <</if>> <</silently>>\ <</widget>> /* * <<NextMorning>> * * Advances the current Time Period to the Morning of the next day. */ <<widget "NextMorning">> \<<silently>> /% Increament the Day Number by 1 unit. %/ <<set $day += 1>> /% Set the current Time Period to the index of the "Morning" element of setup.PERIODS array. %/ <<set $period to 1>> <</silently>>\ <</widget>>
<<if $gameday is Friday>> <<if $gametime is Morning>> John is here <<elseif $gametime is Afternoon>> Alan is here <</if>> <</if>>