11using CommandSystem;
22using JetBrains.Annotations;
33using RemoteAdmin;
4+ using SER.Helpers;
45using SER.Helpers.Exceptions;
56using SER.Helpers.Extensions;
67using SER.Helpers.ResultSystem;
78using SER.ScriptSystem;
89using SER.ScriptSystem.Structures;
910using SER.TokenSystem;
11+ using SER.TokenSystem.Tokens.Interfaces;
1012using SER.ValueSystem;
13+ using SER.VariableSystem.Bases;
1114using SER.VariableSystem.Variables;
1215using Console = GameCore.Console;
1316
@@ -177,7 +180,8 @@ public static Result RunAttachedScript(CustomCommand requestingCommand, ScriptEx
177180 return "The script that was supposed to handle this command was not found.";
178181 }
179182
180- if (Tokenizer.SliceLine(args.JoinStrings(" ")).HasErrored(out var sliceError, out var outSlices))
183+ if (Tokenizer.SliceLine(args.JoinStrings(" "))
184+ .HasErrored(out var sliceError, out var outSlices))
181185 {
182186 return sliceError;
183187 }
@@ -203,11 +207,21 @@ public static Result RunAttachedScript(CustomCommand requestingCommand, ScriptEx
203207
204208 for (var index = 0; index < requestingCommand.Usage.Length; index++)
205209 {
210+ var slice = slices[index];
206211 var argVariable = requestingCommand.Usage[index];
207212 var name = argVariable[0].ToString().ToLower() + argVariable.Substring(1);
213+
214+ if (Tokenizer.GetTokenFromSlice(slice, null!, 0)
215+ .WasSuccessful(out var token))
216+ {
217+ if (token.TryGetLiteralValue<LiteralValue>().WasSuccessful(out var value))
218+ {
219+ script.AddVariable(Variable.CreateVariable(name, value));
220+ continue;
221+ }
222+ }
208223
209- // todo: need to parse values from string too (probably using tokenizer)
210- script.AddVariable(new LiteralVariable<TextValue>(name, slices[index].Value));
224+ script.AddVariable(new LiteralVariable<TextValue>(name, slice.Value));
211225 }
212226
213227 script.Run();
0 commit comments