@@ -286,7 +286,7 @@ public static void Init(Shell shell) {
286
286
// Currently mostly the things related to time.
287
287
f = Intrinsic . Create ( "world" ) ;
288
288
f . code = ( context , partialResult ) => {
289
- return new Intrinsic . Result ( WorldModule ( ) ) ;
289
+ return new Intrinsic . Result ( WorldInfo ( ) ) ;
290
290
} ;
291
291
}
292
292
@@ -1619,69 +1619,60 @@ public static ValMap TextModule() {
1619
1619
1620
1620
1621
1621
1622
- static ValMap worldModule ;
1622
+ static ValMap worldInfo ;
1623
1623
1624
1624
/// <summary>
1625
1625
/// Creates a module for accessing data about the SDV world.
1626
1626
/// </summary>
1627
1627
/// <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
+ }
1632
1633
1633
1634
// The in-game time on this day.
1634
1635
// 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 ) ;
1640
1637
1641
1638
// Days since start is the amount of in-game days since this farm was started.
1642
1639
// 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 ) ;
1648
1641
1649
1642
// 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 ) ;
1655
1647
1656
1648
// 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 ( ) ) ;
1662
1650
1663
1651
// 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 ) ;
1669
1653
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 ) ;
1676
1656
1677
1657
// 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 ) ;
1681
1670
} ;
1682
- worldModule [ "seasonName" ] = f . GetFunc ( ) ;
1683
1671
1684
- return worldModule ;
1672
+ // Daily luck
1673
+ worldInfo [ "luck" ] = new ValNumber ( Game1 . player . DailyLuck ) ;
1674
+
1675
+ return worldInfo ;
1685
1676
}
1686
1677
1687
1678
/// <summary>
0 commit comments