-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConsole.cs
34 lines (28 loc) · 1.07 KB
/
Console.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using Qrakhen.Sqript;
namespace Qrakhen.SqriptLib
{
public class ConsoleInterface : Interface
{
public ConsoleInterface() : base("console") {
}
public Value write(Dictionary<string, Value> parameters) {
Console.Write(parameters["value"].getValue());
return null;
}
public Value read(Dictionary<string, Value> parameters) {
var key = Console.ReadKey();
return new Value((int) key.KeyChar, Sqript.ValueType.INTEGER);
}
public Value readLine(Dictionary<string, Value> parameters) {
var line = Console.ReadLine();
return new Value(line, Sqript.ValueType.STRING);
}
public override void load() {
define(new Call("write", new string[] { "value" }, write, Sqript.ValueType.NULL));
define(new Call("read", new string[] { }, read, Sqript.ValueType.INTEGER));
define(new Call("readLine", new string[] { }, readLine, Sqript.ValueType.STRING));
}
}
}