diff --git a/M1/M1API.cs b/M1/M1API.cs
index 60836e3..b3179cb 100644
--- a/M1/M1API.cs
+++ b/M1/M1API.cs
@@ -286,7 +286,7 @@ public static void Init(Shell shell) {
// Currently mostly the things related to time.
f = Intrinsic.Create("world");
f.code = (context, partialResult) => {
- return new Intrinsic.Result(WorldModule());
+ return new Intrinsic.Result(WorldInfo());
};
}
@@ -1619,69 +1619,60 @@ public static ValMap TextModule() {
- static ValMap worldModule;
+ static ValMap worldInfo;
///
/// Creates a module for accessing data about the SDV world.
///
/// A value map with functions to get information about the world.
- static ValMap WorldModule() {
- if(worldModule != null) { return worldModule; }
- worldModule = new ValMap();
- worldModule.assignOverride = DisallowAllAssignment;
+ static ValMap WorldInfo() {
+ if (worldInfo == null) {
+ worldInfo = new ValMap();
+ worldInfo.assignOverride = DisallowAllAssignment;
+ }
// The in-game time on this day.
// Can exceed 2400 when the farmer refuses to sleep.
- Intrinsic f = Intrinsic.Create("");
- f.code = (context, partialResult) => {
- return new Intrinsic.Result(new ValNumber(Game1.timeOfDay));
- };
- worldModule["timeOfDay"] = f.GetFunc();
+ worldInfo["timeOfDay"] = new ValNumber(Game1.timeOfDay);
// Days since start is the amount of in-game days since this farm was started.
// Day 1 of year 1 is 1 in this function.
- f = Intrinsic.Create("");
- f.code = (context, partialResult) => {
- return new Intrinsic.Result(new ValNumber(SDate.Now().DaysSinceStart));
- };
- worldModule["daySinceGameStart"] = f.GetFunc();
+ worldInfo["daySinceGameStart"] = new ValNumber(SDate.Now().DaysSinceStart);
// The current day in the in-game season.
- f = Intrinsic.Create("");
- f.code = (context, partialResult) => {
- return new Intrinsic.Result(new ValNumber(SDate.Now().Day));
- };
- worldModule["dayOfSeason"] = f.GetFunc();
+ worldInfo["dayOfSeason"] = new ValNumber(SDate.Now().Day);
+
+ // The number of the in-game day of week (0 = Sunday).
+ worldInfo["dayOfWeek"] = new ValNumber((int)SDate.Now().DayOfWeek);
// The name of the in-game day.
- f = Intrinsic.Create("");
- f.code = (context, partialResult) => {
- return new Intrinsic.Result(new ValString(SDate.Now().DayOfWeek.ToString()));
- };
- worldModule["dayOfWeekName"] = f.GetFunc();
+ worldInfo["dayOfWeekName"] = new ValString(SDate.Now().DayOfWeek.ToString());
// The in-game year, starts at 1.
- f = Intrinsic.Create("");
- f.code = (context, partialResult) => {
- return new Intrinsic.Result(new ValNumber(SDate.Now().Year));
- };
- worldModule["year"] = f.GetFunc();
+ worldInfo["year"] = new ValNumber(SDate.Now().Year);
- // The numeric representation for the current in-game season.
- f = Intrinsic.Create("");
- f.code = (context, partialResult) => {
- return new Intrinsic.Result(new ValNumber(SDate.Now().SeasonIndex));
- };
- worldModule["season"] = f.GetFunc();
+ // The numeric representation for the current in-game season (0 = spring).
+ worldInfo["season"] = new ValNumber(SDate.Now().SeasonIndex);
// The human-readable representation for the current in-game season.
- f = Intrinsic.Create("");
- f.code = (context, partialResult) => {
- return new Intrinsic.Result(new ValString(SDate.Now().Season));
+ worldInfo["seasonName"] = new ValString(SDate.Now().Season);
+
+ // The current weather
+ {
+ var loc = (Farm)Game1.getLocationFromName("Farm");
+ var weather = Game1.netWorldState.Value.GetWeatherForLocation(loc.GetLocationContext());
+ string result = "Sunny";
+ if (weather.isLightning) result = "stormy";
+ else if (weather.isRaining) result = "raining";
+ else if (weather.isSnowing) result = "snowing";
+ else if (weather.isDebrisWeather) result = "windy";
+ worldInfo["weather"] = new ValString(result);
};
- worldModule["seasonName"] = f.GetFunc();
- return worldModule;
+ // Daily luck
+ worldInfo["luck"] = new ValNumber(Game1.player.DailyLuck);
+
+ return worldInfo;
}
///
diff --git a/M1/assets/sysdisk/help/topics.txt b/M1/assets/sysdisk/help/topics.txt
index 4f802fa..d1d1c16 100644
--- a/M1/assets/sysdisk/help/topics.txt
+++ b/M1/assets/sysdisk/help/topics.txt
@@ -1,7 +1,8 @@
Available topics:
files coding demos
text input community
- farm bot toDo
+ farm bot world
+ toDo
(Access these with, for example:
`help "demos"` -- remember to use
diff --git a/M1/assets/sysdisk/help/world.txt b/M1/assets/sysdisk/help/world.txt
new file mode 100644
index 0000000..9b23e41
--- /dev/null
+++ b/M1/assets/sysdisk/help/world.txt
@@ -0,0 +1,5 @@
+The `world` global provides a information
+about the world. This includes current
+date, time, and weather. Try:
+
+ `pprint world`
diff --git a/M1/assets/sysdisk/lib/editor.ms b/M1/assets/sysdisk/lib/editor.ms
index ee579d0..ecfe306 100644
--- a/M1/assets/sysdisk/lib/editor.ms
+++ b/M1/assets/sysdisk/lib/editor.ms
@@ -21,6 +21,9 @@ pal.cursor = "#CCCCFF"
pal.topBar = "#AAAAAA"
pal.topBarText = "#8888CC"
+cutLines = []
+linesCutFromLineNum = null
+
lineLen = function(lineNum)
if lineNum < data.len then return data[lineNum].len
return 0
@@ -33,7 +36,7 @@ drawTopBar = function()
print " " + _sourceFile
lstr = str(cursorY + 1)
print " " * (screenW - 13 - lstr.len - text.column)
- print "^Q: Quit L" + lstr
+ print "^H: Help L" + lstr
print " " * (screenW - text.column)
end function
@@ -172,6 +175,66 @@ nextWord = function(dir)
outer.cursorX = x
end function
+cutLine = function
+ if cursorY != linesCutFromLineNum then
+ outer.cutLines = []
+ outer.linesCutFromLineNum = cursorY
+ end if
+ if cursorY >= data.len then return "End of File"
+ cutLines.push data[cursorY]
+ data.remove cursorY
+ refreshDisplay
+ if cutLines.len == 1 then return "Cut (1 Line)"
+ return "Cut (" + cutLines.len + " Lines)"
+end function
+
+pasteLines = function
+ for line in cutLines
+ data.insert cursorY, line
+ outer.cursorY = cursorY + 1
+ end for
+ scrollCursorIntoView
+ refreshDisplay
+ if cutLines.len == 1 then return "Paste (1 Line)"
+ return "Paste (" + cutLines.len + " Lines)"
+end function
+
+showHelp = function
+ text.color = pal.text; text.backColor = "#4F1CDBFF"
+ text.clear; text.delimiter = char(13)
+ text.row = 19; text.column = 0
+ text.inverse = true
+ print " "*8 + "Farmtronics Text Editor" + " "*9
+ text.inverse = false
+ print "Hold the Control key and press a letter"
+ print "to perform one of the functions below."
+ print "Example: "
+ print " ^Q means hold Contol and press Q."
+ print
+ funcs = [
+ "^A: Go to start of line",
+ "^E: Go to end of line",
+ "^U: Page up",
+ "^D: Page down",
+ "^K: Cut line(s)",
+ "^V: Paste line(s)",
+ "^H: View this help",
+ "^Q: Quit"]
+ text.delimiter = ""
+ for func in funcs
+ parts = func.split(":")
+ text.column = 3; text.inverse = true
+ print parts[0] + " "
+ text.inverse = false
+ print parts[1] + char(13)
+ end for
+ text.row = 0
+ print "(Press any key to continue.)"
+ key.get
+ text.backColor = color.clear
+ refreshDisplay
+end function
+
showCommand = function(keyPress, desc)
refreshRow 0
s = keyPress
@@ -197,18 +260,27 @@ handleControlKey = function(k)
if kcode > 31 then keyPress = "^" + char(kcode)
if anyShift then keyPress = "Shift-" + keyPress
+ // Want to customize your key bindings? Change
+ // the code below, and the help in showHelp above.
if keyPress == "^A" then // ctrl-A (start of line)
desc = "LineStart"
outer.cursorX = 0
else if keyPress == "^E" then // ctrl-E (end of line)
desc = "LineEnd"
outer.cursorX = lineLen(cursorY)
+ else if keyPress == "^H" then // help
+ showHelp
+ desc = "Help"
else if keyPress == "^U" then // Page Up
desc = "PageUp"
outer.cursorY = outer.cursorY - screenLines
else if keyPress == "^D" then // Page Down
desc = "PageDown"
- outer.cursorY = outer.cursorY + screenLines
+ outer.cursorY = outer.cursorY + screenLines
+ else if keyPress == "^K" then // Cut line
+ desc = cutLine
+ else if keyPress == "^V" then // Paste lines
+ desc = pasteLines
else if keyPress == "^Q" then // Escape or Ctrl+X
desc = "Quit"
outer.quitting = true