1.4.2 (Internal Activation)

This commit is contained in:
Ryan 2017-09-20 11:24:53 -04:00
parent 31f09c0e47
commit 5f023fdfd3
6 changed files with 138 additions and 41 deletions

View File

@ -18,7 +18,7 @@ namespace parseManagerCS
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
//args=new string[]{"choiceTest.txt"}; args=new string[]{"choiceTest.txt"};
string file; string file;
string print = ""; string print = "";
List<char> temp = new List<char>(); List<char> temp = new List<char>();

View File

@ -1,4 +1,4 @@
VERSION 1.3.2 VERSION 1.4.1
THREAD testthread.txt THREAD testthread.txt
[PLAYGAME]{ [PLAYGAME]{
print("Welcome to my game!") print("Welcome to my game!")
@ -37,12 +37,11 @@ THREAD testthread.txt
"So your name is $name$, thats cool!" "So your name is $name$, thats cool!"
pos=1 pos=1
sleep(200) sleep(200)
SAVE("savedata.dat")
::loop:: ::loop::
clear()
SAVE("savedata.dat") SAVE("savedata.dat")
writeAt("",0,0)
setFG(Color_Blue) setFG(Color_Blue)
fancy(" What to do $name$? Time plsyed $hours_played$:$mins_played$:$secs_played$,/l, Play Game, View Stats, View Credits, Quit Game") fancy(" What to do $name$? Time played $hours_played:00$:$mins_played:00$:$secs_played:00$,/l, Play Game, View Stats, View Credits, Quit Game")
keyUP=isDown("{UP}") keyUP=isDown("{UP}")
keyDOWN=isDown("{DOWN}") keyDOWN=isDown("{DOWN}")
keyENTER=isDown("{ENTER}") keyENTER=isDown("{ENTER}")
@ -50,7 +49,7 @@ THREAD testthread.txt
if keyDOWN==true then setVarPlay("pos",pos+1)|SKIP(0) if keyDOWN==true then setVarPlay("pos",pos+1)|SKIP(0)
if keyENTER==true then GOTO("choicemade")|SKIP(0) if keyENTER==true then GOTO("choicemade")|SKIP(0)
writeAt("->",1,pos+2) writeAt("->",1,pos+2)
sleep(75) sleep(25)
GOTO("loop") GOTO("loop")
::choicemade:: ::choicemade::
playSong(snd_select) playSong(snd_select)
@ -69,8 +68,8 @@ THREAD testthread.txt
if keyENTER==true then SKIP(0)|GOTO("loop") if keyENTER==true then SKIP(0)|GOTO("loop")
print(" ") print(" ")
} }
[testFunc:function(a)]{ [testfunc:function(testing)]{
"Invoke Test: $a$!" ""
} }
[setVarPlay:function(var,val)]{ [setVarPlay:function(var,val)]{
setVar(var,val) setVar(var,val)
@ -79,9 +78,9 @@ THREAD testthread.txt
beep() beep()
GOTO("end") GOTO("end")
::toolittle:: ::toolittle::
setVar("pos",1) setVar("pos",4)
GOTO("end") GOTO("end")
::toomuch:: ::toomuch::
setVar("pos",4) setVar("pos",1)
::end:: ::end::
} }

View File

@ -1,4 +1,4 @@
VERSION 1.0 VERSION 1.4
LOAD game/play.dat LOAD game/play.dat
[COUNTER]{ [COUNTER]{
::loop:: ::loop::

Binary file not shown.

View File

@ -8,3 +8,13 @@ C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debu
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.xml C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.xml
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\OpenTK.dll C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\OpenTK.dll
C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\OpenTK.xml C:\Users\Ryan\Documents\SharpDevelop Projects\parseManager\parseManager\bin\Debug\OpenTK.xml
D:\SharpDevelop Projects\parseManager\parseManager\bin\Debug\parseManagerTester.exe.config
D:\SharpDevelop Projects\parseManager\parseManager\bin\Debug\parseManagerTester.exe
D:\SharpDevelop Projects\parseManager\parseManager\bin\Debug\parseManagerTester.pdb
D:\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.dll
D:\SharpDevelop Projects\parseManager\parseManager\bin\Debug\OpenTK.dll
D:\SharpDevelop Projects\parseManager\parseManager\bin\Debug\NAudio.xml
D:\SharpDevelop Projects\parseManager\parseManager\bin\Debug\OpenTK.xml
D:\SharpDevelop Projects\parseManager\parseManager\obj\Debug\parseManagerTester.csprojResolveAssemblyReference.cache
D:\SharpDevelop Projects\parseManager\parseManager\obj\Debug\parseManagerTester.exe
D:\SharpDevelop Projects\parseManager\parseManager\obj\Debug\parseManagerTester.pdb

View File

@ -24,7 +24,7 @@ namespace parseManagerCS
/// This also has very flexible flow control meaning you can use it for chat logic and such /// This also has very flexible flow control meaning you can use it for chat logic and such
public class parseManager public class parseManager
{ {
public string _VERSION = "1.4.0"; public string _VERSION = "1.4.2";
standardDefine _invoke = new standardDefine(); standardDefine _invoke = new standardDefine();
string _filepath; string _filepath;
bool _active = true; bool _active = true;
@ -32,6 +32,7 @@ namespace parseManagerCS
string _define = "NO_DEFINE"; string _define = "NO_DEFINE";
string _entry = "START"; string _entry = "START";
bool _isInternal; bool _isInternal;
parseManager systemThread;
Type _defineType; Type _defineType;
bool isThread; bool isThread;
standardDefine def = new standardDefine(); standardDefine def = new standardDefine();
@ -66,6 +67,12 @@ namespace parseManagerCS
_mainENV["Color_White"] = ConsoleColor.White; _mainENV["Color_White"] = ConsoleColor.White;
_mainENV["Color_Yellow"] = ConsoleColor.Yellow; _mainENV["Color_Yellow"] = ConsoleColor.Yellow;
_mainENV["VERSION"] = _VERSION; _mainENV["VERSION"] = _VERSION;
Parse(
@"[SYSTEM_THREADED_BLOCK]{
::loop::
sleep(1)
GOTO(""loop"")
}", true);
} }
public void _SetDENV(ENV env) public void _SetDENV(ENV env)
{ {
@ -135,6 +142,11 @@ namespace parseManagerCS
INITENV(); INITENV();
Parse(code, c); Parse(code, c);
} }
public void InitSystemThread()
{
var thread = new Thread(() => def._THREAD("SYSTEM_THREADED_BLOCK", this, systemThread));
thread.Start();
}
public bool IsInternal() public bool IsInternal()
{ {
return _isInternal; return _isInternal;
@ -319,10 +331,14 @@ namespace parseManagerCS
{ {
chunk c; chunk c;
if (isRegisteredFunction(method, out c)) { if (isRegisteredFunction(method, out c)) {
return InvokeI(method, args, c, true); return systemThread.InvokeI(method, args, c, true);
} }
PushError("Attempt to invoke a non existing method!"); try {
return systemThread.InvokeR(method, args);
} catch {
PushError("Attempt to invoke a non existing method!");
return null; return null;
}
} }
public object InvokeR(string method, object[] args) public object InvokeR(string method, object[] args)
{ {
@ -338,7 +354,9 @@ namespace parseManagerCS
if (tests.Contains("Null")) { if (tests.Contains("Null")) {
PushError("Invalid method: " + method + " (Method does not exist! Check your spelling!)"); PushError("Invalid method: " + method + " (Method does not exist! Check your spelling!)");
} else if (tests.Contains("ArgumentException")) { } else if (tests.Contains("ArgumentException")) {
PushError("Invalid method: " + method + " (Check your arguments! Ensure the types are correct!)"); PushError("Invalid method: " + method + " (Check your number of arguments!)");
} else if (tests.Contains("mismatch")) {
PushError("Invalid method: " + method + " (Ensure the types are correct!)");
} }
PushError("Invalid method: " + method + " (Unknown Error! It just doesn't work!)\n\n" + e); PushError("Invalid method: " + method + " (Unknown Error! It just doesn't work!)\n\n" + e);
return null; return null;
@ -589,6 +607,7 @@ namespace parseManagerCS
} }
public string parseHeader(string header) public string parseHeader(string header)
{ {
header = header.Replace(@"\$", "````");
var results = Regex.Matches(header, @"\$([\S\*]+?)\$"); var results = Regex.Matches(header, @"\$([\S\*]+?)\$");
int len = results.Count; int len = results.Count;
string str; string str;
@ -597,10 +616,13 @@ namespace parseManagerCS
int testnum; int testnum;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
str = results[i].Groups[1].Value; str = results[i].Groups[1].Value;
if (str.Contains("*")) { if (str.Contains("*") || str.Contains(":")) {
var test = Regex.Match(str, @"(.+?)\*(.+)"); var test = Regex.Match(str, @"(.+?)\*(.+)");
var test2 = Regex.Match(str, @"(.+):(.+)");
var spart = test.Groups[1].Value; var spart = test.Groups[1].Value;
var ipart = test.Groups[2].Value; var ipart = test.Groups[2].Value;
var vpart = test2.Groups[1].Value;
var fpart = test2.Groups[2].Value;
if (!isVar(spart, out temp)) { if (!isVar(spart, out temp)) {
} }
@ -610,8 +632,11 @@ namespace parseManagerCS
} else if (isVar(ipart, out temp2)) { } else if (isVar(ipart, out temp2)) {
str = def.repeat(this, temp.ToString(), (double)temp2); str = def.repeat(this, temp.ToString(), (double)temp2);
header = header.Replace(results[i].ToString(), str); header = header.Replace(results[i].ToString(), str);
} else if (isVar(vpart, out temp2) && fpart != "") {
str = def.tostring(this, (double)temp2, fpart);
header = header.Replace(results[i].ToString(), str);
} else { } else {
PushError("When using the $varname*num$ expression num must be a number or a variable that is set to a number!"); PushError("When using the $varname*num$ expression num must be a number or a variable that is set to a number! (" + header + ")");
} }
} }
if (isVar(str, out temp)) { if (isVar(str, out temp)) {
@ -620,6 +645,7 @@ namespace parseManagerCS
header = header.Replace(results[i].ToString(), "null"); header = header.Replace(results[i].ToString(), "null");
} }
} }
header = header.Replace("````", "$");
return header; return header;
} }
public object[] ResolveVar(string[] v) public object[] ResolveVar(string[] v)
@ -1073,7 +1099,7 @@ namespace parseManagerCS
{ {
_Parent = other; _Parent = other;
} }
public object[] GetList() public object[] ToArray()
{ {
var temp = new object[_varsI.Count]; var temp = new object[_varsI.Count];
var count = 0; var count = 0;
@ -1135,15 +1161,15 @@ namespace parseManagerCS
return null; return null;
} }
set { set {
while(_busyS){ while (_busyS) {
// wait // wait
} }
_busyS=true; _busyS = true;
if (!_sen) { if (!_sen) {
ind = ind.ToLower(); ind = ind.ToLower();
} }
_vars[ind] = value; _vars[ind] = value;
_busyS=false; _busyS = false;
} }
} }
public object this[int ind] { public object this[int ind] {
@ -1158,12 +1184,12 @@ namespace parseManagerCS
return null; return null;
} }
set { set {
while(_busyI){ while (_busyI) {
// wait // wait
} }
_busyI=true; _busyI = true;
_varsI[ind] = value; _varsI[ind] = value;
_busyI=false; _busyI = false;
} }
} }
} }
@ -1279,6 +1305,7 @@ namespace parseManagerCS
} }
public static void SetMainPM(parseManager o) public static void SetMainPM(parseManager o)
{ {
o.InitSystemThread();
_main = o; _main = o;
} }
public static parseManager GetMainPM() public static parseManager GetMainPM()
@ -1389,6 +1416,34 @@ public class standardDefine
next = PM.Next(); next = PM.Next();
} }
} }
public void _THREAD(string block, parseManager _PM, parseManager PM)
{
var define = _PM.GetDefine();
var path = _PM.GetFilepath();
if (_PM.IsInternal()) {
if (define == "NO_DEFINE") {
PM = new parseManager(path, true);
} else {
PM = new parseManager(path, define, true);
}
} else {
if (define == "NO_DEFINE") {
PM = new parseManager(path);
} else {
PM = new parseManager(path, define);
}
}
GLOBALS.AddThread(PM);
PM.makeThread();
PM._SetDENV(_PM.GetDENV());
PM.SetENV(_PM.GetENV());
nextType next = PM.Next(block);
string type;
while (next.GetCMDType() != "EOF") {
type = next.GetCMDType();
next = PM.Next();
}
}
public void _newThread(parseManager PM, string filename) public void _newThread(parseManager PM, string filename)
{ {
var thread = new Thread(() => _THREAD(PM, filename)); var thread = new Thread(() => _THREAD(PM, filename));
@ -1448,6 +1503,10 @@ public class standardDefine
c.SetPos((int)env[1]); c.SetPos((int)env[1]);
setENV(PM, (ENV)env[3]); setENV(PM, (ENV)env[3]);
} }
public string tostring(parseManager PM, double obj, string pad)
{
return obj.ToString(pad);
}
public void EXIT(parseManager PM) public void EXIT(parseManager PM)
{ {
cleanUpAudio(); cleanUpAudio();
@ -1533,7 +1592,7 @@ public class standardDefine
return (double)((string)o).Length; return (double)((string)o).Length;
} }
if (type.Contains("ENV")) { if (type.Contains("ENV")) {
return (double)((ENV)o).GetList().Length; return (double)((ENV)o).ToArray().Length;
} }
return 0; return 0;
} }
@ -1615,7 +1674,8 @@ public class standardDefine
{ {
return rnd.NextDouble(); return rnd.NextDouble();
} }
public void randomseed(parseManager PM,double seed){ public void randomseed(parseManager PM, double seed)
{
rnd = new Random((int)seed); rnd = new Random((int)seed);
} }
public double round(parseManager PM, double num, double n) public double round(parseManager PM, double num, double n)
@ -1775,20 +1835,6 @@ public class standardDefine
kk = Key.Y; kk = Key.Y;
} else if (k == "Z") { } else if (k == "Z") {
kk = Key.Z; kk = Key.Z;
} else if (k == "{UP}") {
kk = Key.Up;
} else if (k == "{DOWN}") {
kk = Key.Down;
} else if (k == "{LEFT}") {
kk = Key.Left;
} else if (k == "{RIGHT}") {
kk = Key.Right;
} else if (k == "{ENTER}") {
kk = Key.Enter;
} else if (k == "{LSHIFT}") {
kk = Key.LeftShift;
} else if (k == "{RSHIFT}") {
kk = Key.RightShift;
} else if (k == "0") { } else if (k == "0") {
kk = Key.D0; kk = Key.D0;
} else if (k == "1") { } else if (k == "1") {
@ -1809,11 +1855,53 @@ public class standardDefine
kk = Key.D8; kk = Key.D8;
} else if (k == "9") { } else if (k == "9") {
kk = Key.D9; kk = Key.D9;
} else if (k == "{UP}") {
kk = Key.Up;
} else if (k == "{DOWN}") {
kk = Key.Down;
} else if (k == "{LEFT}") {
kk = Key.Left;
} else if (k == "{RIGHT}") {
kk = Key.Right;
} else if (k == "{ENTER}") {
kk = Key.Enter;
} else if (k == "{LSHIFT}") {
kk = Key.LeftShift;
} else if (k == "{RSHIFT}") {
kk = Key.RightShift;
} else if (k == "{SPACE}") { } else if (k == "{SPACE}") {
kk = Key.Space; kk = Key.Space;
} else if (k == "{F1}") {
kk = Key.F1;
} else if (k == "{F2}") {
kk = Key.F2;
} else if (k == "{F3}") {
kk = Key.F3;
} else if (k == "{F4}") {
kk = Key.F4;
} else if (k == "{F5}") {
kk = Key.F5;
} else if (k == "{F6}") {
kk = Key.F6;
} else if (k == "{F7}") {
kk = Key.F7;
} else if (k == "{F8}") {
kk = Key.F8;
} else if (k == "{F9}") {
kk = Key.F9;
} else if (k == "{F10}") {
kk = Key.F10;
} else if (k == "{F11}") {
kk = Key.F11;
} else if (k == "{F12}") {
kk = Key.F12;
} }
return Keyboard.IsKeyDown(kk); return Keyboard.IsKeyDown(kk);
} }
public void setCursorVisibility(parseManager PM, bool v)
{
Console.CursorVisible = v;
}
public void error(parseManager PM, string msg) public void error(parseManager PM, string msg)
{ {
PM.PushError(msg); PM.PushError(msg);