mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
AWA
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<Platform>cosmos</Platform>
|
<Platform>cosmos</Platform>
|
||||||
<SupportsX86Intrinsics>false</SupportsX86Intrinsics>
|
<SupportsX86Intrinsics>false</SupportsX86Intrinsics>
|
||||||
<SelfContained>True</SelfContained>
|
<SelfContained>True</SelfContained>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||||
<Configurations>Debug;Release;Fixed_Release</Configurations>
|
<Configurations>Debug;Release;Fixed_Release</Configurations>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
350db31
|
22c896e
|
||||||
@@ -63,8 +63,8 @@ namespace CMLeonOS
|
|||||||
// {
|
// {
|
||||||
// 我不认,我试着转换成Base64
|
// 我不认,我试着转换成Base64
|
||||||
// 我认了
|
// 我认了
|
||||||
PCScreenFont defaultFont = PCScreenFont.Default;
|
// PCScreenFont defaultFont = PCScreenFont.Default;
|
||||||
VGAScreen.SetFont(defaultFont.CreateVGAFont(), defaultFont.Height);
|
// VGAScreen.SetFont(defaultFont.CreateVGAFont(), defaultFont.Height);
|
||||||
// Console.WriteLine($"{defaultFont.Height}");
|
// Console.WriteLine($"{defaultFont.Height}");
|
||||||
// Console.WriteLine($"{defaultFont.Width}");
|
// Console.WriteLine($"{defaultFont.Width}");
|
||||||
// VGAScreen.SetGraphicsMode(VGADriver.ScreenSize.Size720x480, ColorDepth.ColorDepth32);
|
// VGAScreen.SetGraphicsMode(VGADriver.ScreenSize.Size720x480, ColorDepth.ColorDepth32);
|
||||||
|
|||||||
@@ -9,5 +9,8 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
[ManifestResourceStream(ResourceName = "CMLeonOS.LuaApps.testspeed.lua")]
|
[ManifestResourceStream(ResourceName = "CMLeonOS.LuaApps.testspeed.lua")]
|
||||||
public static readonly byte[] testspeed;
|
public static readonly byte[] testspeed;
|
||||||
|
|
||||||
|
[ManifestResourceStream(ResourceName = "CMLeonOS.LuaApps.calculator.lua")]
|
||||||
|
public static readonly byte[] calculator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
98
LuaApps/calculator.lua
Normal file
98
LuaApps/calculator.lua
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
print("====================================")
|
||||||
|
print(" Lua Calculator")
|
||||||
|
print("====================================")
|
||||||
|
print("Type 'exit' or 'quit' to exit")
|
||||||
|
print("Type 'clear' to clear the result")
|
||||||
|
print()
|
||||||
|
|
||||||
|
local result = nil
|
||||||
|
local operator = nil
|
||||||
|
local lastResult = nil
|
||||||
|
|
||||||
|
while true do
|
||||||
|
io.write("calc> ")
|
||||||
|
local input = io.read()
|
||||||
|
|
||||||
|
if input == nil or input == "" then
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
|
||||||
|
input = input:lower()
|
||||||
|
|
||||||
|
if input == "exit" or input == "quit" then
|
||||||
|
print("Exiting calculator...")
|
||||||
|
break
|
||||||
|
elseif input == "clear" then
|
||||||
|
result = nil
|
||||||
|
operator = nil
|
||||||
|
lastResult = nil
|
||||||
|
print("Calculator cleared.")
|
||||||
|
goto continue
|
||||||
|
elseif input == "help" then
|
||||||
|
print("Available commands:")
|
||||||
|
print(" + : Addition")
|
||||||
|
print(" - : Subtraction")
|
||||||
|
print(" * : Multiplication")
|
||||||
|
print(" / : Division")
|
||||||
|
print(" ^ : Power")
|
||||||
|
print(" % : Modulo")
|
||||||
|
print(" clear : Clear calculator")
|
||||||
|
print(" exit : Exit calculator")
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
|
||||||
|
local num = tonumber(input)
|
||||||
|
|
||||||
|
if num ~= nil then
|
||||||
|
if operator == nil then
|
||||||
|
result = num
|
||||||
|
lastResult = num
|
||||||
|
print("Result: " .. result)
|
||||||
|
else
|
||||||
|
local calcResult = nil
|
||||||
|
if operator == "+" then
|
||||||
|
calcResult = result + num
|
||||||
|
elseif operator == "-" then
|
||||||
|
calcResult = result - num
|
||||||
|
elseif operator == "*" then
|
||||||
|
calcResult = result * num
|
||||||
|
elseif operator == "/" then
|
||||||
|
if num == 0 then
|
||||||
|
print("Error: Division by zero!")
|
||||||
|
else
|
||||||
|
calcResult = result / num
|
||||||
|
end
|
||||||
|
elseif operator == "^" then
|
||||||
|
calcResult = result ^ num
|
||||||
|
elseif operator == "%" then
|
||||||
|
if num == 0 then
|
||||||
|
print("Error: Modulo by zero!")
|
||||||
|
else
|
||||||
|
calcResult = result % num
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if calcResult ~= nil then
|
||||||
|
result = calcResult
|
||||||
|
lastResult = calcResult
|
||||||
|
print("Result: " .. result)
|
||||||
|
end
|
||||||
|
|
||||||
|
operator = nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if input == "+" or input == "-" or input == "*" or input == "/" or input == "^" or input == "%" then
|
||||||
|
operator = input
|
||||||
|
print("Operator: " .. operator)
|
||||||
|
else
|
||||||
|
print("Invalid input: " .. input)
|
||||||
|
print("Type 'help' for available commands")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
::continue::
|
||||||
|
end
|
||||||
|
|
||||||
|
print()
|
||||||
|
print("Final result: " .. (lastResult or "No calculation"))
|
||||||
|
print("Goodbye!")
|
||||||
@@ -29,6 +29,11 @@ namespace CMLeonOS.Commands.Utility
|
|||||||
{
|
{
|
||||||
embeddedApps["testspeed.lua"] = LuaApps.testspeed;
|
embeddedApps["testspeed.lua"] = LuaApps.testspeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LuaApps.calculator != null && LuaApps.calculator.Length > 0)
|
||||||
|
{
|
||||||
|
embeddedApps["calculator.lua"] = LuaApps.calculator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user