diff --git a/Projects/SAMufasaGUI/project1.lpi b/Projects/SAMufasaGUI/project1.lpi
index 380c9a1..84f8c06 100644
--- a/Projects/SAMufasaGUI/project1.lpi
+++ b/Projects/SAMufasaGUI/project1.lpi
@@ -7,7 +7,7 @@
-
+
@@ -305,8 +305,8 @@
-
-
+
+
@@ -374,9 +374,11 @@
-
-
+
+
+
+
@@ -407,9 +409,11 @@
-
-
+
+
+
+
@@ -1178,7 +1182,7 @@
-
+
@@ -1492,8 +1496,8 @@
-
-
+
+
@@ -1665,7 +1669,7 @@
-
+
@@ -1690,6 +1694,14 @@
+
+
+
+
+
+
+
+
diff --git a/Tests/PS/Neopets_old.mufa b/Tests/PS/Neopets_old.mufa
new file mode 100644
index 0000000..4891a82
--- /dev/null
+++ b/Tests/PS/Neopets_old.mufa
@@ -0,0 +1,148 @@
+program BankProblems;
+
+// http://www.neopets.com/games/play.phtml?game_id=371
+
+Const
+ KeyDownUpSpeed = 1; // The Higher the "KeyDownUpSpeed", the slower the script is.
+
+Type
+ Door = record
+ X: Integer;
+ Y: Integer;
+ DoorChar: Byte;
+ IsOpen: Boolean;
+ IsMonster: Boolean;
+ WhatMonster: String;
+ End;
+
+Var
+ Doors: Array [0..5] Of Door;
+
+Procedure DeclareStuff;
+
+Var
+ I: Integer;
+Begin
+ For I := 0 To 5 Do
+ Begin
+ Doors[I].X := 45 + I * 96;
+ Doors[I].Y := 210;
+ End;
+
+ Doors[0].DoorChar := 83;
+ Doors[1].DoorChar := 68;
+ Doors[2].DoorChar := 70;
+ Doors[3].DoorChar := 74;
+ Doors[4].DoorChar := 75;
+ Doors[5].DoorChar := 76;
+End;
+
+Function IsBadGuy(DN: Integer): Boolean;
+
+Var
+ TempColor: Array [0..11] Of Integer;
+ I, x, y: Integer;
+ H, S, L: Extended;
+Begin
+ TempColor[0] := GetColor(Doors[DN].X, Doors[DN].Y);
+ TempColor[1] := GetColor(Doors[DN].X, Doors[DN].Y-1);
+ TempColor[2] := GetColor(Doors[DN].X-1, Doors[DN].Y);
+ TempColor[3] := GetColor(Doors[DN].X, Doors[DN].Y+1);
+ TempColor[4] := GetColor(Doors[DN].X+1, Doors[DN].Y);
+ TempColor[5] := GetColor(Doors[DN].X, Doors[DN].Y-2);
+ TempColor[5] := GetColor(Doors[DN].X-2, Doors[DN].Y);
+ TempColor[6] := GetColor(Doors[DN].X+1, Doors[DN].Y+2);
+ TempColor[7] := GetColor(Doors[DN].X+2, Doors[DN].Y);
+ TempColor[8] := GetColor(Doors[DN].X, Doors[DN].Y-3);
+ TempColor[9] := GetColor(Doors[DN].X-3, Doors[DN].Y);
+ TempColor[10] := GetColor(Doors[DN].X+1, Doors[DN].Y+3);
+ TempColor[11] := GetColor(Doors[DN].X+3, Doors[DN].Y);
+
+ For I := 0 To 11 Do
+ Begin
+ If SimilarColors(TempColor[I], 3055, 30) Then // Red Devil
+ Begin
+ Result := True;
+ Doors[DN].WhatMonster := 'Devil';
+ Exit;
+ End;
+ End;
+
+ For I := 0 To 11 Do
+ Begin
+ If SimilarColors(TempColor[I], 12841714, 40) Then // Squirrle
+ Begin
+ ColorToHSL(TempColor[I], H, S, L);
+ If (L > 60) And (L < 95) Then
+ If (H > 5 ) And (H < 30) Then
+ If FindColorTolerance(x, y, 4092580, Doors[DN].X, Doors[DN].Y-1,
+ Doors[DN].X + 20, Doors[DN].Y + 1, 40)
+ Then
+ Begin
+ Result := True;
+ Doors[DN].WhatMonster := 'Squirrle';
+ Exit;
+ End;
+ End;
+ End;
+
+ For I := 0 To 11 Do
+ Begin
+ If SimilarColors(TempColor[I], 28756, 30) Then // Green Monster
+ Begin
+ Result := True;
+ Doors[DN].WhatMonster := 'Green Monster';
+ Exit;
+ End;
+ End;
+
+ For I := 0 To 11 Do
+ Begin
+ If SimilarColors(TempColor[I], 794793, 30) Then // Mysterious Man
+ Begin
+ Result := True;
+ Doors[DN].WhatMonster := 'Mysterious Man';
+ Exit;
+ End;
+ End;
+
+End;
+
+Procedure HandleMonsters;
+
+Var
+ I, iX, iY, Time: Integer;
+
+Begin
+ For I := 0 To 5 Do
+ Begin
+ If IsBadGuy(I) Then
+ Begin
+ KeyDown(Doors[I].DoorChar);
+ Wait(10 * KeyDownUpSpeed);
+ KeyUp(Doors[I].DoorChar);
+ End;
+ End;
+End;
+
+Procedure AddToGold;
+
+Begin
+ If GetColor(388, 25) = 0 Then
+ Begin
+ Wait(100);
+ KeyDown(32);
+ Wait(10 * KeyDownUpSpeed);
+ KeyUp(32);
+ End;
+End;
+
+begin
+ //ClearDebug;
+ DeclareStuff;
+ Repeat
+ AddToGold;
+ HandleMonsters;
+ Wait(10);
+ Until False;
+end.
diff --git a/Units/MMLAddon/PSInc/pscompile.inc b/Units/MMLAddon/PSInc/pscompile.inc
index caae63d..d2a4120 100644
--- a/Units/MMLAddon/PSInc/pscompile.inc
+++ b/Units/MMLAddon/PSInc/pscompile.inc
@@ -93,6 +93,8 @@ Sender.AddFunction(@FindColorSpiral,'function FindColorSpiral(var x, y: Integer;
Sender.AddFunction(@FindColorsSpiralTolerance,'function FindColorsSpiralTolerance(x, y: Integer; var Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer) : boolean;');
Sender.AddFunction(@SetColorToleranceSpeed, 'procedure SetColorToleranceSpeed(cts: integer);');
+Sender.AddFunction(@ColorToHSL, 'procedure ColorToHSL(c: integer; var r,g,b: extended);');
+
{Mouse etc.}
Sender.AddFunction(@MoveMouse, 'procedure MoveMouse(x, y: integer);');
Sender.AddFunction(@GetMousePos, 'procedure GetMousePos(var x, y: integer);');
diff --git a/Units/MMLAddon/mmlpsthread.pas b/Units/MMLAddon/mmlpsthread.pas
index 0f35377..a049851 100644
--- a/Units/MMLAddon/mmlpsthread.pas
+++ b/Units/MMLAddon/mmlpsthread.pas
@@ -93,6 +93,7 @@ uses
Graphics, //For Graphics types
math, //Maths!
bitmaps,
+ colour_conv,
forms,//Forms
lclintf; // for GetTickCount and others.