diff --git a/src/components/filesystem.c b/src/components/filesystem.c index b41ac5c..cfc107f 100644 --- a/src/components/filesystem.c +++ b/src/components/filesystem.c @@ -127,6 +127,8 @@ void nn_fs_size(nn_filesystem *fs, void *_, nn_component *component, nn_computer } size_t byteSize = fs->size(component, fs->userdata, path); + + nn_return(computer, nn_values_integer(byteSize)); nn_fs_readCost(fs, 1, component, computer); } @@ -162,7 +164,14 @@ void nn_fs_lastModified(nn_filesystem *fs, void *_, nn_component *component, nn_ return; } - nn_return(computer, nn_values_integer(fs->lastModified(component, fs->userdata, path))); + size_t t = fs->lastModified(component, fs->userdata, path); + + // OpenOS does BULLSHIT with this thing, dividing it by 1000 and expecting it to be + // fucking usable as a date, meaning it needs to be an int. + // Because of that, we ensure it is divisible by 1000 + t -= t % 1000; + + nn_return(computer, nn_values_integer(t)); nn_fs_readCost(fs, 1, component, computer); } diff --git a/src/emulator.c b/src/emulator.c index 1265591..6cd2105 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -680,7 +680,11 @@ render: Color heatColor = GREEN; if(heat > 60) heatColor = YELLOW; if(heat > 80) heatColor = RED; - DrawText(TextFormat("Heat: %lf\n", heat), 10, GetScreenHeight() - 30, 20, heatColor); + + size_t memUsage = nn_getComputerMemoryUsed(computer); + size_t memTotal = nn_getComputerMemoryTotal(computer); + + DrawText(TextFormat("Heat: %.02lf Memory Used: %.2lf%%", heat, (double)memUsage / memTotal * 100), 10, GetScreenHeight() - 30, 20, heatColor); EndDrawing(); } diff --git a/src/sandbox.lua b/src/sandbox.lua index 952c34c..7733e83 100644 --- a/src/sandbox.lua +++ b/src/sandbox.lua @@ -8,9 +8,7 @@ local function copy(v, p) end if p then for key, val in pairs(p) do - if not rawget(t, key) then - t[key] = copy(val) - end + t[key] = copy(val) end end return t @@ -434,6 +432,8 @@ sandbox = { } sandbox._G = sandbox +print("oh gosh", sandbox.unicode.sub("abc", 1, 0)) + local function bootstrap() local eeprom = libcomponent.list("eeprom")() assert(eeprom, "no eeprom") diff --git a/src/testLuaArch.c b/src/testLuaArch.c index 125a8b4..8b7df6c 100644 --- a/src/testLuaArch.c +++ b/src/testLuaArch.c @@ -444,6 +444,10 @@ int testLuaArch_unicode_sub(lua_State *L) { return 1; } // Lua indexing bullshit + if(stop == 0) { + lua_pushstring(L, ""); + return 1; + } if(start > 0) { start -= 1; } else if(start < 0) {