Skip to content

Commit 5f2f738

Browse files
author
Blecki
committed
Nothing major
1 parent 5cc26be commit 5f2f738

File tree

7 files changed

+46
-6
lines changed

7 files changed

+46
-6
lines changed

DefaultDatabase/DefaultDatabase.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@
159159
<None Include="database\static\matchers.mud">
160160
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
161161
</None>
162-
<None Include="database\static\players\god\god.mud">
163-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
164-
</None>
165162
<None Include="database\static\room.mud">
166163
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
167164
</None>

DefaultDatabase/MudEngine2012.dll

512 Bytes
Binary file not shown.

DefaultDatabase/MudServer.exe

0 Bytes
Binary file not shown.

DefaultDatabase/database/static/players/god/god.mud

Lines changed: 0 additions & 3 deletions
This file was deleted.

MISP/StandardLibrary.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ private void SetupStandardLibrary()
6565
return arguments[0];
6666
}));
6767

68+
functions.Add("raise-error", new Function("raise-error",
69+
ArgumentInfo.ParseArguments(this, "string msg"),
70+
"",
71+
(context, arguments) =>
72+
{
73+
context.RaiseNewError(MISP.ScriptObject.AsString(arguments[0]), context.currentNode);
74+
return null;
75+
}));
76+
77+
functions.Add("catch-error", new Function("catch-error",
78+
ArgumentInfo.ParseArguments(this, "code good", "code bad"),
79+
"",
80+
(context, arguments) =>
81+
{
82+
var result = Evaluate(context, arguments[0], true, false);
83+
if (context.evaluationState == EvaluationState.UnwindingError)
84+
{
85+
context.evaluationState = EvaluationState.Normal;
86+
return Evaluate(context, arguments[1], true, false);
87+
}
88+
return result;
89+
}));
90+
6891

6992
SetupVariableFunctions();
7093
SetupObjectFunctions();

MudEngine2012/Database.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ public MISP.ScriptObject CreateObject(String path)
2626
return namedObjects[path];
2727
}
2828

29+
public MISP.ScriptObject CreateUniquelyNamedObject(String basePath)
30+
{
31+
while (true)
32+
{
33+
var randomPart = Guid.NewGuid();
34+
var path = basePath + "/" + randomPart.ToString();
35+
if (LoadObject(path) == null)
36+
{
37+
namedObjects.Upsert(path, new MISP.GenericScriptObject("@path", path));
38+
return namedObjects[path];
39+
}
40+
}
41+
}
42+
2943
public MISP.ScriptObject LoadObject(String path, bool timeOut = true)
3044
{
3145
if (namedObjects.ContainsKey(path)) return namedObjects[path];

MudEngine2012/MudCoreSetupScript.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ private void SetupScript()
6161
},
6262
"string name");
6363

64+
scriptEngine.AddFunction("create-uniquely-named", "base-path: Directory to create new object in.",
65+
(context, arguments) =>
66+
{
67+
var basePath = MISP.ScriptObject.AsString(arguments[0]);
68+
try { return database.CreateUniquelyNamedObject(basePath); }
69+
catch (Exception e) { return null; }
70+
},
71+
"string base-path");
72+
6473
scriptEngine.AddFunction("save", "name: Save a named object.",
6574
(context, arguments) =>
6675
{

0 commit comments

Comments
 (0)