@@ -286,7 +286,7 @@ public static void Init(Shell shell) {
286286 // Currently mostly the things related to time.
287287 f = Intrinsic . Create ( "world" ) ;
288288 f . code = ( context , partialResult ) => {
289- return new Intrinsic . Result ( WorldModule ( ) ) ;
289+ return new Intrinsic . Result ( WorldInfo ( ) ) ;
290290 } ;
291291 }
292292
@@ -1619,69 +1619,60 @@ public static ValMap TextModule() {
16191619
16201620
16211621
1622- static ValMap worldModule ;
1622+ static ValMap worldInfo ;
16231623
16241624 /// <summary>
16251625 /// Creates a module for accessing data about the SDV world.
16261626 /// </summary>
16271627 /// <returns>A value map with functions to get information about the world.</returns>
1628- static ValMap WorldModule ( ) {
1629- if ( worldModule != null ) { return worldModule ; }
1630- worldModule = new ValMap ( ) ;
1631- worldModule . assignOverride = DisallowAllAssignment ;
1628+ static ValMap WorldInfo ( ) {
1629+ if ( worldInfo == null ) {
1630+ worldInfo = new ValMap ( ) ;
1631+ worldInfo . assignOverride = DisallowAllAssignment ;
1632+ }
16321633
16331634 // The in-game time on this day.
16341635 // Can exceed 2400 when the farmer refuses to sleep.
1635- Intrinsic f = Intrinsic . Create ( "" ) ;
1636- f . code = ( context , partialResult ) => {
1637- return new Intrinsic . Result ( new ValNumber ( Game1 . timeOfDay ) ) ;
1638- } ;
1639- worldModule [ "timeOfDay" ] = f . GetFunc ( ) ;
1636+ worldInfo [ "timeOfDay" ] = new ValNumber ( Game1 . timeOfDay ) ;
16401637
16411638 // Days since start is the amount of in-game days since this farm was started.
16421639 // Day 1 of year 1 is 1 in this function.
1643- f = Intrinsic . Create ( "" ) ;
1644- f . code = ( context , partialResult ) => {
1645- return new Intrinsic . Result ( new ValNumber ( SDate . Now ( ) . DaysSinceStart ) ) ;
1646- } ;
1647- worldModule [ "daySinceGameStart" ] = f . GetFunc ( ) ;
1640+ worldInfo [ "daySinceGameStart" ] = new ValNumber ( SDate . Now ( ) . DaysSinceStart ) ;
16481641
16491642 // The current day in the in-game season.
1650- f = Intrinsic . Create ( "" ) ;
1651- f . code = ( context , partialResult ) => {
1652- return new Intrinsic . Result ( new ValNumber ( SDate . Now ( ) . Day ) ) ;
1653- } ;
1654- worldModule [ "dayOfSeason" ] = f . GetFunc ( ) ;
1643+ worldInfo [ "dayOfSeason" ] = new ValNumber ( SDate . Now ( ) . Day ) ;
1644+
1645+ // The number of the in-game day of week (0 = Sunday).
1646+ worldInfo [ "dayOfWeek" ] = new ValNumber ( ( int ) SDate . Now ( ) . DayOfWeek ) ;
16551647
16561648 // The name of the in-game day.
1657- f = Intrinsic . Create ( "" ) ;
1658- f . code = ( context , partialResult ) => {
1659- return new Intrinsic . Result ( new ValString ( SDate . Now ( ) . DayOfWeek . ToString ( ) ) ) ;
1660- } ;
1661- worldModule [ "dayOfWeekName" ] = f . GetFunc ( ) ;
1649+ worldInfo [ "dayOfWeekName" ] = new ValString ( SDate . Now ( ) . DayOfWeek . ToString ( ) ) ;
16621650
16631651 // The in-game year, starts at 1.
1664- f = Intrinsic . Create ( "" ) ;
1665- f . code = ( context , partialResult ) => {
1666- return new Intrinsic . Result ( new ValNumber ( SDate . Now ( ) . Year ) ) ;
1667- } ;
1668- worldModule [ "year" ] = f . GetFunc ( ) ;
1652+ worldInfo [ "year" ] = new ValNumber ( SDate . Now ( ) . Year ) ;
16691653
1670- // The numeric representation for the current in-game season.
1671- f = Intrinsic . Create ( "" ) ;
1672- f . code = ( context , partialResult ) => {
1673- return new Intrinsic . Result ( new ValNumber ( SDate . Now ( ) . SeasonIndex ) ) ;
1674- } ;
1675- worldModule [ "season" ] = f . GetFunc ( ) ;
1654+ // The numeric representation for the current in-game season (0 = spring).
1655+ worldInfo [ "season" ] = new ValNumber ( SDate . Now ( ) . SeasonIndex ) ;
16761656
16771657 // The human-readable representation for the current in-game season.
1678- f = Intrinsic . Create ( "" ) ;
1679- f . code = ( context , partialResult ) => {
1680- return new Intrinsic . Result ( new ValString ( SDate . Now ( ) . Season ) ) ;
1658+ worldInfo [ "seasonName" ] = new ValString ( SDate . Now ( ) . Season ) ;
1659+
1660+ // The current weather
1661+ {
1662+ var loc = ( Farm ) Game1 . getLocationFromName ( "Farm" ) ;
1663+ var weather = Game1 . netWorldState . Value . GetWeatherForLocation ( loc . GetLocationContext ( ) ) ;
1664+ string result = "Sunny" ;
1665+ if ( weather . isLightning ) result = "stormy" ;
1666+ else if ( weather . isRaining ) result = "raining" ;
1667+ else if ( weather . isSnowing ) result = "snowing" ;
1668+ else if ( weather . isDebrisWeather ) result = "windy" ;
1669+ worldInfo [ "weather" ] = new ValString ( result ) ;
16811670 } ;
1682- worldModule [ "seasonName" ] = f . GetFunc ( ) ;
16831671
1684- return worldModule ;
1672+ // Daily luck
1673+ worldInfo [ "luck" ] = new ValNumber ( Game1 . player . DailyLuck ) ;
1674+
1675+ return worldInfo ;
16851676 }
16861677
16871678 /// <summary>
0 commit comments