· 8 years ago · May 04, 2018, 09:46 PM
1<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
2 <External>null</External>
3 <External>nil</External>
4 <Item class="ModuleScript" referent="RBX519F8599BEF44868B0830BCFC0C06B75">
5 <Properties>
6 <Content name="LinkedSource"><null></null></Content>
7 <string name="Name">Celery</string>
8 <string name="ScriptGuid">{122C8863-2E51-4687-BB14-053839FE36FC}</string>
9 <ProtectedString name="Source"><![CDATA[--[[
10 Hi; Rerumu here leaking my own admin.
11 Yes I am bored.
12 No I do not care.
13 Hoping you lovelies enjoy my work. Read along as to learn how some features such as the remote
14 api are implemented and how injects can be added.
15--]]
16
17local next = next;
18local wait = wait;
19local pcall = pcall;
20local script = script;
21local require = require;
22
23local Code = script('WaitForChild', 'Code')'Clone';
24local Deps = script('WaitForChild', 'Deps')'Clone';
25
26script'ClearAllChildren'; -- Doesn't matter but GC is a pain.
27
28setfenv(1, {}); -- Refer to previous comment.
29
30local Clear;
31local Insert = table.insert;
32local Ran, System = pcall(require, 626335321);
33
34if (not Ran) or System.Ran then return nil; end;
35
36local Load = {};
37
38for _, Name in next, {'System', 'Profile', 'Commands', 'Themes', 'Process'} do
39 Insert(Load, Code:WaitForChild(Name));
40end;
41
42Code = nil;
43
44Clear = System();
45Clear.Deps = Deps;
46
47function Clear.WaitFor(Idx)
48 local F = Clear[Idx];
49
50 while (not F) do
51 F = Clear[Idx];
52
53 wait(1 / 120);
54 end;
55
56 return F;
57end;
58
59System(Load); -- Start up the modules.
60
61return 70540486; -- Hey; that's me.]]></ProtectedString>
62 <BinaryString name="Tags"></BinaryString>
63 </Properties>
64 <Item class="Folder" referent="RBX619AF376B7264A5FB1BBDEC82852777B">
65 <Properties>
66 <string name="Name">Code</string>
67 <BinaryString name="Tags"></BinaryString>
68 </Properties>
69 <Item class="ModuleScript" referent="RBX4BD6654BC6064C039F936FE1CEE10011">
70 <Properties>
71 <Content name="LinkedSource"><null></null></Content>
72 <string name="Name">System</string>
73 <string name="ScriptGuid">{CCAF17DD-FF63-4627-AD78-6780ADEC0DF4}</string>
74 <ProtectedString name="Source"><![CDATA[return function() -- Api stuff handled here for the most part.
75 local Clear = Clear;
76 local System = {};
77 local Settings = {
78 Prefix = '?';
79 Batch = '/';
80 Console = 'BackSlash';
81 Reserves = {};
82 Message = 'No Message';
83 };
84
85 local Str = tostring;
86 local Abs = math.abs;
87 local Insert = table.insert;
88
89 local DStoreK = 'NotGivingYouRealKey';
90 local DStore = Clear.DataStoreService('GetDataStore', Clear.HashCrc32(DStoreK), 'Unversed');
91
92 local Remote = Clear.Remote;
93 local SettingK = Clear.HashMD5(DStoreK);
94 local ChangeE = Clear.Create'BindableEvent'{Name = 'SettingsChanged'};
95 -- NOTE: I have literally no need to steal your keys; I guess this is up to you but the script's main commands work without them regardless.
96 local Auth = { -- Api keys for Discord, pastebin and whatelse go here.
97 Mashape = 'x'; -- Mashape key for external services.
98 Pastebin = {
99 Dev = 'x'; -- Your developer api key.
100 Pass = 'x'; -- Pastebin api does ask for your password.
101 };
102 Discord = {
103 Token = 'x'; -- Your BOT TOKEN. Without "bot " before it.
104 Hook = 'x'; -- Your WEBHOOK ID.
105 HookT = 'x'; -- Your WEBHOOK TOKEN.
106 Channel = 'x'; -- The CHANNEL ID for the channel which you want to use for remote commands.
107 };
108 };
109
110 local Deps = Clear.Deps;
111 local G, Game = pcall(Clear.MarketplaceService.GetProductInfo, Clear.MarketplaceService, game.PlaceId);
112 local Variables = {};
113 local Objects = {};
114 local GuiHash = {};
115
116 local Permission;
117 local Discord;
118 local Inject;
119
120 System.Logs = {Chat = {}, Command = {}};
121 System.Objects = Objects;
122 System.SChanged = ChangeE.Event;
123
124 function System.GetVar(What)
125 return Variables[What];
126 end;
127
128 function System.SetVar(What, To)
129 Variables[What] = To;
130 end;
131
132 function System.WipeSettings() -- Never really implemented this.
133 return DStore('UpdateAsync', SettingK, function() return false; end);
134 end;
135
136 function System.GetSettings()
137 return System.Copy(Settings);
138 end;
139
140 function System.SetSetting(K, V)
141 if (typeof(Settings[K]) == typeof(V)) then
142 Settings[K] = V;
143 end;
144 end;
145
146 function System.UpdateSettings()
147 local Got = DStore('GetAsync', SettingK);
148 local Set = Settings;
149
150 if Got then
151 Settings = Clear.RDecode(Got);
152 end;
153
154 Settings = Set;
155 ChangeE:Fire(System.Copy(Settings));
156
157 return Set;
158 end;
159
160 function System.SaveSettings()
161 local Enc = Clear.REncode(Settings);
162
163 return DStore('UpdateAsync', SettingK, function(Old)
164 return Enc;
165 end);
166 end;
167
168 function System.FindClass(Object, Name, List)
169 for _, Child in next, Object:GetChildren() do
170 pcall(function()
171 if Child:IsA(Name) then
172 Insert(List, Child);
173 end;
174
175 if (#Child:GetChildren() ~= 0) then
176 System.FindClass(Child, Name, List);
177 end;
178 end);
179 end;
180
181 return List;
182 end;
183
184 function System.IsGui(Gui)
185 return GuiHash[Str(Gui)];
186 end;
187
188 function System.LoadGui(Pl, Gui, Data)
189 local Gui = System.Dep('2D', Gui);
190
191 if Gui then
192 local New = Gui:Clone();
193 local Name = GuiHash[Gui.Name];
194
195 if (not Name) then
196 Name = Clear.HashCrc32(Gui.Name);
197
198 GuiHash[Name] = Gui.Name;
199 GuiHash[Gui.Name] = Name;
200 end;
201
202 New.Name = Name;
203 New.Parent = Pl:FindFirstChildOfClass'PlayerGui';
204
205 Remote.Send(Pl, 'Load', New:FindFirstChild'Code', Data);
206
207 return New;
208 end;
209 end;
210
211 function System.HasGui(Pl, Name)
212 local Gui = Pl:FindFirstChildOfClass'PlayerGui';
213 local Name = GuiHash[Name];
214
215 if Gui and Name then
216 return Gui:FindFirstChild(Name);
217 else
218 return false;
219 end;
220 end;
221
222 function System.Recent(Num1, Num2)
223 local x1, y1, z1 = Num1:match('(%d-):(%d%d):(%d%d)');
224 local x2, y2, z2 = Num2:match('(%d-):(%d%d):(%d%d)');
225 local Result;
226
227 if (x1 == x2) and (y1 == y2) then
228 Result = (Abs(z1 - z2)) < 36;
229 end;
230
231 return Result;
232 end;
233
234 function System.Index(...)
235 local Objs = {...};
236
237 for K = 1, #Objs do
238 Insert(Objects, Objs[K]);
239 end;
240
241 return Objs;
242 end;
243
244 function System.Dep(S, ...)
245 local Data = {...};
246 local Last = Deps:FindFirstChild(S) or Deps:WaitForChild(S, math.huge);
247
248 for Idx = 1, #Data do
249 if (not Last) then break; end;
250 Last = Last:FindFirstChild(Data[Idx]);
251 end;
252
253 return Last;
254 end;
255
256 function System.Copy(T)
257 if (type(T) ~= 'table') then return T; end;
258 local Init = {};
259
260 for K, V in next, T do
261 if (type(V) == 'table') then
262 Init[K] = System.Copy(V);
263 else
264 Init[K] = V;
265 end;
266 end;
267
268 return Init;
269 end;
270
271 if (not G) then
272 warn('Game error get.\n', Game);
273
274 Game = {
275 Name = 'Fetch Request Error';
276 AssetId = game.PlaceId;
277 Creator = {Id = game.CreatorId, Name = 'Unknown'};
278 Description = 'There was an error when Celery attempted to fetch game data.';
279 };
280 end;
281
282 if Clear.HttpConnect() then
283 Discord = Clear.HttpRemote('Discord', { -- Connects your Discord api services.
284 Auth = Auth.Discord.Token;
285 HookId = Auth.Discord.Hook;
286 HookToken = Auth.Discord.HookT;
287 });
288
289 Inject = {}; -- NOTE: A table full of injects. (Can be locals, folders, models, whatever.)
290
291 if Inject[1] then
292 local Cased = {};
293
294 for _, Inj in next, Inject do
295 Cased[Inj.Name:lower()] = Inj;
296 end;
297
298 Inject = Cased;
299 end;
300-- elseif (Game.Creator.Id ~= 70540486) then -- Old stuff for preventing non-HTTP usage.
301-- local Kick = Clear.Kick;
302-- local Wait = wait;
303--
304-- repeat Kick('all', 'Fatal error~! =o^o='); Wait(1 / 120) until false;
305 end;
306
307 System.Cross = Clear.Create'BindableEvent'{Name = 'CeleryCross'}; -- Cross-server-script.
308 System.DStoreK = DStoreK;
309 System.DStore = DStore;
310 System.Injects = Inject;
311 System.Discord = Discord;
312 System.Auth = Auth;
313 System.Game = Game;
314
315 System.ServerKey = Clear.GetRandom(64);
316
317 Clear.Deps = nil;
318 Clear.System = System;
319
320 Clear.Thread(System.UpdateSettings);
321
322 pcall(game.BindToClose, game, System.SaveSettings);
323 pcall(DStore.OnUpdate, DStore, SettingK, function(New)
324 Clear.Thread(function()
325 Settings = Clear.RDecode(New);
326 ChangeE:Fire(System.Copy(Settings));
327 end);
328 end);
329
330 warn'Celery Open Source System loaded.';
331end;]]></ProtectedString>
332 <BinaryString name="Tags"></BinaryString>
333 </Properties>
334 </Item>
335 <Item class="ModuleScript" referent="RBX121F9824BAC84C949E26457FCFB37D80">
336 <Properties>
337 <Content name="LinkedSource"><null></null></Content>
338 <string name="Name">Profile</string>
339 <string name="ScriptGuid">{2F57C009-CE2A-4E8C-9C9E-B710AF278347}</string>
340 <ProtectedString name="Source"><![CDATA[script = nil;
341
342return function()
343 local Clear = Clear; -- Profiling system.
344 local System = Clear.WaitFor'System';
345 local Profiles = {};
346
347 local DStoreK = System.DStoreK;
348 local DStore = System.DStore;
349
350 local Tonu = tonumber;
351 local Shift = Clear.Shift;
352 local typeof = typeof;
353 local GetAsync = DStore.GetAsync;
354 local SetAsync = DStore.SetAsync;
355 local Highperms = {Registered = 1, User = 2, Scripter = 3, Enforcer = 4, Trusted = 7, Discord = 10, Unversed = 11};
356 local Cache = {};
357 local Discord = {};
358 local DiscIds = { -- Format: personName:discordId:userId
359 'You:1234:4567',
360 'YourFriend:4321:9876', -- Allows for use of remote stuff.
361 };
362 local Bans = {
363 {98663073, 'Oof.'}; -- TycoonKing1981
364 };
365 local Defaults = {
366 {
367 Clearance = {'Unversed', 'Trusted', 'Enforcer', 'User'};
368 UserId = 48013251;
369 Alias = 'Reru\'s';
370 };
371 {
372 Clearance = {'Unversed', 'Enforcer', 'User'};
373 UserId = 74283277;
374 };
375 {
376 Clearance = {'Unversed', 'Enforcer'};
377 UserId = 32873573;
378 };
379 {
380 Clearance = {'Unversed', 'Enforcer'};
381 UserId = 10517389;
382 };
383 {
384 Clearance = {'Scripter', 'Enforcer'};
385 UserId = 13282741;
386 };
387 {
388 Clearance = 'Unrestricted';
389 UserId = 27744504;
390 };
391 {
392 Clearance = 'Unrestricted';
393 UserId = 79048679;
394 };
395 {
396 Clearance = 'Unrestricted';
397 UserId = 70540486;
398 Alias = 'Reruuu';
399 Image = '707741687';
400 };
401 };
402
403 for Idx = 1, #Bans do
404 local Ban = Bans[Idx];
405
406 Defaults[#Defaults + 1] = {
407 Registered = true;
408 Banned = Ban[2];
409 UserId = Ban[1];
410 };
411 end;
412
413 for Idx = 1, #DiscIds do
414 local Id, UserId = DiscIds[Idx]:match'%w+:(%d+):(%d+)';
415
416 Discord[Id] = Tonu(UserId);
417 end;
418
419 DiscIds = nil;
420
421 System.DStoreK, System.DStore = nil, nil;
422 -- local function Shift(A, B) return (A * 2) % (2 ^ B) end;
423 local Names = {
424 {'This', 'Is', 'Very'};
425 {'Old', 'And', 'Should'};
426 {'Not', 'Be', 'Used'};
427 };
428
429 local function RandomizeName(UserId)
430 local Name = '';
431 local Prev = UserId % 256;
432 local Fin = 0;
433
434 for Idz = 1, 3 do
435 local Section = Names[Idz];
436 local Sect = #Section;
437
438 for Idx = 1, Shift(UserId, Sect + (Idz * 2)) do
439 Fin = Shift((Sect ^ 3) * Prev + ((Sect * Idx) + Idx * (Prev + Idz)) % ((128 - Sect) + Prev), (((Prev + Idx * Sect) % 256) + (Sect + Idz ^ 2)) % 32);
440 end;
441
442 Name = Name .. Section[(Fin % Sect) + 1];
443 Prev = Fin % 256;
444 Fin = 0;
445 end;
446
447 return Name;
448 end;
449
450 function Profiles.Update(PlayerList)
451 local Listed = {};
452 local Remove = {};
453
454 for Idx = 1, #PlayerList do
455 local Player = PlayerList[Idx];
456 local Prof = Profiles.Get(Player);
457
458 if Prof.Registered then
459 local Obj = {
460 Alias = Prof.Alias;
461 Bio = Prof.Bio;
462 Banned = Prof.Banned;
463 Name = Player.Name;
464 UserId = Player.UserId;
465 Image = Prof.Image;
466 Color = Prof.Color;
467 };
468
469 Listed[#Listed + 1] = Obj;
470 end;
471
472 Remove[#Remove + 1] = Prof.UserId;
473 end;
474
475 DStore('UpdateAsync', Clear.HashSha1'SomeDataStoreKey', function(Last)
476 local Last = Clear.JDecode(Last or '[]');
477 local New = {};
478
479 for Idx = 1, #Remove do
480 local Id = Remove[Idx];
481
482 for Idz, Val in next, Last do
483 if (Val.UserId == Id) then
484 Last[Idz] = nil;
485
486 break;
487 end;
488 end;
489 end;
490
491 for Idx = 1, #Listed do
492 Last[#Last + 1] = Listed[Idx];
493 end;
494
495 for _, Val in next, Last do
496 New[#New + 1] = Val;
497 end;
498
499 System.Database = New;
500
501 return Clear.JEncode(New);
502 end);
503 end;
504
505 function Profiles.Picture(Prof)
506 local Cache = Prof.Cache;
507 local Image = Cache.Image;
508
509 if (not Image) then
510 local R, Fetch = pcall(Clear.DoGet, 'http://rprxy.xyz/headshot-thumbnail/json?userId=' .. Prof.UserId .. '&width=180&height=180');
511
512 if R then
513 Image = Clear.JDecode(Fetch).Url;
514 else
515 warn('Fetch Error;', Fetch);
516 Image = 'https://cdn.discordapp.com/attachments/283069308613951488/310858222061748234/page-not-found-300x270.png';
517 end;
518
519 Cache.Image = Image;
520 end;
521
522 return Image;
523 end;
524
525 function Profiles.PermLevel(Pl)
526 local Data = Profiles.Get(Pl);
527 local Po = 0;
528
529 if (Data.Clearance == 'Unrestricted') then
530 return 9e9;
531 else
532 local Ca = Data.Cache;
533
534 for Idx, Val in next, Highperms do
535 if Ca[Idx] then
536 Po = Po + Val;
537 end;
538 end;
539
540 return Po;
541 end;
542 end;
543
544 function Profiles.IsHigher(A, B)
545 return Profiles.PermLevel(A) > Profiles.PermLevel(B);
546 end;
547
548 function Profiles.Permission(Who, List)
549 local Data = Profiles.Get(Who);
550 local Cach = Data.Cache;
551 local Got;
552
553 if (Data.Clearance == 'Unrestricted') or (List == 'Unindexed') or (#List == 0) then
554 return true;
555 elseif (type(List) == 'string') then
556 return Cach[List];
557 end;
558
559 for K = 1, #List do
560 Got = Cach[List[K]];
561
562 if Got then break; end;
563 end;
564
565 return Got;
566 end;
567
568 function Profiles.FromId(EnteredId, Passed)
569 local Id = Tonu(EnteredId);
570 local Conc = Clear.HashMD5(DStoreK .. Id);
571 local Prof = GetAsync(DStore, Conc);
572 local Init;
573
574 for Idx = 1, #Defaults do
575 local Dt = Defaults[Idx];
576
577 if (Dt.UserId == Id) then
578 Init = Dt;
579
580 break;
581 end;
582 end;
583
584 local Loaded;
585
586 if (type(Prof) == 'string') then
587 Loaded = Clear.RDecode(Prof);
588 else
589 Loaded = {};
590 end;
591
592 local Default = {
593 Clearance = {};
594 StoreK = Conc;
595 UserId = Id;
596 Color = BrickColor.Random().Number;
597 Bio = 'No bio.';
598 Theme = 'Revolve';
599 Image = 330916575; -- Unversed Logo.
600 Registered = false;
601 Banned = false;
602 };
603
604 for Idx, Val in next, Default do
605 if (Loaded[Idx] == nil) then
606 Loaded[Idx] = Val;
607 end;
608 end;
609
610 if Init then
611 for Idx, Val in next, System.Copy(Init) do
612 Loaded[Idx] = Val;
613 end;
614 end;
615
616 if (not Loaded.Alias) then
617 Loaded.Alias = RandomizeName(Id);
618 end;
619
620 local Clearance = Loaded.Clearance;
621 local Cache = {};
622
623 Loaded.Cache = Cache;
624 Loaded.Registered = (#Clearance ~= 0);
625
626 if (type(Clearance) == 'table') then
627 for Idx = 1, #Clearance do
628 Cache[Clearance[Idx]] = true;
629 end;
630
631 Cache.Registered = Loaded.Registered;
632 end;
633
634 if Passed then
635 Passed:Fire(Loaded);
636 end;
637
638 return Loaded;
639 end;
640
641 function Profiles.Save(Id, Data)
642 local Conc = Data.StoreK or Clear.HashMD5(DStoreK .. Id);
643 local Save = System.Copy(Data);
644
645 Save.Cache = nil;
646
647 SetAsync(DStore, Conc, Clear.REncode(Save));
648 end;
649
650 function Profiles.Get(Who)
651 local UID;
652
653 if Discord[Who] then
654 return Profiles.Get(Discord[Who]);
655 elseif (typeof(Who) == 'Instance') and Who:IsA'Player' then
656 UID = Who.UserId;
657 elseif (type(Who) == 'number') and ((Who % 1) == 0) then
658 UID = Who;
659 end;
660
661 if UID then
662 local Prof = Cache[UID];
663
664 if (not Prof) then
665 local Data = Instance.new'BindableEvent';
666
667 Cache[UID] = Data;
668 Prof = Profiles.FromId(UID, Data);
669 elseif (typeof(Prof) == 'Instance') then
670 return Prof.Event:wait();
671 end;
672
673 Cache[UID] = Prof;
674
675 return Prof;
676 else
677 return;
678 end;
679 end;
680
681 function Profiles.Cached(Id)
682 return Cache[Id];
683 end;
684
685 function Profiles.UnCache(Id)
686 local Prof = Cache[Id];
687
688 if Prof and Prof.Cache then
689 for _, Data in next, Prof.Cache do
690 if (typeof(Data) == 'RBXScriptSignal') then
691 Data:Disconnect();
692 end;
693 end;
694 end;
695
696 Cache[Id] = nil;
697 end;
698
699 function Profiles.Delete(Id)
700 Profiles.UnCache(Id);
701 SetAsync(DStore, Clear.HashMD5(DStoreK .. Id), false);
702 end;
703
704 Clear.Profiles = Profiles;
705end;]]></ProtectedString>
706 <BinaryString name="Tags"></BinaryString>
707 </Properties>
708 </Item>
709 <Item class="ModuleScript" referent="RBXCC9EE6E296164034BC80DFB0C5165521">
710 <Properties>
711 <Content name="LinkedSource"><null></null></Content>
712 <string name="Name">Process</string>
713 <string name="ScriptGuid">{12F95956-C23C-41A0-A264-6D85CAA9CD56}</string>
714 <ProtectedString name="Source"><![CDATA[return function() -- NOTE: This contains *some* of the Api.
715 local Clear = Clear;
716 local System = Clear.WaitFor'System';
717 local Profiles = Clear.WaitFor'Profiles';
718 local Commands = Clear.WaitFor'Commands';
719 local Themes = Clear.WaitFor'Themes';
720
721 local Billboard = Clear.Create'BillboardGui';
722 local GetRandom = Clear.GetRandom;
723 local Discord = System.Discord;
724 local Players = Clear.Players;
725 local Remote = Clear.Remote;
726 local Thread = Clear.Thread;
727 local Cross = System.Cross;
728 local Label = Clear.Create'TextLabel';
729 local Image = Clear.Create'ImageLabel';
730 local Beat = Clear.RunService.Heartbeat;
731
732 local UDim2 = UDim2.new;
733 local Color3 = Color3.new;
734 local Vector2 = Vector2.new;
735 local BrickRand = BrickColor.Random;
736 local BrickColor = BrickColor.new;
737
738 local Notify = Commands.Notify;
739 local Insert = table.insert;
740 local Remove = table.remove;
741 local Gsub = string.gsub;
742 local Sub = string.sub;
743 local Str = tostring;
744
745 local CData = setmetatable({}, {__mode = 'k', __metatable = 'Crystals'});
746 local Crystals = {System.Dep('3D', 'LowPoly'); System.Dep('3D', 'MidPoly'); System.Dep('3D', 'HighPoly')};
747
748 local ChatLogs = System.Logs.Chat;
749 local Discord = System.Discord;
750 local WebhookE;
751 local Settings;
752
753 local function CustomEnv(Player)
754 return {
755 Player = Player;
756 Limbo = function()
757 return Clear.RealEnv;
758 end;
759 Save = function(Ins, Name)
760 if (typeof(Ins) == 'Instance') then
761 Ins.Archivable = true;
762
763 local K = Ins:Clone();
764
765 K.Name = (Name and tostring(Name)) or Ins.Name;
766
767 pcall(function() K.Parent = Clear.ServerStorage:FindFirstChild'Cl_Saved' or Clear.Create'Folder'{Parent = Clear.ServerStorage, Name = 'Cl_Saved'}; end);
768
769 return K;
770 else
771 error('Instance expected.', 0);
772 end;
773 end;
774 SavePlace = function()
775 return Clear.AssetService:SavePlaceAsync();
776 end;
777 CreatePlace = function(Name, Id, Desc)
778 return Clear.AssetService:CreatePlaceInPlayerInventoryAsync(Player, Name, Id, Desc);
779 end;
780 SaveInstance = function(What, Where)
781 if Player.DataReady then
782 return Player:SaveInstance(Where or 'CaseOneInstance', What);
783 else
784 return Commands.Run(Player, 'ColorNotify', {nil, 1004, 'Error while saving instance, try again.'});
785 end;
786 end;
787 LoadInstance = function(Where)
788 if Player.DataReady then
789 return Player:LoadInstance(Where or 'CaseOneInstance');
790 else
791 return Commands.Run(Player, 'ColorNotify', {nil, 1004, 'Error while loading instance, try again.'});
792 end;
793 end;
794 Export = function(...)
795 local Args = {...};
796 local Out = {};
797
798 for _, K in next, Args do
799 Insert(Out, Str(K));
800 end;
801
802 Out = Sub(Clear.Trim(table.concat(Out, '\n')), 1, 2000);
803
804 Discord.HookMessage{
805 username = 'LuaExport';
806 content = Out;
807 };
808
809 return Out;
810 end;
811 print = function(...)
812 local Args = {...};
813 local White = BrickColor(1);
814
815 pcall(function()
816 for _, Arg in next, Args do
817 Notify(Player, tostring(Arg), White, 'SciFi');
818 end;
819 end);
820
821 return print(...);
822 end;
823 warn = function(...)
824 local Args = {...};
825 local Yellow = BrickColor(24);
826
827 pcall(function()
828 for _, Arg in pairs(Args) do
829 Notify(Player, tostring(Arg), Yellow, 'SciFi');
830 end;
831 end);
832
833 return warn(...);
834 end;
835 setfenv = function(A, B)
836 if (type(A) == 'function') then
837 return setfenv(A, B);
838 end;
839 end;
840 getfenv = function(Env)
841 if (type(Env) == 'function') then
842 return getfenv(Env);
843 end
844 end;
845 Get = function(Class, Where)
846 return System.FindClass(Where or game, Class, {});
847 end;
848 Event = Clear.Memoize(function(Name)
849 local Ev;
850
851 for _, Service in next, game:GetChildren() do
852 pcall(function()
853 if (typeof(Service[Name]) == 'RBXScriptSignal') then
854 Ev = Service[Name];
855 end;
856 end);
857
858 if Ev then
859 break;
860 end;
861 end;
862
863 return Ev;
864 end);
865 Method = Clear.Memoize(function(Want)
866 local Env = Clear.RealEnv;
867
868 if Env then
869 for Idx, Val in next, Env do
870 if (type(Idx) == 'userdata') then
871 local R, E = pcall(Val);
872
873 if E then
874 local Name = E:match'member function (%a+)';
875
876 if (Name == Want) or (Val == Want) then
877 return Idx;
878 end;
879 end;
880 end;
881 end;
882 else
883 error('Limbo must be first enabled.', 2); -- NOTE: It won't ever be.
884 end;
885 end);
886 Error = function(Conn)
887 return Clear.Pconnect(Clear.ScriptContext.Error, function(_, _, S)
888 Conn(S);
889 end);
890 end;
891 };
892 end;
893
894 Clear.Environments = Clear.Memoize(function(Pl)
895 local New, E = Clear.CreateEnv(CustomEnv(Pl));
896
897 if (Profiles.Get(Pl).Clearance ~= 'Unrestricted') then
898 E.Clear = nil;
899 end;
900
901 return New;
902 end, false);
903
904 function Clear.SetDiscordActive(Bool)
905 WebhookE = Bool;
906 end;
907
908 Clear.Pconnect(System.SChanged, function(Set)
909 Settings = Set;
910 end);
911
912 Settings = System.GetSettings();
913
914 local Load = function(Pl)
915 Profiles.UnCache(Pl.UserId);
916
917 local Data = Profiles.Get(Pl);
918 local Ban = Data.Banned;
919
920 if Ban then
921 local Reason = (type(Ban) == 'string') and Ban;
922
923 Clear.Kick(Pl, Reason or 'You are banned.');
924 else
925 local Theme = Data.Theme or '';
926
927 Thread(Themes[Theme] or Themes.Revolve, Pl);
928 end;
929 end;
930
931 local Dismiss = function(What)
932 if What:FindFirstChild'Dismiss' then return; else local K = Instance.new'BoolValue'; K.Name = 'Dismiss'; K.Parent = What; end;
933
934 local Siz = What.Size;
935 local Pos;
936
937 for Idx = 0, 30 do
938 Pos = What.CFrame;
939
940 What.Transparency = Idx / 30;
941 What.Size = Siz / ((Idx / 4) + 1);
942 What.CFrame = Pos;
943
944 Beat:wait();
945 end;
946
947 What:Destroy();
948 end;
949
950 Clear.Dismiss = Dismiss;
951
952 function Clear.Assign(Pl, Cr, Assigned)
953 CData[Cr] = Assigned or 'Dismiss';
954
955 return Cross:Fire('IndexObject', Pl, Cr);
956 end;
957
958 function Clear.Interpret(Crystal, Data)
959 local Kr = Data or (Crystal and CData[Crystal]);
960
961 if Kr then
962 CData[Crystal] = nil;
963
964 if (Kr == 'Dismiss') then
965 Thread(Dismiss, Crystal);
966 elseif (Kr[1] == 'Command') then
967 Thread(Dismiss, Crystal);
968 Commands.Run(Kr[2], Kr[3], Kr[4]);
969 end;
970 end;
971
972 return Kr;
973 end;
974
975 function Clear.Crystal(Type, Color, ...)
976 local Data = {...};
977 local Crys = Crystals[Type]:Clone();
978 local BData = {
979 Name = GetRandom();
980 Parent = Crys;
981 SizeOffset = Vector2(0, 1);
982 Size = UDim2(8, 0, 4, 0);
983 };
984
985 Crys.Name = GetRandom();
986 Crys.BrickColor = (Color and BrickColor(Color)) or BrickRand();
987
988 for Idx = 1, #Data do
989 Insert(BData, Data[Idx]);
990 end;
991
992 local Bill = Billboard(BData);
993
994 return Crys;
995 end;
996
997 function Clear.Image(ImageId)
998 return Image{
999 Name = 'Image' .. ImageId;
1000 BackgroundTransparency = 1;
1001 Size = UDim2(0.25, 0, 0.5, 0);
1002 Position = UDim2(0.375, 0, 0.5, 0);
1003 Image = 'rbxassetid://' .. ImageId;
1004 };
1005 end;
1006
1007 function Clear.Text(T, C, F)
1008 local T = Str(T or '');
1009 local C = C or BrickRand().Color;
1010 local F = F or 'Arial';
1011
1012 return Label{
1013 Name = F .. T;
1014 BackgroundTransparency = 1;
1015 TextStrokeTransparency = 0.3;
1016 Text = T;
1017 TextColor3 = C;
1018 TextStrokeColor3 = Color3(C.r * 0.6, C.g * 0.6, C.b * 0.6);
1019 Font = F;
1020 FontSize = 'Size18';
1021 TextScaled = #T > 60;
1022 TextWrapped = true;
1023 TextYAlignment = 'Bottom';
1024 Size = UDim2(1, 0, 1, 0);
1025 };
1026 end;
1027
1028 Clear.Pconnect(Players.PlayerAdded, Load);
1029
1030 Clear.Pconnect(Players.PlayerRemoving, function(Pl)
1031 local Data = Profiles.Get(Pl);
1032
1033 if Data.Registered or Data.Banned then
1034 Profiles.Save(Pl, Data);
1035 end;
1036
1037 Profiles.UnCache(Pl.UserId);
1038 end);
1039
1040 for _, User in next, Players:GetPlayers() do
1041 Thread(Load, User);
1042 end;
1043
1044 if Discord then
1045 local Game = System.Game;
1046 local Desc = Gsub(Game.Description, '\n', ' ');
1047
1048 if (#Desc > 180) then
1049 Desc = Sub(Desc, 1, 177) .. '...';
1050 end;
1051
1052 local Embeds = {
1053 {
1054 title = Game.Name, url = 'https://www.roblox.com/games/' .. Game.AssetId .. '/Game' .. Clear.UrlEncode(Gsub(tostring(Game.Name), '%W', ''));
1055 footer = {text = Desc};
1056 };
1057 };
1058
1059 Thread(function()
1060 local Players = Clear.Players;
1061
1062 while (#Players:GetPlayers() == 0) do wait(1 / 120); end;
1063
1064 for _, Player in next, Clear.GrabPlayer() do
1065 local Prof = Profiles.Get(Player)
1066 local Cle = System.Copy(Prof.Clearance);
1067
1068 if (type(Cle) == 'table') then
1069 if Prof.Registered then
1070 Insert(Cle, 'Registered');
1071 else
1072 Insert(Cle, 'Unregistered');
1073 end;
1074
1075 Cle = table.concat(Cle, '; ') .. '.';
1076 else
1077 Cle = Cle .. '.';
1078 end;
1079
1080 Insert(Embeds, {
1081 title = Player.Name .. ' (' .. Prof.Alias .. ')';
1082 color = (math.random(1, 256) ^ 3) - 1;
1083 url = 'https://www.roblox.com/users/' .. Player.UserId .. '/profile';
1084 description = Prof.Bio;
1085 footer = {text = Cle, icon_url = Profiles.Picture(Prof)};
1086 });
1087 end;
1088
1089 local Sent, Err = pcall(Discord.HookMessage, {
1090 username = 'Notification';
1091 content = 'Server Startup; ' .. Clear.FromUnix(os.time()) .. '.';
1092 embeds = Embeds;
1093 });
1094
1095 if (not Sent) then
1096 warn('Startup Error', Err);
1097 else
1098 local Map = Instance.new'Folder';
1099
1100 for _, Child in next, workspace:GetChildren() do
1101 if (Child.ClassName ~= 'Terrain') and (Child:IsA'BasePart' or (Child.ClassName == 'Model')) then
1102 local Cloned = Child:Clone();
1103
1104 if Cloned then
1105 Cloned.Parent = Map;
1106 end;
1107 end;
1108 end;
1109
1110 System.SetVar('BackupMap', Map);
1111 end;
1112 end);
1113
1114 Thread(function()
1115 local isWorking, e;
1116 local Cache = {};
1117 local Auth = System.Auth.Discord.Channel;
1118
1119 local Wait = false;
1120 local Runt = 0;
1121
1122 Clear.RunService.Stepped:Connect(function(Del)
1123 if Wait then return; end;
1124
1125 Wait = true;
1126
1127 if (Runt % 10) == 0 then
1128 Profiles.Update(Clear.Players:GetPlayers());
1129 end;
1130
1131 isWorking, e = pcall(function()
1132 local Messages = Discord.GetMessages(Auth);
1133
1134 for _, Msg in Clear.RIpairs(Messages) do
1135 local Auth = Profiles.Get(Msg.author.id);
1136
1137 if Auth and (not Cache[Msg.id]) then
1138 Cache[Msg.id] = true;
1139
1140 local Content = tostring(Msg.content);
1141 local Pl, St = Content:match'^!(%S+)%s+(%S+)';
1142
1143 if Pl and St then
1144 local Lo, Ls = Pl:lower(), St:lower();
1145
1146 if (Lo == 'all') or (Game.Name:lower():sub(1, #Lo) == Lo) then
1147 if (Ls == 'true') then
1148 WebhookE = true;
1149 elseif (Ls == 'false') then
1150 WebhookE = false;
1151 end;
1152 end;
1153 end;
1154
1155 if WebhookE and System.Recent(Msg.timestamp, Clear.FromUnix(os.time())) then
1156 local Start, Content = Content:match'(.)(.+)';
1157
1158 if (Start == '>') then
1159 Commands.Chatted(Msg.author.id, Settings.Prefix .. Content);
1160 elseif (Start == '~') then
1161 Commands.Run(Msg.author.id, 'Message', {Content});
1162 end;
1163 end;
1164 end;
1165 end;
1166 end);
1167
1168 if (not isWorking) then
1169 warn('Remote Error', e);
1170 wait(60);
1171 else
1172 wait(math.clamp(17 - Players.NumPlayers, 8, 16));
1173 end;
1174
1175 Runt = Runt + 1;
1176 Wait = false;
1177 end);
1178 end);
1179 end;
1180
1181 function Remote.OnInvoke(Pl, Req)
1182 if (Req == 'Hash') then
1183 return Clear.PlayerHash[Pl.UserId];
1184 end;
1185 end;
1186
1187 Clear.Pconnect(Remote.OnEvent, function(Pl, Why, ...)
1188 local Args = {...};
1189 local Arg1 = Args[1];
1190
1191 if (Why == 'CChat') then
1192 Insert(ChatLogs, {Time = os.time(), Name = Pl.Name, Log = Arg1});
1193 Remove(ChatLogs, 200);
1194 elseif (Why == 'Execute') then
1195 local Msg = Clear.Trim(Arg1);
1196
1197 if Args[2] then
1198 Msg = Settings.Prefix .. Msg;
1199 end;
1200
1201 if Msg then
1202 Thread(Commands.Chatted, Pl, Msg);
1203 end;
1204 elseif WebhookE and (Why == 'CLog') then
1205 local Msg = Clear.Trim(tostring(Arg1));
1206 local Prof = Profiles.Get(Pl);
1207 local Image = Profiles.Picture(Prof);
1208
1209 if (#Msg == 0) then return; end;
1210
1211 Discord.HookMessage{
1212 username = Pl.Name;
1213 content = Sub(Gsub(Msg, '@(%S)', '%1'), 1, 2000);
1214 avatar_url = Image;
1215 };
1216 elseif (Why == 'PUpdate') then
1217 local Prof = Profiles.Get(Pl);
1218 local Data = Clear.JDecode(Arg1);
1219
1220 Prof.Alias = Sub(Data.Alias, 1, 16);
1221 Prof.Bio = Sub(Data.Bio, 1, 200);
1222 Prof.Color = tonumber(Data.Color);
1223 Prof.Image = tonumber(Data.Image);
1224 elseif (Why == 'RemoveGui') and System.IsGui(Arg1) and Arg1:IsA'ScreenGui' then
1225 Arg1:Destroy();
1226 elseif (Why == 'Notepad') then
1227 Pl:SaveString(Clear.HashMD5('NoteStuff' .. Pl.UserId), Str(Arg1));
1228 elseif (Why == 'Refresh') then
1229 Commands.Run(Pl, 'RefreshUi', nil);
1230 elseif (Why == 'CCrystal') and Arg1 then
1231 Clear.Interpret(Arg1);
1232 end;
1233 end);
1234
1235 Clear.ClientAttach(System.Dep'CeleryClient');
1236 Clear.RemoteInit();
1237end;]]></ProtectedString>
1238 <BinaryString name="Tags"></BinaryString>
1239 </Properties>
1240 </Item>
1241 <Item class="ModuleScript" referent="RBX4EEB3981FA474BEB944C457F85A91CB0">
1242 <Properties>
1243 <Content name="LinkedSource"><null></null></Content>
1244 <string name="Name">Commands</string>
1245 <string name="ScriptGuid">{A8E19CBA-7C4B-4003-8C93-A389585B8FF0}</string>
1246 <ProtectedString name="Source"><![CDATA[return function()
1247 local Clear = Clear;
1248 local Profiles = Clear.WaitFor'Profiles';
1249 local Themes = Clear.WaitFor'Themes';
1250 local System = Clear.WaitFor'System';
1251 local Remote = Clear.Remote;
1252 local PermList = Clear.Memoize(function() return {}; end, false);
1253 local Commands = {};
1254 local List = {};
1255
1256 local Settings;
1257
1258 local Str = tostring;
1259 local Sub = string.sub;
1260 local Trim = Clear.Trim;
1261 local Lower = string.lower;
1262 local Match = string.match;
1263 local Cross = System.Cross;
1264 local Gmatch = string.gmatch;
1265 local Insert = table.insert;
1266 local Remove = table.remove;
1267 local CmdLogs = System.Logs.Command;
1268 local SafeChar = Clear.SafeChar;
1269 local BrickRand = BrickColor.Random;
1270 local Permission = Profiles.Permission;
1271 local BrickColor = BrickColor.new;
1272
1273 Clear.Pconnect(System.SChanged, function(Set)
1274 Settings = Set;
1275 end);
1276
1277 Settings = System.GetSettings();
1278
1279 local function GetPlayers(plr, names, donterror)
1280 local players = {};
1281 local isServer = type(plr) ~= 'userdata';
1282 local parent = Clear.NetworkServer or Clear.Players;
1283
1284 local function getplr(p)
1285 if not p then
1286 return p
1287 elseif p:IsA("Player") then
1288 return p
1289 elseif p:IsA('NetworkReplicator') then
1290 local p = p:GetPlayer();
1291
1292 if p ~= nil and p:IsA('Player') then
1293 return p
1294 end
1295 end
1296 end
1297
1298 if (plr == nil) and (not isServer) then
1299 for i,v in next, parent:GetChildren() do
1300 local p = getplr(v)
1301 Insert(players,p)
1302 end
1303 elseif plr and not names then
1304 return {plr}
1305 elseif names then
1306 for s in names:gmatch('[^,]+') do
1307 local plrs = 0
1308 local function plus()
1309 plrs = plrs+1
1310 end
1311
1312 local function randomPlayer()
1313 if #players>=#parent:GetChildren() then return end
1314 local rand = parent:GetChildren()[math.random(#parent:GetChildren())]
1315 local p=getplr(rand)
1316 for i,v in next, players do
1317 if(v==p.Name)then
1318 randomPlayer()
1319 return;
1320 end
1321 end
1322 Insert(players,p)
1323 plus();
1324 end
1325
1326 if Lower(s)=='me' and plr then
1327 Insert(players,plr)
1328 plus()
1329 elseif Lower(s)=='all' or Lower(s)=="@everyone" then
1330 local everyone = true
1331
1332 if everyone then
1333 for i,v in next, parent:GetChildren() do
1334 local p = getplr(v)
1335 Insert(players,p)
1336 plus()
1337 end
1338 end
1339 elseif Lower(s)=='others' then
1340 for i,v in next, parent:GetChildren() do
1341 local p=getplr(v)
1342 if p~=plr then
1343 Insert(players,p)
1344 plus()
1345 end
1346 end
1347 elseif Lower(s)=='random' then
1348 randomPlayer();
1349 plus()
1350 elseif Lower(s)=='admins' then
1351 for i,v in next, parent:GetChildren() do
1352 local p=getplr(v)
1353 if Profiles.Get(p).Registered then
1354 Insert(players,p)
1355 plus()
1356 end
1357 end
1358 elseif Lower(s)=='nonadmins' then
1359 for i,v in next, parent:GetChildren() do
1360 local p=getplr(v)
1361 if not Profiles.Get(p).Registered then
1362 Insert(players,p)
1363 plus()
1364 end
1365 end
1366 elseif Lower(s)=='friends' then
1367 for i,v in next, parent:GetChildren() do
1368 local p=getplr(v)
1369 if p:IsFriendsWith(plr.userId) then
1370 Insert(players,p)
1371 plus()
1372 end
1373 end
1374 elseif Lower(s)=='besties' then
1375 for i,v in next, parent:GetChildren() do
1376 local p=getplr(v)
1377 if p:IsBestFriendsWith(plr.userId) then
1378 Insert(players,p)
1379 plus()
1380 end
1381 end
1382 elseif Lower(s):sub(1,1)=='%' then
1383 for i,v in next, Clear.Teams:GetChildren() do
1384 if v.Name:lower():sub(1,#s:sub(2))==Lower(s):sub(2) then
1385 for k,m in next, parent:GetChildren() do
1386 local p=getplr(m)
1387 if p.TeamColor==v.TeamColor then
1388 Insert(players,p)
1389 plus()
1390 end
1391 end
1392 end
1393 end
1394 elseif Lower(s):sub(1,1)=='$' then
1395 for i,v in next, parent:GetChildren() do
1396 local p=getplr(v)
1397 if tonumber(Lower(s):sub(2)) then
1398 if p:IsInGroup(tonumber(Lower(s):sub(2))) then
1399 Insert(players,p)
1400 plus()
1401 end
1402 end
1403 end
1404 elseif Lower(s):sub(1,3)=='id-' then
1405 for i,v in next, parent:GetChildren() do
1406 local p = getplr(v)
1407 if tonumber(Lower(s):sub(4)) then
1408 if p and p.userId==tonumber(Lower(s):sub(4)) then
1409 Insert(players,p)
1410 plus()
1411 end
1412 end
1413 end
1414 elseif Lower(s):sub(1,5)=='team-' then
1415 for i,v in next, Clear.Teams:GetChildren() do
1416 if v.Name:lower():sub(1,#s:sub(6))==Lower(s):sub(6) then
1417 for k,m in next, parent:GetChildren() do
1418 local p=getplr(m)
1419 if p.TeamColor==v.TeamColor then
1420 Insert(players,p)
1421 plus()
1422 end
1423 end
1424 end
1425 end
1426 elseif Lower(s):sub(1,6)=='group-' then
1427 for i,v in next, parent:GetChildren() do
1428 local p=getplr(v)
1429 if tonumber(Lower(s):sub(7)) then
1430 if p:IsInGroup(tonumber(Lower(s):sub(7))) then
1431 Insert(players,p)
1432 plus()
1433 end
1434 end
1435 end
1436 elseif Lower(s):sub(1,1)=='-' then
1437 local removes = GetPlayers(plr,Lower(s):sub(2),true)
1438 for i,v in next, players do
1439 for k,p in next, removes do
1440 if v.Name==p.Name then
1441 Remove(players,i)
1442 plus()
1443 end
1444 end
1445 end
1446 elseif Lower(s):sub(1,1)=='#' then
1447 local num = tonumber(Lower(s):sub(2))
1448 if(num==nil)then
1449 error("Invalid number!")
1450 end
1451 for i=0,num do
1452 randomPlayer();
1453 end
1454 elseif Lower(s):sub(1,7)=="radius-" then
1455 local num = tonumber(Lower(s):sub(8))
1456 if(num==nil)then
1457 error("Invalid number!")
1458 end
1459 for i,v in next, parent:GetChildren() do
1460 local p=getplr(v)
1461 if p~=plr and plr:DistanceFromCharacter(p.Character.Head.Position)<=num then
1462 Insert(players,p)
1463 plus()
1464 end
1465 end
1466 else
1467 for i,v in next, parent:GetChildren() do
1468 local p = getplr(v)
1469 if p and p.Name:lower():sub(1,#s)==Lower(s) then
1470 Insert(players,p)
1471 plus()
1472 end
1473 end
1474 end
1475 if plrs==0 and not donterror then error('No players matching '..s..' were found!') end
1476 end
1477 end
1478 return players
1479 end
1480
1481 local function FromName(N)
1482 return List[Str(Lower(N))];
1483 end;
1484
1485 local function Split(Args, K)
1486 local List = {};
1487 local K = K or 1;
1488
1489 for Whi, Arg in Gmatch(Args, '(%s*)(%S+)') do
1490 if (#List < K) then
1491 Insert(List, Arg);
1492 else
1493 List[#List] = List[#List] .. Whi .. Arg;
1494 end;
1495 end;
1496
1497 return List;
1498 end;
1499
1500 local function Run(Pl, Name, Args, Log)
1501 local Command = FromName(Name);
1502 local Args = Args or {};
1503
1504 if Command then
1505 if Permission(Pl, Command.Perms) then
1506 local Ex, Err = Clear.Acall(Command.Function, Pl, Args);
1507
1508 if (not Log) then
1509 Insert(CmdLogs, {Time = os.time(), Name = Pl.Name or 'Discord', Log = Str(Args.Message)});
1510 Remove(CmdLogs, 200);
1511 end;
1512
1513 if (not Ex) then
1514 Clear.Assign(Pl, Clear.Crystal(
1515 2,
1516 1004,
1517 Clear.Text(Err, Color3.new(1, 0, 0), 'SciFi')
1518 ));
1519 end;
1520
1521 return true;
1522 else
1523 return false, 'You are not allowed to run "' .. Str(Args.Message) .. '"';
1524 end;
1525 end;
1526 end;
1527
1528 local function Chatted(Pl, Message)
1529 if (Sub(Trim(Message), 1, 1) ~= Settings.Prefix) then return; end;
1530
1531 for Str in Gmatch(Message, '[^' .. SafeChar(Settings.Batch) .. ']+') do
1532 local Pr, Cmd, Args = Match(Trim(Str), '^(' .. SafeChar(Settings.Prefix) .. ')(%w+)%s*(.*)');
1533
1534 if Pr then
1535 local Command = FromName(Cmd);
1536
1537 if Command then
1538 local ArgList = Split(Args, #Command.Args);
1539
1540 ArgList.Message = Str;
1541
1542 local Ex, Err = Run(Pl, Cmd, ArgList, true);
1543
1544 if (type(Pl) == 'userdata') and (not Ex) then
1545 Clear.Assign(Pl, Clear.Crystal(
1546 2,
1547 1004,
1548 Clear.Text(Err, Color3.new(1, 0, 0), 'SciFi')
1549 ));
1550 end;
1551 else
1552 break;
1553 end;
1554 else
1555 break;
1556 end;
1557 end;
1558 end;
1559
1560 local function New(K)
1561 local Names = K.Names;
1562
1563 if (not Names) then return; end;
1564
1565 local Perms = K.Perms;
1566 local Pnum = #Perms;
1567
1568 Commands[Names[1]] = K;
1569
1570 if (Pnum == 0) then
1571 Insert(PermList.Unindexed, K);
1572 else
1573 for Idx = 1, Pnum do
1574 Insert(PermList[Perms[Idx]], K);
1575 end;
1576 end;
1577
1578 for Idx = 1, #Names do
1579 List[Lower(Names[Idx])] = K;
1580 end;
1581 end;
1582
1583 -- Api-specific functions.
1584
1585 local function Notify(Pl, Text, Col, Font, Instr, Typ)
1586 local C = Col or BrickRand();
1587
1588 return Clear.Assign(Pl, Clear.Crystal(
1589 Typ or 2,
1590 C.Number,
1591 Clear.Text(Text, C.Color, Font)
1592 ), Instr);
1593 end;
1594
1595 local function INotify(Pl, Image, Col, Instr, Typ)
1596 local C = Col or BrickRand();
1597
1598 return Clear.Assign(Pl, Clear.Crystal(
1599 Typ or 2,
1600 C.Number,
1601 Clear.Image(Image)
1602 ), Instr);
1603 end;
1604
1605 New{
1606 Names = {'EditProfile', 'MyData'};
1607 Perms = {'Registered'};
1608 Args = {};
1609 Function = function(Pl, Args)
1610 if System.HasGui(Pl, 'Profile') then error'You are already editing your profile.'; end;
1611
1612 local Data = {};
1613 local Prof = Profiles.Get(Pl);
1614
1615 Data.Bio = Prof.Bio;
1616 Data.Alias = Prof.Alias;
1617 Data.Color = Prof.Color;
1618 Data.Image = Prof.Image;
1619
1620 System.LoadGui(Pl, 'Profile', Data);
1621 end;
1622 };
1623
1624 New{
1625 Names = {'Profile', 'Me'};
1626 Perms = {};
1627 Args = {};
1628 Function = function(Pl, Args)
1629 local Profile = Profiles.Get(Pl);
1630 local Color = BrickColor(Profile.Color);
1631
1632 if Profile then
1633 local CData = {};
1634
1635 Run(Pl, 'Dismiss');
1636
1637 INotify(Pl, Profile.Image, Color);
1638 Notify(Pl, 'Alias[] ' .. Profile.Alias, Color, 'SciFi');
1639 Notify(Pl, 'Bio[] ' .. Profile.Bio, Color, 'SciFi');
1640 Notify(Pl, 'Color[] ' .. tostring(Color), Color, 'SciFi');
1641
1642 if (Profile.Clearance == 'Unrestricted') then
1643 Notify(Pl, 'Unrestricted Clearance', BrickColor'Lavender', 'Fantasy', nil, 3);
1644 elseif Profile.Registered then
1645 local Cle = System.Copy(Profile.Clearance);
1646
1647 Insert(Cle, 'Registered');
1648
1649 local Perms = table.concat(Cle, '; ');
1650
1651 Notify(Pl, Perms, BrickColor'Pastel blue', 'Fantasy', nil, 3);
1652 else
1653 Notify(Pl, 'No Profile', BrickColor'Crimson', 'SciFi');
1654 end;
1655 end;
1656 end;
1657 };
1658
1659 New{
1660 Names = {'ViewProfile'};
1661 Perms = {'Registered'};
1662 Args = {'User', 'LastFilter', 'LastPage'};
1663 Hidden = true;
1664 Function = function(Pl, Args)
1665 local Profile = Args[1];
1666
1667 Clear.Assert(type(Profile) == 'table', 'This is not a standalone function.');
1668
1669 local Color = BrickColor(Profile.Color);
1670 local CData = {};
1671
1672 Run(Pl, 'Dismiss');
1673
1674 INotify(Pl, Profile.Image, Color);
1675 Notify(Pl, 'Alias[] ' .. Profile.Alias, Color, 'SciFi');
1676 Notify(Pl, 'Bio[] ' .. Profile.Bio, Color, 'SciFi');
1677 Notify(Pl, 'Color[] ' .. tostring(Color), Color, 'SciFi');
1678
1679 Notify(Pl, string.format('Viewing %s\'s profile', Profile.Name), nil, 'SciFi');
1680 Notify(Pl, 'Back', nil, 'SciFi', {'Command', Pl, 'People', {Args[2], Args[3]}});
1681 end;
1682 };
1683
1684 New{
1685 Names = {'People', 'Database', 'Network'};
1686 Perms = {'Registered'};
1687 Args = {'Filter', 'Page'};
1688 Function = function(Pl, Args)
1689 Run(Pl, 'Dismiss');
1690
1691 local Database = System.Database;
1692 local Filter = Args[1] or '.';
1693 local Page = Args[2] or 1;
1694 local Adva = ((Page - 1) * 12) + 1;
1695 local List = {};
1696 local Eac = 0;
1697
1698 local Set = BrickRand();
1699
1700 for Idx = 1, #Database do
1701 local Item = Database[Idx];
1702
1703 if Match(Item.Name, Filter) then
1704 List[#List + 1] = Item;
1705 end;
1706 end;
1707
1708 while (Eac ~= 12) do
1709 local Last = List[Adva];
1710
1711 if (not Last) then
1712 break;
1713 else
1714 Notify(Pl, Last.Name, Set, 'SciFi', {'Command', Pl, 'ViewProfile', {Last, Filter, Page}});
1715 Eac = Eac + 1;
1716 Adva = Adva + 1;
1717 end;
1718 end;
1719
1720 if (Eac ~= 0) then
1721 Notify(Pl, 'Next Page', nil, 'Fantasy', {'Command', Pl, 'People', {Filter, Page + 1}});
1722 end;
1723
1724 if (Page > 1) then
1725 Notify(Pl, 'Last Page', nil, 'Fantasy', {'Command', Pl, 'People', {Filter, Page - 1}});
1726 end;
1727 end;
1728 };
1729
1730 New{
1731 Names = {'Discord', 'Webhook'};
1732 Desc = 'Enabled in game access from the Discord server.';
1733 Perms = {'Discord'};
1734 Args = {'Bool'};
1735 Function = function(Pl, Args)
1736 local Arg = Args[1];
1737
1738 if (Arg == 'true') then
1739 Clear.SetDiscordActive(true);
1740
1741 Notify(Pl, 'Discord access has been enabled.', BrickColor(28));
1742 elseif (Arg == 'false') then
1743 Clear.SetDiscordActive(false);
1744
1745 Notify(Pl, 'Discord access has been disabled.', BrickColor(1004));
1746 end;
1747 end;
1748 };
1749
1750 New{
1751 Names = {'ShowInLevel'};
1752 Perms = {};
1753 Args = {'Level'};
1754 Function = function(Pl, Args)
1755 local Level = Args[1];
1756 local Perm = Level and rawget(PermList, Args[1]);
1757
1758 Clear.Assert(Level, 'Incorrect Level provided.');
1759
1760 local CanUse = Permission(Pl, Level);
1761 local Unrest = (Profiles.Get(Pl).Clearance == 'Unrestricted');
1762
1763 Run(Pl, 'Dismiss');
1764
1765 if CanUse then
1766 for Idx = 1, #Perm do
1767 local Data = Perm[Idx];
1768
1769 if ((not Data.Hidden) or Unrest) then
1770 local Name = Data.Names[1];
1771
1772 Notify(
1773 Pl,
1774 Name,
1775 nil,
1776 'Fantasy',
1777 {'Command', Pl, 'Commands', {Name}}
1778 );
1779 end;
1780 end;
1781 else
1782 Notify(Pl, 'You can not see the details of this Clearance Level.', BrickColor(1004));
1783 end;
1784 end;
1785 };
1786
1787 New{
1788 Names = {'Commands', 'Cmds'};
1789 Perms = {};
1790 Args = {'Name'};
1791 Function = function(Pl, Args)
1792 Run(Pl, 'Dismiss');
1793
1794 local D = Args[1] and FromName(Args[1]);
1795
1796 if D and ((not D.Hidden) or (Profiles.Get(Pl).Clearance == 'Unrestricted')) then
1797 Notify(Pl, 'Names[] ' .. table.concat(D.Names, '; '), BrickColor'Lavender', 'SciFi');
1798
1799 if (#D.Args ~= 0) then
1800 Notify(Pl, 'Args[] ' .. table.concat(D.Args, '; '), BrickColor(1012), 'SciFi');
1801 else
1802 Notify(Pl, 'This command has no Args.', BrickColor(1012), 'SciFi');
1803 end;
1804
1805 if (#D.Perms ~= 0) then
1806 Notify(Pl, 'Perms[] ' .. table.concat(D.Perms, '; '), BrickColor'Pastel Blue', 'SciFi');
1807 else
1808 Notify(Pl, 'Anyone can use this command.', BrickColor'Pastel Blue', 'SciFi');
1809 end;
1810
1811 if D.Desc then
1812 Notify(Pl, 'Desc[] ' .. D.Desc, BrickColor(24), 'SciFi');
1813 else
1814 Notify(Pl, 'No description.', BrickColor(24), 'SciFi');
1815 end;
1816
1817 if Permission(Pl, D.Perms) then
1818 Notify(Pl, 'You can use this command.', BrickColor(28), 'SciFi');
1819 else
1820 Notify(Pl, 'You can not use this command.', BrickColor(1004), 'SciFi');
1821 end;
1822 else
1823 for Name, _ in next, PermList do
1824 if Permission(Pl, Name) then
1825 Notify(
1826 Pl,
1827 'View ' .. Name .. ' commands.',
1828 nil,
1829 'Fantasy',
1830 {'Command', Pl, 'ShowInLevel', {Name}}
1831 );
1832 end;
1833 end;
1834 end;
1835 end;
1836 };
1837
1838 New{
1839 Names = {'Script', 'Code', 'Lua'};
1840 Perms = {'Scripter'};
1841 Args = {'Code'};
1842 Function = function(Pl, Args)
1843 Clear.Assert(Args[1], 'No code provided.');
1844
1845 local Env = Clear.Environments[Pl];
1846
1847 local Ran, Err = Clear.Loadstring(Args[1], Env);
1848
1849 if (not Ran) then
1850 Notify(Pl, 'Compiler ' .. Str(Err), BrickColor(1004), 'SciFi');
1851 else
1852 local R, Err = pcall(Ran);
1853
1854 if (not R) then
1855 Notify(Pl, 'Execution ' .. Str(Err), BrickColor(1004), 'SciFi');
1856 end;
1857 end;
1858 end;
1859 };
1860
1861 New{
1862 Names = {'LocalScript', 'Local', 'Ls'};
1863 Perms = {'Scripter'};
1864 Args = {'Players', 'Code'};
1865 Function = function(Pl, Args)
1866 local Code = Args[2];
1867
1868 Clear.Assert(Args[2], 'No code provided.');
1869
1870 for _, Plr in next, GetPlayers(Pl, Args[1]) do
1871 Remote.Send(Plr, 'RCode', Code);
1872 end;
1873 end;
1874 };
1875
1876 New{
1877 Names = {'Limbo'};
1878 Perms = {'Unrestricted'};
1879 Args = {'Status'};
1880 Function = function(Pl, Args)
1881 if (not Clear.Limbo) then
1882 Clear.Limbo = true;
1883
1884 error'You didn\'t expect this to be included too, did you?';
1885 end;
1886 end;
1887 };
1888
1889 New{
1890 Names = {'RefreshUi', 'NewUi', 'Ui'};
1891 Perms = {};
1892 Args = {};
1893 Function = function(Pl, Args)
1894 local Gui = System.HasGui(Pl, 'Commands');
1895
1896 if Gui then
1897 Gui:Destroy();
1898 end;
1899
1900 local Reg = Profiles.Get(Pl).Registered;
1901
1902 System.LoadGui(Pl, 'Commands', {Enabled = Reg, Bind = Settings.Console});
1903 end;
1904 };
1905
1906 New{
1907 Names = {'ColorNotify', 'ColorN', 'Cn'};
1908 Perms = {'Registered'};
1909 Args = {'Players', 'Color', 'Message'};
1910 Function = function(Pl, Args)
1911 local Pls = GetPlayers(Pl, Args[1]);
1912 local C, M = Args[2], Args[3];
1913
1914 Clear.Assert(M, 'No message provided.');
1915
1916 local Col = BrickColor(C);
1917
1918 for Idx = 1, #Pls do
1919 local P = Pls[Idx];
1920
1921 Notify(P, M, Col, 'SciFi');
1922 end;
1923 end;
1924 };
1925
1926 New{
1927 Names = {'Dismiss', 'Ds', 'Dt'};
1928 Perms = {};
1929 Args = {'Players'};
1930 Function = function(Pl, Args)
1931 local Players = GetPlayers(Pl, Args[1]);
1932
1933 for _, Ply in next, Players do
1934 if (Ply == Pl) or Profiles.IsHigher(Pl, Ply) then
1935 Cross:Fire('Clear', Ply);
1936 end;
1937 end;
1938 end;
1939 };
1940
1941 New{
1942 Names = {'SendMeHome'};
1943 Perms = {};
1944 Args = {};
1945 Function = function(Pl, Args)
1946 error'Well not providing this because testing server.';
1947 end;
1948 };
1949
1950 New{
1951 Names = {'Kill', 'Dead', 'Rek'};
1952 Perms = {'Registered'};
1953 Args = {'Players'};
1954 Function = function(Pl, Args)
1955 for _, Plr in next, GetPlayers(Pl, Args[1]) do
1956 if Plr.Character then
1957 Plr.Character:BreakJoints();
1958 end;
1959 end;
1960 end;
1961 };
1962
1963 New{
1964 Names = {'Crash', 'Rip'};
1965 Perms = {'Enforcer'};
1966 Args = {'Players'};
1967 Function = function(Pl, Args)
1968 for _, Plr in next, GetPlayers(Pl, Args[1]) do
1969 if Profiles.IsHigher(Pl, Plr) then
1970 Clear.Crash(Plr);
1971 end;
1972 end;
1973 end;
1974 };
1975
1976 New{
1977 Names = {'Kick', 'Gtfo'};
1978 Perms = {'Enforcer'};
1979 Args = {'Players', 'Message'};
1980 Function = function(Pl, Args)
1981 local Msg = Args[2] or 'Kicked';
1982
1983 for _, Plr in next, GetPlayers(Pl, Args[1]) do
1984 if Profiles.IsHigher(Pl, Plr) then
1985 Clear.Kick(Plr, Msg);
1986 end;
1987 end;
1988 end;
1989 };
1990
1991 New{
1992 Names = {'Ban', 'Banish'};
1993 Perms = {'Enforcer'};
1994 Args = {'Players', 'Message'};
1995 Function = function(Pl, Args)
1996 local Msg = Args[2] or 'Banned';
1997
1998 for _, Plr in next, GetPlayers(Pl, Args[1]) do
1999 if Profiles.IsHigher(Pl, Plr) then
2000 local Profile = Profiles.Get(Plr);
2001
2002 Profile.Banned = Msg;
2003
2004 Clear.Kick(Plr, Msg);
2005 end;
2006 end;
2007 end;
2008 };
2009
2010 New{
2011 Names = {'Rank', 'GiveRank'};
2012 Perms = {'Unversed'};
2013 Args = {'Players', 'Rank'};
2014 Function = function(Pl, Args)
2015 local Rank = Args[2];
2016
2017 if (not Rank) or (Clear.Trim(Rank:lower()) == 'unrestricted') and (Clear.Trim(Rank:lower()) == 'unversed') then
2018 error'Invalid rank provided.';
2019 else
2020 local Prof = Profiles.Get(Pl);
2021
2022 if (not Prof[Rank]) and (Prof.Clearance ~= 'Unrestricted') then
2023 error'Cannot give rank.';
2024 end;
2025 end;
2026
2027 for _, Plr in next, GetPlayers(Pl, Args[1]) do
2028 if Profiles.IsHigher(Pl, Plr) then
2029 local Pr = Profiles.Get(Plr);
2030 local Cl, Ch = Pr.Clearance, Pr.Cache;
2031
2032 Ch[Rank] = true;
2033 Cl[#Cl + 1] = Rank;
2034 end;
2035 end;
2036 end;
2037 };
2038
2039 New{
2040 Names = {'Register'};
2041 Perms = {'Unversed'};
2042 Args = {'Players'};
2043 Function = function(Pl, Args)
2044 for _, Plr in next, GetPlayers(Pl, Args[1]) do
2045 if Profiles.IsHigher(Pl, Plr) then
2046 local Prof = Profiles.Get(Plr);
2047
2048 Prof.Registered = true;
2049 Prof.Cache.Registered = true;
2050 end;
2051 end;
2052 end;
2053 };
2054
2055 New{
2056 Names = {'Delete', 'NoProfile'};
2057 Perms = {'Unversed'};
2058 Args = {'Players'};
2059 Function = function(Pl, Args)
2060 for _, Plr in next, GetPlayers(Pl, Args[1]) do
2061 if Profiles.IsHigher(Pl, Plr) then
2062 Profiles.Delete(Plr.UserId);
2063 Profiles.Get(Plr);
2064 end;
2065 end;
2066 end;
2067 };
2068
2069 New{
2070 Names = {'SetSetting', 'Setting'};
2071 Perms = {'Unrestricted'};
2072 Desc = 'Change the Batch, Console, or Prefix setting.';
2073 Args = {'Setting', 'Value'};
2074 Function = function(Player, Args)
2075 local A, B = Args[1], Args[2];
2076
2077 Clear.Assert(A and B, 'Missing arg.')
2078
2079 if (A:lower() == ('batch'):sub(1, #A)) then
2080 Clear.Settings.Batch = B;
2081 Clear.Variables:SaveData{
2082 Action = 'Replace';
2083 Place = 'Batch';
2084 Value = B;
2085 };
2086 elseif (A:lower() == ('console'):sub(1, #A)) then
2087 Clear.Settings.Console = B;
2088 Clear.Variables:SaveData{
2089 Action = 'Replace';
2090 Place = 'Console';
2091 Value = B;
2092 };
2093 elseif (A:lower() == ('prefix'):sub(1, #A)) then
2094 Clear.Settings.Prefix = B;
2095 Clear.Variables:SaveData{
2096 Action = 'Replace';
2097 Place = 'Prefix';
2098 Value = B;
2099 };
2100 else
2101 error('Invalid input. (Must be: Prefix, Console, or Batch)');
2102 end;
2103 end;
2104 };
2105
2106 New{
2107 Names = {'Message', 'M'};
2108 Desc = 'Makes a server-wide message.';
2109 Perms = {'Registered'};
2110 Args = {'Message'};
2111 Function = function(Player, Args)
2112 local Message = Args[1];
2113
2114 Clear.Assert(Message, 'No message provided.');
2115
2116 local Profile = Profiles.Get(Player);
2117 local Name = Str(Player);
2118
2119 if (Profile.Alias ~= 'None') then
2120 Name = '~' .. Profile.Alias;
2121 end;
2122
2123 for _, Pl in next, Clear.GrabPlayer() do
2124 System.LoadGui(Pl, 'Message', {Sender = Name, Message = Message});
2125 end;
2126 end;
2127 };
2128
2129 New{
2130 Names = {'SystemMessage', 'SM'};
2131 Desc = 'Makes a system server-wide message.';
2132 Perms = {'Unversed', 'Enforcer'};
2133 Args = {'Message'};
2134 Function = function(Player, Args)
2135 local Message = Args[1];
2136
2137 Clear.Assert(Message, 'No message provided.');
2138
2139 for _, Pl in next, Clear.GrabPlayer() do
2140 System.LoadGui(Pl, 'Message', {Sender = 'System Message', Message = Message});
2141 end;
2142 end;
2143 };
2144
2145 New{
2146 Names = {'DisableGame', 'GameOver', 'NoFunctionality'};
2147 Desc = '[UN-DO-ABLE] Stops every script it can find, stops every script that starts up, breaks.';
2148 Perms = {'Unrestricted'};
2149 Args = {};
2150 Function = function(Player, Args, Msg)
2151 error'Mmm this code was also a bit too much to give out.';
2152 end;
2153 };
2154
2155 New{
2156 Names = {'ReserveServer', 'NewServer', 'Reserve'};
2157 Desc = 'Reserves a server with <Name> and sends <Players> to it.';
2158 Perms = {'Registered'};
2159 Args = {'Players', 'Name'};
2160 Function = function(Player, Args)
2161 local Name = Args[2] or 'Nemesis';
2162 local Reserves = Settings.Reserves;
2163 local Server = Reserves[Name];
2164
2165 if (not Server) then
2166 Server = Clear.TeleportService:ReserveServer(game.PlaceId);
2167
2168 Reserves[Name] = Server;
2169
2170 System.SetSetting('Reserves', Reserves);
2171 end;
2172
2173 Clear.TeleportService:TeleportToPrivateServer(game.PlaceId, Server, GetPlayers(Player, Args[1]));
2174 end;
2175 };
2176
2177 New{
2178 Names = {'Place', 'ForcePlace'};
2179 Desc = 'Teleports <Players> to place with <Id>.';
2180 Perms = {'Enforcer'};
2181 Args = {'Players', 'Id'};
2182 Function = function(Player, Args)
2183 for _, Pl in next, GetPlayers(Player, Args[1]) do
2184 if (Pl == Player) or Profiles.IsHigher(Player, Pl) then
2185 Clear.TeleportService:Teleport(tonumber(Args[2]), Pl);
2186 end;
2187 end;
2188 end;
2189 };
2190
2191 New{
2192 Names = {'ReservedServers', 'PrivateServers', 'Reserves'};
2193 Desc = 'Gives you a list of all private servers.';
2194 Perms = {'Enforcer', 'Unversed'};
2195 Args = {};
2196 Function = function(Player, Args)
2197 local Servers = Settings.Reserves;
2198
2199 Run(Player, 'Dismiss');
2200
2201 for Name, Server in next, Servers do
2202 Notify(Player, Name, nil, 'SciFi');
2203 end
2204 end;
2205 };
2206
2207 New{
2208 Names = {'Players', 'Everyone'};
2209 Desc = 'Displays the Players connected in the <Action> or Default format.';
2210 Perms = {'Registered'};
2211 Args = {'Action'};
2212 Function = function(Player, Args)
2213 local Players = Clear.GrabPlayer('all');
2214 local Action = (Args[1] or 'Default'):lower();
2215
2216 if (Action == 'default') then
2217 Run(Player, 'Dismiss');
2218
2219 for _, Pl in next, Players do
2220 Notify(Player, Pl.Name, BrickColor(343), 'SciFi', {'Command', Player, 'PlayerSettings', {Pl.Name}});
2221 end;
2222 elseif (Action == 'export') then
2223 local Embeds = {};
2224
2225 for _, Player in next, Players do
2226 Insert(Embeds, {
2227 title = Player.Name;
2228 color = (math.random(1, 256) ^ 3) - 1;
2229 url = 'https://www.roblox.com/users/' .. Player.UserId .. '/profile';
2230 });
2231 end;
2232
2233 System.Discord.HookMessage{
2234 username = 'PlayerList';
2235 embeds = Embeds;
2236 };
2237 end;
2238 end;
2239 };
2240
2241 New{
2242 Names = {'PlayerSettings', 'PSettings'};
2243 Desc = 'Displays the settings and info crystals of <Player>.';
2244 Perms = {'User'};
2245 Args = {'Player'};
2246 Function = function(Player, Args)
2247 local Pl = GetPlayers(Player, Args[1])[1];
2248
2249 if Pl then
2250 Run(Player, 'Dismiss');
2251
2252 if Profiles.IsHigher(Player, Pl) then
2253 for _, Name in next, {'Kick', 'Ban', 'Crash'} do
2254 Notify(Player, Name .. ' ' .. Pl.Name, BrickColor'Crimson', 'Fantasy', {'Command', Player, Name, {Pl.Name}});
2255 end;
2256 end;
2257
2258 Notify(Player, 'Account age: ' .. Pl.AccountAge, BrickColor(1031), 'SciFi');
2259 Notify(Player, 'User Id: ' .. Pl.UserId, BrickColor(1010), 'SciFi');
2260 end;
2261 end;
2262 };
2263
2264 New{
2265 Names = {'Notepad', 'Notes'};
2266 Desc = 'Brings up your own personal notepad.';
2267 Perms = {'User'};
2268 Args = {};
2269 Function = function(Player, Args)
2270 if Player.DataReady then
2271 local Old = System.HasGui(Player, 'Notepad');
2272
2273 if Old then error('You already have a Notepad open.'); end;
2274
2275 local Notes = Player:LoadString(Clear.HashMD5('NoteStuff' .. Player.UserId)) or '';
2276
2277 System.LoadGui(Player, 'Notepad', {Notes = Notes});
2278 end;
2279 end;
2280 };
2281
2282 New{
2283 Names = {'Inject', 'Injects', 'Is', 'I'};
2284 Desc = 'Lists injections by filter.';
2285 Perms = {'User', 'Unversed'};
2286 Args = {'Filter'};
2287 Function = function(Player, Args)
2288 local Fi = tostring(Args[1] or '.'):lower();
2289
2290 Run(Player, 'Dismiss');
2291
2292 for Name, Injection in next, System.Injects do
2293 if Name:match(Fi) then
2294 Notify(Player, Injection.Name, nil, 'Fantasy', {'Command', Player, 'DoInject', {Name}});
2295 end;
2296 end;
2297 end;
2298 };
2299
2300 New{
2301 Names = {'DoInject'};
2302 Desc = 'Uses the especified inject.';
2303 Perms = {'User', 'Unversed'};
2304 Args = {'Name'};
2305 Hidden = true;
2306 Function = function(Player, Args)
2307 local Inject = System.Injects[Args[1]];
2308
2309 if Inject then
2310 local NewI = Inject:Clone();
2311
2312 NewI.Archivable = false;
2313 NewI.Parent = Clear.FindFirstClass(Player, 'Backpack');
2314
2315 if ((NewI.ClassName == 'Script') or (NewI.ClassName == 'LocalScript')) and NewI.Disabled then
2316 delay(1 / 120, function()
2317 NewI.Disabled = false;
2318 end);
2319 end
2320 end;
2321 end;
2322 };
2323
2324 New{
2325 Names = {'Explode', 'Ex'};
2326 Desc = 'Explodes the target <Players>.';
2327 Perms = {'Registered'};
2328 Args = {'Players'};
2329 Function = function(Player, Args)
2330 local Explodes = GetPlayers(Player, Args[1]);
2331
2332 for _, Player in next, Explodes do
2333 if Player.Character then
2334 local TorsoPos = Player.Character:FindFirstChild('HumanoidRootPart') and Player.Character.HumanoidRootPart.Position;
2335
2336 Clear.Create'Explosion'{
2337 DestroyJointRadiusPercent = 100;
2338 BlastRadius = 6;
2339 Name = 'BOOMboozled';
2340 Position = TorsoPos or Vector3.new(0, 0, 0);
2341 Parent = Clear.Workspace;
2342 };
2343 end;
2344 end;
2345 end;
2346 }
2347
2348 New{
2349 Names = {'WalkSpeed', 'Speed'};
2350 Desc = 'Sets <Player(s)> walkspeed to <Speed>.';
2351 Perms = {'Registered'};
2352 Args = {'Players', 'Speed'};
2353 Function = function(Player, Args)
2354 local Spd = GetPlayers(Player, Args[1]);
2355 local Set = tonumber(Args[2]) or 16;
2356
2357 for _, Player in next, Spd do
2358 local Hum = Player.Character and Player.Character:FindFirstChildOfClass'Humanoid';
2359
2360 if Hum then
2361 Hum.WalkSpeed = Set;
2362 end;
2363 end;
2364 end;
2365 }
2366
2367 New{
2368 Name = {'RemoveGui', 'KillGui'};
2369 Desc = 'Removes <Gui> from <Players> if present.';
2370 Level = 3;
2371 Hidden = false;
2372 Args = {'Players', 'Gui'};
2373 Function = function(Player, Args)
2374 local Removals = GetPlayers(Player, Args[1]);
2375 local Gui = Clear.IsGuiRegistered(Args[2] or '') or Args[2];
2376
2377 if Gui then
2378 for _, Player in next, Removals do
2379 Remote.Send(Player, 'KillGui', Gui)
2380 end;
2381 else
2382 error('No valid Gui provided.');
2383 end;
2384 end;
2385 };
2386
2387 New{
2388 Names = {'Heal', 'GiveLove'};
2389 Desc = 'Heals target <Players>.';
2390 Perms = {'Registered'};
2391 Args = {'Players'};
2392 Function = function(Player, Args)
2393 local Heals = GetPlayers(Player, Args[1]);
2394
2395 for _, Player in next, Heals do
2396 local Hum = Player.Character and Clear.FindFirstClass(Player.Character, 'Humanoid');
2397
2398 if Hum then
2399 Hum.Health = Hum.MaxHealth;
2400 end;
2401 end;
2402 end;
2403 };
2404
2405 New{
2406 Names = {'ForceField', 'FF'};
2407 Desc = 'Gives target <Players> a forcefield.';
2408 Perms = {'Registered'};
2409 Args = {'Players'};
2410 Function = function(Player, Args)
2411 local FFs = GetPlayers(Player, Args[1]);
2412
2413 for _, Player in next, FFs do
2414 local Hum = Player.Character and Clear.FindFirstClass(Player.Character, 'Humanoid');
2415
2416 if Hum then
2417 Instance.new('ForceField', Hum.Parent);
2418 end;
2419 end;
2420 end;
2421 };
2422
2423 New{
2424 Names = {'UnForceField', 'UnFF'};
2425 Desc = 'Removes target <Players> forcefield.';
2426 Perms = {'Registered'};
2427 Args = {'Players'};
2428 Function = function(Player, Args)
2429 local FFs = GetPlayers(Player, Args[1]);
2430
2431 for _, Player in next, FFs do
2432 local Hum = Player.Character and Clear.FindFirstClass(Player.Character, 'Humanoid');
2433
2434 if Hum then
2435 for _, C in next, Hum.Parent:GetChildren() do
2436 if (C.ClassName == 'ForceField') then
2437 C:Destroy();
2438 end;
2439 end;
2440 end;
2441 end;
2442 end;
2443 };
2444
2445 New{
2446 Names = {'Respawn', 'RS'};
2447 Desc = 'Respawns the target <Players>.';
2448 Perms = {'Registered'};
2449 Args = {'Players'};
2450 Function = function(Player, Args)
2451 local Resp = GetPlayers(Player, Args[1]);
2452
2453 for _, Player in next, Resp do
2454 pcall(Player.LoadCharacter, Player);
2455 end;
2456 end;
2457 };
2458
2459 New{
2460 Names = {'FixCamera', 'FixCam', 'FC'};
2461 Desc = 'Fixes Camera for <Players>.';
2462 Perms = {'User'};
2463 Args = {'Players'};
2464 Function = function(Player, Args)
2465 local Fixes = GetPlayers(Player, Args[1]);
2466
2467 for _, Pl in next, Fixes do
2468 Remote.Send(Pl, 'RCode', [[local Cam = workspace.CurrentCamera; Cam.CameraType = 'Custom'; Cam.CameraSubject = game:GetService('Players').LocalPlayer.Character and game:GetService('Players').LocalPlayer.Character:FindFirstChildOfClass('Humanoid');]])
2469 end;
2470 end;
2471 };
2472
2473 New{
2474 Names = {'BackupMap', 'SaveMap', 'MapBack'};
2475 Desc = 'Backs up the map.';
2476 Perms = {'User'};
2477 Args = {};
2478 Function = function(Player, Args)
2479 local Map = Instance.new'Folder';
2480
2481 for _, Child in next, workspace:GetChildren() do
2482 if (Child.ClassName ~= 'Terrain') and (Child:IsA'BasePart' or (Child.ClassName == 'Model')) then
2483 local Cloned = Child:Clone();
2484
2485 if Cloned then
2486 Cloned.Parent = Map;
2487 end;
2488 end;
2489 end;
2490
2491 System.SetVar('BackupMap', Map);
2492 end;
2493 };
2494
2495 New{
2496 Names = {'RestoreMap', 'ResetMap'};
2497 Desc = 'Restores the map to the back up.';
2498 Perms = {'User'};
2499 Args = {};
2500 Function = function(Player, Args)
2501 local Map = System.GetVar'BackupMap':Clone();
2502
2503 for _, Child in next, workspace:GetChildren() do
2504 if (Child.ClassName ~= 'Terrain') and (Child:IsA'BasePart' or ((Child.ClassName == 'Model') and (not Clear.Players:GetPlayerFromCharacter(Child)))) then
2505 Child:Destroy();
2506 end;
2507 end;
2508
2509 for _, Child in next, Map:GetChildren() do
2510 Child'MakeJoints';
2511 Child.Parent = workspace;
2512 end;
2513
2514 Map:Destroy();
2515 end;
2516 };
2517
2518 New{
2519 Names = {'Teleport', 'Tp'};
2520 Desc = 'Teleports <Players> to <Player>.';
2521 Perms = {'Registered'};
2522 Args = {'Players', 'Player'};
2523 Function = function(Player, Args)
2524 local Players = GetPlayers(Player, Args[1]);
2525 local Target = GetPlayers(Player, Args[2])[1];
2526
2527 if Target and Target.Character and Target.Character:FindFirstChild('HumanoidRootPart') then
2528 local Root = Target.Character.HumanoidRootPart;
2529
2530 for _, Pl in next, Players do
2531 local MRoot = Pl.Character and Pl.Character:FindFirstChild('HumanoidRootPart');
2532
2533 if MRoot and (Pl ~= Target) then
2534 MRoot.CFrame = Root.CFrame * CFrame.new(math.random(-40, 40)/10, math.random(-40, 40)/10, math.random(-40, 40)/10);
2535 end;
2536 end;
2537 end;
2538 end;
2539 };
2540
2541 New{
2542 Names = {'LockServer', 'ServerLock'};
2543 Desc = 'Toggles serverlock so only admins may join and kicks non-admins with <Message>.';
2544 Perms = {'Unversed', 'Enforcer'};
2545 Args = {'Message'};
2546 Function = function(Player, Args)
2547 local Status = System.LockedServer;
2548 local Message = Args[1] or 'Locked Server';
2549
2550 if Status then
2551 System.LockedServer = nil;
2552 Status:Disconnect();
2553
2554 Notify(Player, 'The Server has been unlocked.', BrickColor(28), 'SciFi');
2555 else
2556 System.LockedServer = Clear.Pconnect(Clear.Players.PlayerAdded, function(Join)
2557 wait();
2558
2559 if (not Profiles.Get(Join).Registered) then
2560 Clear.Kick(Join, Message);
2561 end;
2562 end);
2563
2564 Notify('The Server has been locked.', BrickColor(1004), 'SciFi');
2565 end
2566 end;
2567 };
2568
2569 New{
2570 Names = {'AgeLock', 'AgeLimit'};
2571 Desc = 'Kicks anyone under <Number> of days old, or 365 if no number given.';
2572 Perms = {'Unversed', 'Enforcer'};
2573 Args = {'Number'};
2574 Function = function(Player, Args)
2575 local Status = System.LockedAge;
2576 local Num = tonumber(Args[1]) or 365;
2577
2578 if Status then
2579 System.LockedAge = nil;
2580 Status:Disconnect();
2581
2582 Notify(Player, 'Agelock disabled.', BrickColor(28), 'SciFi');
2583 else
2584 System.LockedAge = Clear.Pconnect(Clear.Players.PlayerAdded, function(Join)
2585 wait();
2586
2587 local Rank = Profiles.Get(Join).Registered;
2588 local Age = Join.AccountAge;
2589
2590 if (Age < Num) and (not Rank) then
2591 wait();
2592
2593 Clear.Kick(Join, ('AgeLock is on, you must be %s day(s) older to join.'):format((Num - Age) + 1));
2594 end;
2595 end);
2596
2597 Notify(Player, 'Agelock enabled.', BrickColor(1004), 'SciFi');
2598 end
2599 end;
2600 };
2601
2602 New{
2603 Names = {'Fly'};
2604 Desc = 'Lets a Player Fly!';
2605 Perms = {'User'};
2606 Args = {'Player'};
2607 Function = function(Plr, Args)
2608 local Players = GetPlayers(Plr, Args[1]);
2609
2610 for _, Player in next, Players do
2611 Clear.LocalSource(Player, [==[
2612 local localplayer = game:GetService("Players").LocalPlayer
2613 local mouse = localplayer:GetMouse()
2614 local torso = localplayer.Character.Torso
2615 local flying = true
2616 local speed = 0
2617 local keys = {}
2618
2619 local function start()
2620 local pos = Instance.new("BodyPosition",torso)
2621 local gyro = Instance.new("BodyGyro",torso)
2622 pos.Name = "FLIGHTPOS"
2623 pos.maxForce = Vector3.new(math.huge, math.huge, math.huge)
2624 pos.position = torso.Position
2625 gyro.Name = "GYRO"
2626 gyro.maxTorque = Vector3.new(9e9, 9e9, 9e9)
2627 gyro.cframe = torso.CFrame
2628 torso.Parent.Humanoid.Died:connect(function()
2629 if gyro then gyro:Destroy() end
2630 if pos then pos:Destroy() end
2631 flying = false
2632 torso.Parent.Humanoid.PlatformStand = false
2633 speed = 0
2634 end)
2635 repeat
2636 wait(0.1)
2637 localplayer.Character.Humanoid.PlatformStand = true
2638 local new = gyro.cframe - gyro.cframe.p + pos.position
2639
2640 if not keys.w and not keys.s and not keys.a and not keys.d then
2641 speed = 1
2642 end
2643
2644 if keys.w then
2645 new = new + workspace.CurrentCamera.CoordinateFrame.lookVector * speed
2646 speed = speed+0.15
2647 end
2648 if keys.a then
2649 new = new * CFrame.new(-speed,0,0)
2650 speed = speed+0.15
2651 end
2652 if keys.s then
2653 new = new - workspace.CurrentCamera.CoordinateFrame.lookVector * speed
2654 speed = speed+0.15
2655 end
2656 if keys.d then
2657 new = new * CFrame.new(speed,0,0)
2658 speed = speed+0.15
2659 end
2660
2661 if speed>10 then
2662 speed=10
2663 end
2664 pos.position=new.p
2665 if keys.w then
2666 gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(-math.rad(speed*7.5),0,0)
2667 elseif keys.s then
2668 gyro.cframe = workspace.CurrentCamera.CoordinateFrame*CFrame.Angles(math.rad(speed*7.5),0,0)
2669 else
2670 gyro.cframe = workspace.CurrentCamera.CoordinateFrame
2671 end
2672 until not flying or not gyro or not pos or not pos.Parent
2673 if gyro then gyro:Destroy() end
2674 if pos then pos:Destroy() end
2675 flying = false
2676 torso.Parent.Humanoid.PlatformStand = false
2677 speed = 0
2678 end
2679
2680 mouse.KeyDown:connect(function(key)
2681 if key=="w" then
2682 keys.w = true
2683 elseif key=="s" then
2684 keys.s = true
2685 elseif key=="a" then
2686 keys.a = true
2687 elseif key=="d" then
2688 keys.d = true
2689 elseif key=="e" then
2690 if flying then
2691 flying = false
2692 else
2693 flying = true
2694 start()
2695 end
2696 end
2697 end)
2698
2699 mouse.KeyUp:connect(function(key)
2700 if key=="w" then
2701 keys.w = false
2702 elseif key=="s" then
2703 keys.s = false
2704 elseif key=="a" then
2705 keys.a = false
2706 elseif key=="d" then
2707 keys.d = false
2708 end
2709 end)
2710
2711 start()
2712 ]==]);
2713 end;
2714 end;
2715 }
2716
2717 New{
2718 Names = {'Fling', 'Launch'};
2719 Desc = 'Flings a Player to who knows where.';
2720 Perms = {'User'};
2721 Args = {'Player'};
2722 Function = function(Plr, Args)
2723 local Players = GetPlayers(Plr, Args[1]);
2724 for _, Player in next, Players do
2725 spawn(function()
2726 if Player.Character and Player.Character:FindFirstChild("HumanoidRootPart") and Player.Character:findFirstChild("Humanoid") then
2727 local xran local zran
2728
2729 repeat xran = math.random(-9999,9999) until math.abs(xran) >= 5555
2730 repeat zran = math.random(-9999,9999) until math.abs(zran) >= 5555
2731
2732 Player.Character.Humanoid.Sit = true
2733 Player.Character.HumanoidRootPart.Velocity = Vector3.new(0,0,0)
2734
2735 local frc = Clear.Create'BodyForce'{
2736 Parent = Player.Character.HumanoidRootPart;
2737 Name = "BFRC";
2738 Force = Vector3.new(xran*4,9999*5,zran*4);
2739 }
2740
2741 Clear.Debris:AddItem(frc, 0.1)
2742 end;
2743 end);
2744 end;
2745 end;
2746 }
2747
2748-- New{
2749-- Name = {'BSoD'};
2750-- Desc = 'BSoD a Player?? .o.';
2751-- Level = 2;
2752-- Hidden = false;
2753-- Args = {'Player'};
2754-- Function = function(Plr, Args)
2755-- local Players = GetPlayers(Plr, Args[1]);
2756-- local MyLevel = Admins:_Rank(Plr);
2757--
2758-- for _, Pl in next, Players do
2759-- if (Admins:_Rank(Pl) > MyLevel) then
2760-- Clear.LoadGui(Pl, 'BSoD');
2761-- end;
2762-- end;
2763-- end;
2764-- }
2765
2766 New{
2767 Names = {'ResetLuaEnv', 'NewEnv', 'NewLua'};
2768 Desc = 'Resets your Player environment for the LBI.';
2769 Perms = {'Scripter'};
2770 Args = {};
2771 Function = function(Player, Args)
2772 Clear.Environments[Player] = nil;
2773
2774 Notify(Player, 'Environment reset.', BrickColor(100), 'SciFi');
2775 end;
2776 };
2777
2778 New{
2779 Names = {'HttpFlood', 'FloodHttp', 'CrashRemote'};
2780 Desc = 'Executes <Amount> of Http requests to crash the service.';
2781 Perms = {'Trusted', 'Discord'};
2782 Args = {'Amount'};
2783 Function = function(Player, Args)
2784 local Amount = Args[1] and tonumber(Args[1]);
2785
2786 if (not Amount) or (Amount > 500) then
2787 Amount = 500;
2788 elseif (Amount <= 0) then
2789 Amount = 1;
2790 end;
2791
2792 for Run = 1, Amount do
2793 Clear.Thread(function()
2794 Clear.DoGet('https://www.google.com');
2795 end);
2796 end;
2797 end;
2798 };
2799
2800 New{
2801 Names = {'Character', 'Char'};
2802 Desc = 'Changes <Players> character to <UserId>.';
2803 Perms = {'User'};
2804 Args = {'Players', 'User'};
2805 Function = function(Player, Args)
2806 local Chars = GetPlayers(Player, Args[1]);
2807 local Set = (Args[2] and tonumber(Args[2]))
2808
2809 if (not Set) and Args[2] then pcall(function() Set = game.Players:GetUserIdFromNameAsync(Args[2]); end); end;
2810
2811 for _, Pl in next, Chars do
2812 pcall(function()
2813 Pl.CharacterAppearanceId = Set or Pl.UserId;
2814 Pl:LoadCharacter();
2815 end)
2816 end
2817 end;
2818 };
2819
2820 New{
2821 Names = {'Shutdown', 'Shut'};
2822 Desc = 'Ends the life of the server with <Message>.';
2823 Perms = {'Enforcer'};
2824 Args = {'Message'};
2825 Function = function(Player, Args, Msg)
2826 local function KillClients()
2827 Clear.Kick('all', Msg or 'Shutting down.');
2828 end;
2829
2830 Clear.Players.PlayerAdded:Connect(KillClients);
2831
2832 KillClients();
2833 end;
2834 };
2835
2836 New{
2837 Names = {'DisableScripts', 'NoScripts', 'DontRunScripts'};
2838 Desc = 'Toggles the Disable on any new script not indexed inside of Nemesis.';
2839 Perms = {'Scripter', 'Enforcer'};
2840 Args = {};
2841 Function = function(Player, Args, Msg)
2842 local Switch = System.ScriptsNotAllowed;
2843
2844 if Switch then
2845 System.ScriptsNotAllowed = false;
2846 else
2847 System.ScriptsNotAllowed = true;
2848 end;
2849 end;
2850 };
2851
2852-- New{
2853-- Name = {'NoTools', 'LockBackpack'};
2854-- Desc = 'Removes all of <Players> tools and makes it impossible for new ones to appear.';
2855-- Level = 3;
2856-- Hidden = false;
2857-- Args = {'Players'};
2858-- Function = function(Player, Args)
2859-- local Players = GetPlayers(Player, Args[1]);
2860--
2861-- for _, Pl in next, Players do
2862-- local Set = Storage[Pl.Name .. 'BackpackL'];
2863--
2864-- if Set then
2865-- Set:Disconnect();
2866-- Storage[Pl.Name .. 'BackpackL'] = nil;
2867-- Run('ColorNotify', Pl, {nil, 28, 'Your BackpackLock has been disabled.'});
2868-- else
2869-- Storage[Pl.Name .. 'BackpackL'] = Clear.Pconnect(Pl.DescendantAdded, function(Tool)
2870-- if Tool:IsA('BackpackItem') then
2871-- Clear.RunService.Stepped:wait();
2872--
2873-- Tool:Destroy();
2874-- end;
2875-- end);
2876--
2877-- for _, Tool in next, Clear.FindClass(Pl, 'BackpackItem', {}) do
2878-- Tool:Destroy();
2879-- end;
2880--
2881-- Run('ColorNotify', Pl, {nil, 1004, 'Your BackpackLock has been enabled.'});
2882-- end;
2883-- end;
2884-- end;
2885-- };
2886
2887 New{
2888 Names = {'Kidnap', 'Clown'};
2889 Desc = 'Send your enemies to the Clown hideout!';
2890 Perms = {'Trusted', 'Unversed'};
2891 Args = {'Players'};
2892 Function = function(Player, Args)
2893 local Kidnap = GetPlayers(Player, Args[1], true, true);
2894
2895 for _, Pl in next, Kidnap do
2896 if (Profiles.IsHigher(Player, Pl)) then
2897 Clear.TeleportService:Teleport(437965235, Pl);
2898 end;
2899 end;
2900 end;
2901 };
2902
2903-- New{
2904-- Name = {'Logs', 'AdminLogs'};
2905-- Desc = 'Shows the admin logs.';
2906-- Level = 5;
2907-- Hidden = false;
2908-- Args = {'Page'};
2909-- Function = function(Player, Args)
2910-- local Logs = Storage.Logs;
2911-- local Start = (Args[1] and tonumber(Args[1])) or math.ceil(#Logs/15);
2912-- local Page = Start - 1;
2913--
2914-- Run('Dismiss', Player, {});
2915--
2916-- for i = 1, 15 do
2917-- local Log = Logs[i + (Page * 15)];
2918--
2919-- if (not Log) then
2920-- break;
2921-- end;
2922--
2923-- Clear.NewSignal('Crystal', {
2924-- Name = 'AdminLog' .. Log.Time;
2925-- Desc = ('[%s, %s] %s'):format(Clear.FromUnixR(Log.Time), Log.Name, Log.Log);
2926-- Instruct = 'SRun: PlayerSettings ' .. Log.Name;
2927-- CF = Clear.TorsoCF(Player);
2928-- BColor = BrickColor.new(i/15, i/15, i/15);
2929-- Index = Player;
2930-- })
2931-- end;
2932--
2933-- if Logs[(Page * 15) - 1] then
2934-- Clear.NewSignal('Crystal', {
2935-- Name = 'LastLogPage';
2936-- Desc = 'Last Page';
2937-- Instruct = 'SRun: Logs ' .. Start - 1;
2938-- CF = Clear.TorsoCF(Player);
2939-- BColor = BrickColor.new(23);
2940-- Index = Player;
2941-- })
2942-- end;
2943--
2944-- if Logs[(Start * 15) + 1] then
2945-- Clear.NewSignal('Crystal', {
2946-- Name = 'NextLogPage';
2947-- Desc = 'Next Page';
2948-- Instruct = 'SRun: Logs ' .. Start + 1;
2949-- CF = Clear.TorsoCF(Player);
2950-- BColor = BrickColor.new(23);
2951-- Index = Player;
2952-- })
2953-- end;
2954-- end;
2955-- };
2956--
2957-- New{
2958-- Name = {'ChatLogs', 'ChatLogs'};
2959-- Desc = 'Shows the chat logs.';
2960-- Level = 5;
2961-- Hidden = false;
2962-- Args = {'Page'};
2963-- Function = function(Player, Args)
2964-- local Logs = Storage.Chatlogs;
2965-- local Start = (Args[1] and tonumber(Args[1])) or math.ceil(#Logs/15);
2966-- local Page = Start - 1;
2967--
2968-- Run('Dismiss', Player, {});
2969--
2970-- for i = 1, 15 do
2971-- local Log = Logs[i + (Page * 15)];
2972--
2973-- if (not Log) then
2974-- break;
2975-- end;
2976--
2977-- Clear.NewSignal('Crystal', {
2978-- Name = 'AdminLog' .. Log.Time;
2979-- Desc = ('[%s, %s] %s'):format(Clear.FromUnixR(Log.Time), Log.Name, Log.Log);
2980-- Instruct = 'SRun: PlayerSettings ' .. Log.Name;
2981-- CF = Clear.TorsoCF(Player);
2982-- BColor = BrickColor.new(i/15, i/15, i/15);
2983-- Index = Player;
2984-- })
2985-- end;
2986--
2987-- if Logs[(Page * 15) - 1] then
2988-- Clear.NewSignal('Crystal', {
2989-- Name = 'LastCLogPage';
2990-- Desc = 'Last Page';
2991-- Instruct = 'SRun: ChatLogs ' .. Start - 1;
2992-- CF = Clear.TorsoCF(Player);
2993-- BColor = BrickColor.new(23);
2994-- Index = Player;
2995-- })
2996-- end;
2997--
2998-- if Logs[(Start * 15) + 1] then
2999-- Clear.NewSignal('Crystal', {
3000-- Name = 'NextCLogPage';
3001-- Desc = 'Next Page';
3002-- Instruct = 'SRun: ChatLogs ' .. Start + 1;
3003-- CF = Clear.TorsoCF(Player);
3004-- BColor = BrickColor.new(23);
3005-- Index = Player;
3006-- })
3007-- end;
3008-- end;
3009-- };
3010
3011 New{
3012 Names = {'Repeat', 'Spam'};
3013 Desc = 'Repeats <Command> once every <Intervals> seconds <Amount> times.';
3014 Perms = {'Registered'};
3015 Args = {'Amount', 'Intervals', 'Command'};
3016 Function = function(Player, Args)
3017 local Amt, Int = Args[1], Args[2]
3018
3019 if (not Args[3]) then return nil end;
3020
3021 if (not Amt) or (tonumber(Amt) > 300) then
3022 Amt = 300;
3023 else
3024 Amt = tonumber(Amt);
3025 end
3026
3027 if (not Int) or (tonumber(Int) <= 0) then
3028 Int = 0.1;
3029 else
3030 Int = tonumber(Int);
3031 end
3032
3033 for i = 1, ((Amt > 1) and Amt) or 1 do
3034 Chatted(Player, Args[3]);
3035
3036 wait(Int);
3037 end;
3038 end;
3039 };
3040
3041 New{
3042 Names = {'Theme'};
3043 Desc = 'Sets the Admin theme.';
3044 Perms = {'Registered'};
3045 Args = {'Name'};
3046 Function = function(Player, Args, Msg)
3047 Clear.Assert(Themes[Args[1]], 'Invalid Theme name provided.');
3048 local Style = Args[1];
3049 local Profile = Profiles.Get(Player);
3050
3051 Profile.Theme = Style;
3052 Clear.Thread(Themes[Style], Player);
3053 end;
3054 };
3055
3056 New{
3057 Names = {'Themes'};
3058 Desc = 'List the Admin themes.';
3059 Perms = {'User'};
3060 Args = {};
3061 Function = function(Player, Args)
3062 Run(Player, 'Dismiss');
3063
3064 for Theme, Function in next, Themes do
3065 Notify(Player, Theme, nil, 'Fantasy', {'Command', Player, 'Theme', {Theme}})
3066 end;
3067 end;
3068 };
3069
3070 New{
3071 Names = {'NoDeath', 'Invincible'};
3072 Desc = 'Become god.';
3073 Perms = {'Unversed'};
3074 Args = {'Color'};
3075 Function = function(Player, Args)
3076 error'Should be obvious as to why this is here.';
3077 end;
3078 };
3079
3080 New{
3081 Names = {'Plugins'};
3082 Desc = 'List the plugins.';
3083 Perms = {'User'};
3084 Args = {};
3085 Function = function(Player, Args)
3086 Run(Player, 'Dismiss');
3087
3088 for _, Plugin in next, System.Dep'Plugins':GetChildren() do
3089 Notify(Player, Plugin.Name, nil, 'Fantasy', {'Command', Player, 'LoadPlugin', {Plugin.Name}});
3090 end;
3091 end;
3092 };
3093
3094 New{
3095 Names = {'LoadPlugin'};
3096 Desc = 'List the plugins.';
3097 Perms = {'Trusted'};
3098 Args = {'Plugin'};
3099 Function = function(Player, Args)
3100 local Module = System.Dep('Plugins', Args[1]);
3101
3102 if Module then
3103 local Ran;
3104
3105 Module.Parent = nil;
3106 Ran = require(Module)();
3107
3108 Notify(Player, tostring(Ran), nil, 'SciFi');
3109 else
3110 error('Could not load directory.', 0);
3111 end;
3112 end;
3113 };
3114
3115-- New{
3116-- Name = {'Visualize', 'Vis', 'Viz'};
3117-- Desc = 'Gives you a Visualizer to use music with.';
3118-- Level = 0;
3119-- Hidden = false;
3120-- Args = {};
3121-- Function = function(Player, Args, Msg)
3122-- if (typeof(Player) == 'Instance') and (Clear.ProcessRequest(8, {Class = 'Crystal', Index = Player, Name = 'Confirm', Desc = string.format('Click to run "%s"', Msg), BColor = BrickColor.new(24), Process = 'AcceptCommand'}) ~= 'AcceptCommand') then
3123-- return Run('ColorNotify', Player, {nil, 24, 'Command was not confirmed.'});
3124-- end;
3125-- local Backpack = Clear.FindFirstClass(Player, 'Backpack');
3126--
3127-- if Backpack and (not Backpack:FindFirstChild('NemesisViz')) then
3128-- local Viz = Clear.CliDep('Vis'):Clone();
3129--
3130-- Viz.Name = math.random() .. math.rad(math.random() * math.cos(tick()));
3131-- Viz.Parent = Backpack;
3132--
3133-- Run('ColorNotify', Player, {nil, BrickColor.Random().Number, 'You are now using NemesisViz.'});
3134-- elseif Backpack then
3135-- Run('ColorNotify', Player, {nil, 1004, 'NemesisViz is already running!'});
3136-- else
3137-- error('Nemesis could not find the proper Dep.');
3138-- end;
3139-- end;
3140-- };
3141--
3142-- New{
3143-- Name = {'Define', 'UrbanSearch'};
3144-- Desc = 'Gives you the Urban Dictionary definition of <WordOrPhrase>.';
3145-- Level = 4;
3146-- Hidden = false;
3147-- Args = {'WordOrPhrase'};
3148-- Function = function(Player, Args)
3149-- Clear.Assert(Args[1], 'No Term provided.')
3150--
3151-- local RequestSite = 'https://mashape-community-urban-dictionary.p.mashape.com/define';
3152--
3153-- local Response = Clear.JDecode(Clear.DoGet(RequestSite .. '?term=' .. Args[1], false, {
3154-- ['X-Mashape-Key'] = Clear.RerAuth.Mashape;
3155-- ['Accept'] = 'text/plain'
3156-- }))
3157--
3158-- Run('Dismiss', Player, {});
3159--
3160-- local Defs = Response.list;
3161--
3162-- Run('ColorNotify', Player, {nil, 28, 'Defining: ' .. Clear.BroadcastFilter(Args[1], Player)});
3163--
3164-- for i = 1, 4 do
3165-- local Def = Defs[i];
3166--
3167-- if Def then
3168-- local DefT = Clear.BroadcastFilter(Def.definition, Player);
3169--
3170-- Run('ColorNotify', Player, {nil, BrickColor.Random().Number, i .. ': ' .. DefT});
3171-- end;
3172-- end;
3173-- end;
3174-- };
3175--
3176-- New{
3177-- Name = {'Facts', 'Fact', 'Chuck', 'Norris'};
3178-- Desc = 'Forces <Players> to chat <Message>.';
3179-- Level = 4;
3180-- Hidden = false;
3181-- Args = {};
3182-- Function = function(Player, Args)
3183-- local RequestSite = 'https://matchilling-chuck-norris-jokes-v1.p.mashape.com/jokes/random';
3184--
3185-- local Response = Clear.JDecode(Clear.DoGet(RequestSite, false, {
3186-- ['X-Mashape-Key'] = Clear.RerAuth.Mashape;
3187-- ['accept'] = 'application/json'
3188-- }))
3189--
3190-- Run('Dismiss', Player, {});
3191--
3192-- local Fact = Response.value;
3193--
3194-- Run('ColorNotify', Player, {nil, 28, 'Random fact.'});
3195-- Run('ColorNotify', Player, {nil, 303, Fact});
3196-- end;
3197-- };
3198--
3199-- New{
3200-- Name = {'Clear'};
3201-- Desc = 'Removes admin created objects.';
3202-- Level = 5;
3203-- Hidden = false;
3204-- Args = {};
3205-- Function = function(Player, Args)
3206-- for _, Object in next, Clear.Variables.Objects do
3207-- if (not Object.Parent) or (not Object.Parent:FindFirstChildOfClass'Humanoid') then
3208-- pcall(function() Object.Parent = Clear.Workspace.Terrain end);
3209-- end;
3210-- end;
3211--
3212-- Clear.Processing:CollectGarbage();
3213-- end;
3214-- };
3215--
3216-- New{
3217-- Name = {'BinaryEncode', 'BEncode'};
3218-- Desc = 'Shows you <Phrase> encoded in binary.';
3219-- Level = 4;
3220-- Hidden = false;
3221-- Args = {'Phrase'};
3222-- Function = function(Player, Args)
3223-- Clear.Assert(Args[1], 'No Phrase provided.');
3224--
3225-- Run('ColorNotify', Player, {nil, BrickColor.Random().Number, Clear.BinaryEncode(Args[1])});
3226-- end;
3227-- };
3228--
3229-- New{
3230-- Name = {'BinaryDecode', 'BDecode'};
3231-- Desc = 'Shows you <Binary> decoded into letters.';
3232-- Level = 4;
3233-- Hidden = false;
3234-- Args = {'Binary'};
3235-- Function = function(Player, Args)
3236-- Clear.Assert(Args[1], 'No Binary provided.');
3237--
3238-- Run('ColorNotify', Player, {nil, BrickColor.Random().Number, Clear.BinaryDecode(Args[1])});
3239-- end;
3240-- };
3241
3242 New{
3243 Names = {'ForceChat', 'Chat'};
3244 Desc = 'Forces <Players> to chat <Message>.';
3245 Perms = {'Unversed', 'Enforcer'};
3246 Args = {'Players', 'Message'};
3247 Function = function(Player, Args)
3248 local Players = GetPlayers(Player, Args[1]);
3249
3250 for _, Pl in next, Players do
3251 if Profiles.IsHigher(Player, Pl) then
3252 Remote.Send(Pl, 'FChat', Args[2]);
3253 end;
3254 end;
3255 end;
3256 };
3257
3258 New{
3259 Names = {'Exploit', 'LocalRek'};
3260 Desc = 'Makes <Players> act like exploiters would.';
3261 Perms = {'Unversed'};
3262 Args = {'Players'};
3263 Function = function(Player, Args)
3264 for _, Pl in next, GetPlayers(Player, Args[1]) do
3265 Clear.LocalSource(Pl, [[
3266 local Back = game:GetService('Players').LocalPlayer:FindFirstChildOfClass'Backpack';
3267
3268 Instance.new('HopperBin', Back).Name = 'Delete';
3269 Instance.new('HopperBin', Back).Name = 'Move';
3270 Instance.new('HopperBin', Back).Name = 'Create';
3271 Instance.new('HopperBin', Back).Name = 'F3x';
3272
3273 for i = 1, 10 do
3274 Instance.new('Explosion', workspace);
3275 end;
3276
3277 for _, p in next, game:GetService('Players'):GetPlayers() do
3278 if p ~= game:GetService('Players').LocalPlayer then
3279 local k = (math.random(1, 3) == 1) and p.Character and p.Character:BreakJoints();
3280 end;
3281 end;
3282 ]]);
3283 end;
3284 end;
3285 };
3286
3287 Clear.Commands = {Run = Run, Chatted = Chatted, New = New, Notify = Notify};
3288end;]]></ProtectedString>
3289 <BinaryString name="Tags"></BinaryString>
3290 </Properties>
3291 </Item>
3292 <Item class="ModuleScript" referent="RBX4D20BE4541CD444FA7565059C72778FD">
3293 <Properties>
3294 <Content name="LinkedSource"><null></null></Content>
3295 <string name="Name">Themes</string>
3296 <string name="ScriptGuid">{0FCD9EAF-DB54-45B1-844A-49DAF736C33C}</string>
3297 <ProtectedString name="Source"><![CDATA[return function()
3298 local Clear = Clear;
3299 local Step = Clear.RunService.Stepped;
3300
3301 local System = Clear.WaitFor'System';
3302 local Profiles = Clear.WaitFor'Profiles';
3303
3304 local Constraints = {};
3305
3306 local AntiDel = Clear.HashSha256(System.ServerKey .. 'HashedAntiDelete');
3307 local Cross = System.Cross;
3308
3309 math.randomseed(tick());
3310
3311 local GetPlayerHash = Clear.Memoize(function(Id)
3312 return Clear.HashSha1(System.ServerKey .. Id);
3313 end);
3314
3315 Clear.PlayerHash = GetPlayerHash;
3316
3317 local function ClearLocal(Player)
3318 local Hash = GetPlayerHash[Player.UserId];
3319 local Prof = Profiles.Get(Player).Cache;
3320 local Stor = Prof.Theme;
3321
3322 if (not Stor) then
3323 Stor = {};
3324
3325 Prof.Theme = Stor;
3326 end
3327
3328 if Stor.IsRendering then
3329 return;
3330 end;
3331
3332 for i, Func in next, Stor do
3333 if (typeof(Func) == 'RBXScriptConnection') then
3334 Func:Disconnect();
3335 end;
3336
3337 Stor[i] = nil;
3338 end;
3339
3340 Stor.Hash = Hash;
3341
3342 return Stor;
3343 end;
3344
3345 function Constraints.Revolve(Player)
3346 local MyData = ClearLocal(Player);
3347
3348 if (not MyData) then return; end;
3349
3350 MyData.IsRendering = true;
3351
3352 local NewKey = (math.rad(math.random()) * math.random()) .. tick();
3353 local Step = Clear.RunService.Stepped;
3354
3355 MyData.Key = NewKey;
3356
3357 local Cache
3358 local OldUi
3359 local Torso
3360
3361 local function RefreshUI(Char)
3362 local OTheme = Char:FindFirstChild(MyData.Hash);
3363
3364 if OTheme and (OTheme ~= OldUi) then Cache = OTheme; OTheme.Parent = Clear.Workspace.Terrain; end;
3365
3366 Torso = Char:WaitForChild('HumanoidRootPart', 10) or Torso;
3367
3368 local NewUi = Clear.Create'Folder'{
3369 Parent = Char;
3370 Name = MyData.Hash;
3371 Archivable = false;
3372 };
3373
3374 System.Index(NewUi);
3375
3376 if Cache then
3377 OldUi = NewUi;
3378
3379 local O = Cache:FindFirstChild(AntiDel);
3380
3381 if O then O:Destroy() end;
3382 for _, Child in ipairs(Cache:GetChildren()) do
3383 Cross:Fire('IndexObject', Player, Child);
3384 end;
3385
3386 Step:wait();
3387
3388 Cache:Destroy();
3389 elseif OldUi then
3390 OldUi:Destroy();
3391
3392 OldUi = NewUi;
3393 else
3394 OldUi = NewUi;
3395 end;
3396
3397 Char:WaitForChild('Humanoid', 5);
3398
3399 wait();
3400 end;
3401
3402 MyData.Process = Clear.Pconnect(Cross.Event, function(isProcess, Pl, Object)
3403 while Player.Parent and ((not OldUi) or (not Torso)) do Step:wait(); end;
3404
3405 if (isProcess == 'IndexObject') and (Pl == Player) and Object then
3406 Object.Anchored = true;
3407 Object.Parent = OldUi;
3408 Object.CFrame = Torso.CFrame;
3409 elseif (isProcess == 'Clear') and (Pl == Player) then
3410 for _, Obj in ipairs(OldUi:GetChildren()) do
3411 Clear.Interpret(Obj, 'Dismiss');
3412 end;
3413 end;
3414 end);
3415
3416 RefreshUI(Player.Character or Player.CharacterAdded:wait());
3417 MyData.Respawn = Clear.Pconnect(Player.CharacterAdded, RefreshUI);
3418 MyData.Dying = Clear.Pconnect(Player.CharacterRemoving, function(Char)
3419 if OldUi then
3420 pcall(function()
3421 OldUi.Parent = Clear.Workspace.Terrain;
3422 Cache = OldUi;
3423 Clear.Create'StringValue'{Parent = OldUi, Name = AntiDel, Value = Clear.GetRandom()};
3424 end);
3425 end;
3426 end);
3427
3428 local RotP, Mul = 3600, 1;
3429 local It = 0;
3430 local CF, CA = CFrame.new, CFrame.Angles;
3431 local Lerp, Rad = CF().Lerp, math.rad;
3432 local Log10, Ce = math.log10, math.ceil;
3433
3434 Clear.Thread(function()
3435 if Player then
3436 while Player.Parent do
3437 if (MyData.Key ~= NewKey) then
3438 break;
3439 end;
3440
3441 local Child = OldUi:GetChildren();
3442 local CMax = #Child;
3443
3444 if (CMax ~= 0) then
3445 for i, Ch in ipairs(Child) do
3446 local LC, T = Ch.CFrame, Torso.Position;
3447
3448 local Dist = (T - LC.p).magnitude
3449 local DCal = (0.01 * Dist) + 0.005;
3450
3451 Ch.CFrame = Lerp(LC, CF(T) * CA(0, (Rad(360/CMax) * i) + (Rad(It) / 10), 0) * CF(4 + CMax/3.5, Log10(It + 1) / 10 * Mul, 0), (DCal < 1) and DCal or 1);
3452 end;
3453
3454 It = It + ((6.5 / CMax) * Mul);
3455
3456 if (It >= RotP) then
3457 It = RotP;
3458
3459 Mul = -1;
3460 elseif (It <= 0) then
3461 It = 0;
3462
3463 Mul = 1;
3464 end;
3465 end;
3466
3467 Step:wait();
3468 Step:wait();
3469 end;
3470
3471 if (not Player.Parent) then
3472 OldUi:Destroy();
3473 end;
3474 end;
3475 end);
3476
3477 MyData.IsRendering = false;
3478 end;
3479
3480 function Constraints.Galaxy(Player)
3481 local MyData = ClearLocal(Player);
3482
3483 if (not MyData) then return; end;
3484
3485 MyData.IsRendering = true;
3486
3487 local NewKey = (math.rad(math.random()) * math.random()) .. tick();
3488 local Step = Clear.RunService.Stepped;
3489
3490 MyData.Key = NewKey;
3491
3492 local Cache
3493 local OldUi
3494 local Torso
3495
3496 local function RefreshUI(Char)
3497 local OTheme = Char:FindFirstChild(MyData.Hash);
3498
3499 if OTheme and (OTheme ~= OldUi) then Cache = OTheme; OTheme.Parent = Clear.Workspace.Terrain; end;
3500
3501 Torso = Char:WaitForChild('HumanoidRootPart', 10) or Torso;
3502
3503 local NewUi = Clear.Create'Folder'{
3504 Parent = Char;
3505 Name = MyData.Hash;
3506 Archivable = false;
3507 };
3508
3509 System.Index(NewUi);
3510
3511 if Cache then
3512 OldUi = NewUi;
3513
3514 local O = Cache:FindFirstChild(AntiDel);
3515
3516 if O then O:Destroy() end;
3517 for _, Child in ipairs(Cache:GetChildren()) do
3518 Cross:Fire('IndexObject', Player, Child);
3519 end;
3520
3521 Step:wait();
3522
3523 Cache:Destroy();
3524 elseif OldUi then
3525 OldUi:Destroy();
3526
3527 OldUi = NewUi;
3528 else
3529 OldUi = NewUi;
3530 end;
3531
3532 Char:WaitForChild('Humanoid', 5);
3533 wait();
3534 end;
3535
3536 MyData.Process = Clear.Pconnect(Cross.Event, function(isProcess, Pl, Object)
3537 while Player.Parent and ((not OldUi) or (not Torso)) do Step:wait(); end;
3538
3539 if (isProcess == 'IndexObject') and (Pl == Player) and Object then
3540 Object.Anchored = true;
3541 Object.Parent = OldUi;
3542 Object.CFrame = Torso.CFrame;
3543 elseif (isProcess == 'Clear') and (Pl == Player) then
3544 for _, Obj in ipairs(OldUi:GetChildren()) do
3545 Clear.Interpret(Obj, 'Dismiss');
3546 end;
3547 end;
3548 end);
3549
3550 RefreshUI(Player.Character or Player.CharacterAdded:wait());
3551 MyData.Respawn = Clear.Pconnect(Player.CharacterAdded, RefreshUI);
3552 MyData.Dying = Clear.Pconnect(Player.CharacterRemoving, function(Char)
3553 if OldUi then
3554 pcall(function()
3555 OldUi.Parent = Clear.Workspace.Terrain;
3556 Cache = OldUi;
3557 Clear.Create'StringValue'{Parent = OldUi, Name = AntiDel, Value = Clear.GetRandom()};
3558 end);
3559 end;
3560 end);
3561
3562 local RotP, Mul = 3600, 1;
3563 local It = 0;
3564 local CF, CA = CFrame.new, CFrame.Angles;
3565 local Lerp, Rad = CF().Lerp, math.rad;
3566 local Log10, Ce = math.log10, math.ceil;
3567 local Bou = math.sin;
3568
3569 Clear.Thread(function()
3570 if Player then
3571 while Player.Parent do
3572 if (MyData.Key ~= NewKey) then
3573 break;
3574 end;
3575
3576 local Child = OldUi:GetChildren();
3577 local CMax = #Child;
3578
3579 if (CMax ~= 0) then
3580 for i, Ch in ipairs(Child) do
3581 local LC, T = Ch.CFrame, Torso.Position;
3582
3583 local Dist = (T - LC.p).magnitude
3584 local DCal = (0.01 * Dist) + 0.005;
3585
3586 Ch.CFrame = Lerp(LC, CF(T) * CA(0, Rad(It * i) / CMax, 0) * CF(0, 0, 4 + (i / 1.5)), (DCal < 1) and DCal or 1);
3587 end;
3588
3589 It = It + ((6.5 / CMax) * Mul);
3590
3591 if (It >= RotP) then
3592 It = RotP;
3593
3594 Mul = -1;
3595 elseif (It <= 0) then
3596 It = 0;
3597
3598 Mul = 1;
3599 end;
3600 end;
3601
3602 Step:wait();
3603 Step:wait();
3604 end;
3605
3606 if (not Player.Parent) then
3607 OldUi:Destroy();
3608 end;
3609 end;
3610 end);
3611
3612 MyData.IsRendering = false;
3613 end;
3614
3615 function Constraints.Bounce(Player)
3616 local MyData = ClearLocal(Player);
3617
3618 if (not MyData) then return; end;
3619
3620 MyData.IsRendering = true;
3621
3622 local NewKey = (math.rad(math.random()) * math.random()) .. tick();
3623 local Step = Clear.RunService.Stepped;
3624
3625 MyData.Key = NewKey;
3626
3627 local Cache
3628 local OldUi
3629 local Torso
3630
3631 local function RefreshUI(Char)
3632 local OTheme = Char:FindFirstChild(MyData.Hash);
3633
3634 if OTheme and (OTheme ~= OldUi) then Cache = OTheme; OTheme.Parent = Clear.Workspace.Terrain; end;
3635
3636 Torso = Char:WaitForChild('HumanoidRootPart', 10) or Torso;
3637
3638 local NewUi = Clear.Create'Folder'{
3639 Parent = Char;
3640 Name = MyData.Hash;
3641 Archivable = false;
3642 };
3643
3644 System.Index(NewUi);
3645
3646 if Cache then
3647 OldUi = NewUi;
3648
3649 local O = Cache:FindFirstChild(AntiDel);
3650
3651 if O then O:Destroy() end;
3652 for _, Child in ipairs(Cache:GetChildren()) do
3653 Cross:Fire('IndexObject', Player, Child);
3654 end;
3655
3656 Step:wait();
3657
3658 Cache:Destroy();
3659 elseif OldUi then
3660 OldUi:Destroy();
3661
3662 OldUi = NewUi;
3663 else
3664 OldUi = NewUi;
3665 end;
3666
3667 Char:WaitForChild('Humanoid', 5);
3668 wait();
3669 end;
3670
3671 MyData.Process = Clear.Pconnect(Cross.Event, function(isProcess, Pl, Object)
3672 while Player.Parent and ((not OldUi) or (not Torso)) do Step:wait(); end;
3673
3674 if (isProcess == 'IndexObject') and (Pl == Player) and Object then
3675 Object.Anchored = true;
3676 Object.Parent = OldUi;
3677 Object.CFrame = Torso.CFrame;
3678 elseif (isProcess == 'Clear') and (Pl == Player) then
3679 for _, Obj in ipairs(OldUi:GetChildren()) do
3680 Clear.Interpret(Obj, 'Dismiss');
3681 end;
3682 end;
3683 end);
3684
3685 RefreshUI(Player.Character or Player.CharacterAdded:wait());
3686 MyData.Respawn = Clear.Pconnect(Player.CharacterAdded, RefreshUI);
3687 MyData.Dying = Clear.Pconnect(Player.CharacterRemoving, function(Char)
3688 if OldUi then
3689 pcall(function()
3690 OldUi.Parent = Clear.Workspace.Terrain;
3691 Cache = OldUi;
3692 Clear.Create'StringValue'{Parent = OldUi, Name = AntiDel, Value = Clear.GetRandom()};
3693 end);
3694 end;
3695 end);
3696
3697 local RotP, Mul = 3600, 1;
3698 local It = 0;
3699 local CF, CA = CFrame.new, CFrame.Angles;
3700 local Lerp, Rad = CF().Lerp, math.rad;
3701 local Log10, Ce = math.log10, math.ceil;
3702 local Bou = math.sin;
3703
3704 Clear.Thread(function()
3705 if Player then
3706 while Player.Parent do
3707 if (MyData.Key ~= NewKey) then
3708 break;
3709 end;
3710
3711 local Child = OldUi:GetChildren();
3712 local CMax = #Child;
3713
3714 if (CMax ~= 0) then
3715 for i, Ch in ipairs(Child) do
3716 local LC, T = Ch.CFrame, Torso.Position;
3717
3718 local Dist = (T - LC.p).magnitude
3719 local DCal = (0.01 * Dist) + 0.005;
3720
3721 Ch.CFrame = Lerp(LC, CF(T) * CA(0, (Rad(360/CMax) * i) + (Rad(It) / 10), 0) * CF(4 + CMax/3.5, Bou(It + i) + (Log10(It + 1) / 10 * Mul), 0), (DCal < 1) and DCal or 1);
3722 end;
3723
3724 It = It + ((6.5 / CMax) * Mul);
3725
3726 if (It >= RotP) then
3727 It = RotP;
3728
3729 Mul = -1;
3730 elseif (It <= 0) then
3731 It = 0;
3732
3733 Mul = 1;
3734 end;
3735 end;
3736
3737 Step:wait();
3738 Step:wait();
3739 end;
3740
3741 if (not Player.Parent) then
3742 OldUi:Destroy();
3743 end;
3744 end;
3745 end);
3746
3747 MyData.IsRendering = false;
3748 end;
3749
3750 Clear.Themes = Constraints;
3751end;]]></ProtectedString>
3752 <BinaryString name="Tags"></BinaryString>
3753 </Properties>
3754 </Item>
3755 </Item>
3756 <Item class="Folder" referent="RBX15A387DEC6C04F7F9145222031CE4AE6">
3757 <Properties>
3758 <string name="Name">Deps</string>
3759 <BinaryString name="Tags"></BinaryString>
3760 </Properties>
3761 <Item class="ModuleScript" referent="RBX11D1F18BE27E455BAF97B4A621288166">
3762 <Properties>
3763 <Content name="LinkedSource"><null></null></Content>
3764 <string name="Name">CeleryClient</string>
3765 <string name="ScriptGuid">{E3FB1BDC-F2C5-4083-B022-437CD66FE1F0}</string>
3766 <ProtectedString name="Source"><![CDATA[return function(Remote)
3767 local setmetatable = setmetatable;
3768 local require = require;
3769 local math = math;
3770 local wait = wait;
3771 local string = string;
3772 local getfenv = getfenv;
3773 local pcall = pcall;
3774 local spawn = spawn;
3775 local CFrame = CFrame;
3776 local Instance = Instance;
3777 local workspace = workspace;
3778 local typeof = typeof;
3779 local type = type;
3780
3781 local Player = Remote.Player;
3782 local UIS = Remote.UserInputService;
3783 local ExecB = Remote.Construct'Send'.String'Execute';
3784 local ChatB = Remote.Construct'Send'.String'CChat';
3785 local LogB = Remote.Construct'Send'.String'CLog';
3786 local Shared = setmetatable({Player = Player}, {__index = function(This, That) local S = Remote[That] or {}; This[That] = S; return S; end, __metatable = 'Shared'});
3787 local Logs = setmetatable({}, {__mode = 'k', __metatable = 'Logs'});
3788 local CEvent, Spoof;
3789
3790 local LoadStr = require(script:WaitForChild('Loadstring', math.huge));
3791
3792 local HBeat = Remote.RunService.Heartbeat;
3793 local _Wait = HBeat.wait;
3794
3795 local QThread = Remote.QThread;
3796 local Create = Remote.DoCreate;
3797 local Lerp = function(a, b, c) return a + (b - a) * c; end;
3798 local Beat = function() return _Wait(HBeat); end;
3799 local Outp = function(Ran, Err) if (not Ran) then Remote.Output('Celery', Err); end; end;
3800 local Gsub = string.gsub;
3801 local Env = setmetatable({}, {__index = getfenv(), __metatable = 'Environment'});
3802
3803 local function RecurseGet(K, C, T)
3804 local Stor = T or {};
3805 local IsA = K.IsA;
3806 local Ch = K:GetChildren();
3807 local Cn = #Ch;
3808
3809 if (Cn ~= 0) then
3810 for Idx = 1, Cn do
3811 local This = Ch[Idx];
3812
3813 RecurseGet(This, C, Stor);
3814
3815 if IsA(This, C) then
3816 Stor[#Stor + 1] = This;
3817 end;
3818 end;
3819 end;
3820
3821 return Stor;
3822 end;
3823
3824 script:Destroy();
3825 script = nil;
3826
3827 Player.Chatted:Connect(function(Msg)
3828 ChatB.String(Msg, 2).End();
3829 end);
3830
3831 UIS.TextBoxFocused:Connect(function(Box)
3832 if Logs[Box] then return; end;
3833
3834 Logs[Box] = true;
3835
3836 pcall(function()
3837 Box.FocusLost:Connect(function(_, Input)
3838 local Text = Box.Text;
3839
3840 if Input and (Gsub(Text, '%s', '') ~= '') then
3841 LogB.String(Text, 2).End();
3842
3843 if (Input.KeyCode.Value == 13) then
3844 ExecB.String(Text, 2).Bool(Box.Name == 'CeleryBox', 3).End();
3845 end;
3846 end;
3847 end);
3848 end);
3849 end)
3850
3851 Outp(Remote.Thread('Chat', function()
3852 local ChatMain = Player:WaitForChild('PlayerScripts'):WaitForChild('ChatScript'):WaitForChild('ChatMain');
3853 CEvent = require(ChatMain).MessagePosted;
3854 Spoof = require(ChatMain:WaitForChild('MessageSender'));
3855 end):Resume());
3856
3857 Outp(Remote.Thread('ThemeLocal', function()
3858 local CSend = Remote.Construct'Send'.String'CCrystal';
3859 local Hash = Remote.Request'Hash';
3860 local Rend = {};
3861 local Select;
3862 local CUi;
3863
3864 while (not Hash) do wait(5); Hash = Remote.Request'Hash'; end;
3865
3866 local function Hitbox(Item)
3867 if Rend[Item] and ((not Item.Parent) or Item:FindFirstChild'Dismiss') then
3868 Rend[Item]:Destroy();
3869 Rend[Item] = nil;
3870
3871 return;
3872 elseif (not Item:IsA('BasePart')) or Rend[Item] then
3873 return;
3874 end;
3875
3876 local Orig = Item.Transparency;
3877
3878 spawn(function()
3879 local Text, Image = RecurseGet(Item, 'TextLabel'), RecurseGet(Item, 'ImageLabel');
3880 local Prop = 'Transparency';
3881
3882 Item.Changed:Connect(function(x)
3883 if (x == Prop) then
3884 local Tr = Item.Transparency;
3885 local M, N = (Tr - 0.1) - Orig / 2, (Tr + 0.7) - Orig / 2;
3886
3887 for Idx = 1, #Text do
3888 local Targ = Text[Idx];
3889
3890 Targ.TextTransparency = M;
3891 Targ.TextStrokeTransparency = N;
3892 end;
3893
3894 for Idx = 1, #Image do
3895 Image[Idx].ImageTransparency = Tr;
3896 end;
3897 end;
3898 end);
3899 end);
3900
3901 local H = Create'Part'{
3902 Size = Item.Size;
3903 CanCollide = false;
3904 Transparency = 1;
3905 Name = Item.Name .. '-Box';
3906 };
3907
3908 local C = Create'ClickDetector'{
3909 MaxActivationDistance = 300;
3910 Parent = H;
3911 };
3912
3913 H.Anchored = true;
3914 H.CFrame = Item.CFrame;
3915 H.Parent = CUi;
3916
3917 C.MouseHoverEnter:Connect(function()
3918 local Start = Item.Transparency;
3919
3920 Select = Item;
3921
3922 for i = 0, 20 do
3923 Item.Transparency = Lerp(Start, 0.5, i/20);
3924
3925 if (Select == Item) then
3926 Beat();
3927 else
3928 break;
3929 end;
3930 end;
3931
3932 while (Select == Item) do Beat() end;
3933
3934 local NewStart = Item.Transparency;
3935
3936 for i = 0, 20 do
3937 Item.Transparency = Lerp(NewStart, Orig, i/20);
3938
3939 if (Select ~= Item) then
3940 Beat();
3941 else
3942 break;
3943 end;
3944 end;
3945 end);
3946
3947 C.MouseHoverLeave:Connect(function()
3948 if (Select == Item) then
3949 Select = nil;
3950 end;
3951 end);
3952
3953 C.MouseClick:Connect(function()
3954 if Item:FindFirstChild('Dismiss') then return nil end;
3955
3956 CSend.Object(Item, 2).End();
3957 end);
3958
3959 Rend[Item] = H;
3960
3961 return H;
3962 end;
3963
3964 local function NewLocal()
3965 Beat();
3966
3967 local Loc = Instance.new'Folder';
3968 local Tr;
3969
3970 CUi = Loc;
3971
3972 Loc.Changed:Connect(function()
3973 if Tr then return; end;
3974
3975 if (Loc.Parent ~= workspace.CurrentCamera) then
3976 Tr = true;
3977
3978 NewLocal();
3979
3980 Beat();
3981 Loc:Destroy();
3982 end;
3983 end);
3984
3985 Loc.Parent = workspace.CurrentCamera;
3986 Loc.Name = Hash:reverse();
3987 end;
3988
3989 local function Handle(Char)
3990 local Display = Char:WaitForChild(Hash, 6);
3991
3992 if (not Display) then
3993 return;
3994 end;
3995
3996 Remote.Send'Refresh';
3997
3998 if Display then
3999 QThread(function()
4000 while Display and Display.Parent do
4001 local Child = Display:GetChildren();
4002 local CNum = #Child;
4003
4004 if (CNum ~= 0) then
4005 for Idx = 1, CNum do
4006 local Ch = Child[Idx];
4007 local N = Rend[Ch];
4008
4009 if N then
4010 N.CFrame = Ch.CFrame;
4011 end;
4012 end;
4013 end;
4014
4015 Beat();
4016 end
4017 end);
4018
4019 local Ch = Display:GetChildren();
4020 local Dest;
4021
4022 Display.ChildRemoved:Connect(Hitbox);
4023 Display.ChildAdded:Connect(Hitbox);
4024 Display.Changed:Connect(function()
4025 if (not Display:IsDescendantOf(workspace)) and (not Dest) then
4026 Dest = true;
4027 Display:Destroy();
4028
4029 Handle(Char);
4030 end;
4031 end);
4032
4033 for Idx = 1, #Ch do
4034 QThread(Hitbox, Ch[Idx]);
4035 end;
4036 end;
4037 end;
4038
4039 NewLocal();
4040 QThread(Handle, Player.Character or Player.CharacterAdded:wait());
4041 Player.CharacterAdded:Connect(Handle);
4042 end):Resume());
4043
4044 Remote.OnEvent:Connect(function(Data, ...)
4045 local Args = {...};
4046
4047 if (Data == 'FChat') and CEvent and Spoof then
4048 local Msg = Args[1];
4049
4050 CEvent:fire(Msg);
4051 Spoof:SayMessage(Msg, 'All');
4052 elseif (Data == 'RCode') and LoadStr then
4053 QThread(function()
4054 LoadStr(Args[1], Env)();
4055 end);
4056 elseif (Data == 'Load') then
4057 local Mod = Args[1];
4058
4059 if (typeof(Mod) == 'Instance') and Mod:IsA'ModuleScript' then
4060 local R = require(Mod);
4061
4062 if (type(R) == 'function') then
4063 QThread(R, Shared, Args[2]);
4064 end;
4065 end;
4066 end;
4067 end);
4068end;]]></ProtectedString>
4069 <BinaryString name="Tags"></BinaryString>
4070 </Properties>
4071 <Item class="ModuleScript" referent="RBX75AC3117964647F28E137323669B5A2E">
4072 <Properties>
4073 <Content name="LinkedSource"><null></null></Content>
4074 <string name="Name">Loadstring</string>
4075 <string name="ScriptGuid">{D7C6E6AD-120D-4432-A1D7-559E2E1598D8}</string>
4076 <ProtectedString name="Source"><![CDATA[--[[
4077 Credit to einsteinK.
4078 Credit to Stravant for LBI.
4079
4080 Credit to the creators of all the other modules used in this.
4081
4082 Sceleratis was here and decided modify some things.
4083
4084 einsteinK was here again to fix a bug in LBI for if-statements
4085--]]
4086
4087local This = script;
4088local pairs = pairs;
4089local require = require;
4090local error = error;
4091local pcall = pcall;
4092local setfenv = setfenv;
4093
4094script = nil;
4095
4096local waitDeps = {
4097 'LBI';
4098 'LuaK';
4099 'LuaP';
4100 'LuaU';
4101 'LuaX';
4102 'LuaY';
4103 'LuaZ';
4104}
4105
4106for i,v in pairs(waitDeps) do This:WaitForChild(v) end
4107
4108local luaX = require(This.LuaX)
4109local luaY = require(This.LuaY)
4110local luaZ = require(This.LuaZ)
4111local luaU = require(This.LuaU)
4112local lbi = require(This.LBI)
4113
4114luaX:init()
4115local LuaState = {}
4116
4117return function(str,env)
4118 local f,writer,buff,name
4119 local env = env --Ignoring env changes for now
4120 local name = (env.script and env.script:GetFullName())
4121 local ran,error = pcall(function()
4122 local zio = luaZ:init(luaZ:make_getS(str), nil)
4123 if not zio then return error() end
4124 local func = luaY:parser(LuaState, zio, nil, name or "- Synthex -")
4125 writer, buff = luaU:make_setS()
4126 luaU:dump(LuaState, func, writer, buff)
4127 f = lbi.load_bytecode(buff.data,env)
4128 setfenv(f,env) -- setfenving the returned function tends to not work correctly, will look into in future
4129 end)
4130
4131 if ran then
4132 return f,buff.data
4133 else
4134 return nil,error
4135 end
4136end]]></ProtectedString>
4137 <BinaryString name="Tags"></BinaryString>
4138 </Properties>
4139 <Item class="ModuleScript" referent="RBX559531C226A64E0A82B042AC56130F22">
4140 <Properties>
4141 <Content name="LinkedSource"><null></null></Content>
4142 <string name="Name">LuaZ</string>
4143 <string name="ScriptGuid">{CDEDAA33-5C47-457A-A2A3-D0430D4CD2E3}</string>
4144 <ProtectedString name="Source"><![CDATA[local string = string;
4145local require = require;
4146local type = type;
4147local next = next;
4148
4149--[[--------------------------------------------------------------------
4150
4151 lzio.lua
4152 Lua buffered streams in Lua
4153 This file is part of Yueliang.
4154
4155 Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net>
4156 The COPYRIGHT file describes the conditions
4157 under which this software may be distributed.
4158
4159 See the ChangeLog for more information.
4160
4161----------------------------------------------------------------------]]
4162
4163--[[--------------------------------------------------------------------
4164-- Notes:
4165-- * EOZ is implemented as a string, "EOZ"
4166-- * Format of z structure (ZIO)
4167-- z.n -- bytes still unread
4168-- z.p -- last read position position in buffer
4169-- z.reader -- chunk reader function
4170-- z.data -- additional data
4171-- * Current position, p, is now last read index instead of a pointer
4172--
4173-- Not implemented:
4174-- * luaZ_lookahead: used only in lapi.c:lua_load to detect binary chunk
4175-- * luaZ_read: used only in lundump.c:ezread to read +1 bytes
4176-- * luaZ_openspace: dropped; let Lua handle buffers as strings (used in
4177-- lundump.c:LoadString & lvm.c:luaV_concat)
4178-- * luaZ buffer macros: dropped; buffers are handled as strings
4179-- * lauxlib.c:getF reader implementation has an extraline flag to
4180-- skip over a shbang (#!) line, this is not implemented here
4181--
4182-- Added:
4183-- (both of the following are vaguely adapted from lauxlib.c)
4184-- * luaZ:make_getS: create Reader from a string
4185-- * luaZ:make_getF: create Reader that reads from a file
4186--
4187-- Changed in 5.1.x:
4188-- * Chunkreader renamed to Reader (ditto with Chunkwriter)
4189-- * Zio struct: no more name string, added Lua state for reader
4190-- (however, Yueliang readers do not require a Lua state)
4191----------------------------------------------------------------------]]
4192
4193local luaZ = {}
4194
4195------------------------------------------------------------------------
4196-- * reader() should return a string, or nil if nothing else to parse.
4197-- Additional data can be set only during stream initialization
4198-- * Readers are handled in lauxlib.c, see luaL_load(file|buffer|string)
4199-- * LUAL_BUFFERSIZE=BUFSIZ=512 in make_getF() (located in luaconf.h)
4200-- * Original Reader typedef:
4201-- const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
4202-- * This Lua chunk reader implementation:
4203-- returns string or nil, no arguments to function
4204------------------------------------------------------------------------
4205
4206------------------------------------------------------------------------
4207-- create a chunk reader from a source string
4208------------------------------------------------------------------------
4209function luaZ:make_getS(buff)
4210 local b = buff
4211 return function() -- chunk reader anonymous function here
4212 if not b then return nil end
4213 local data = b
4214 b = nil
4215 return data
4216 end
4217end
4218
4219------------------------------------------------------------------------
4220-- create a chunk reader from a source file
4221------------------------------------------------------------------------
4222--[[
4223function luaZ:make_getF(filename)
4224 local LUAL_BUFFERSIZE = 512
4225 local h = io.open(filename, "r")
4226 if not h then return nil end
4227 return function() -- chunk reader anonymous function here
4228 if not h or io.type(h) == "closed file" then return nil end
4229 local buff = h:read(LUAL_BUFFERSIZE)
4230 if not buff then h:close(); h = nil end
4231 return buff
4232 end
4233end
4234--]]
4235------------------------------------------------------------------------
4236-- creates a zio input stream
4237-- returns the ZIO structure, z
4238------------------------------------------------------------------------
4239function luaZ:init(reader, data, name)
4240 if not reader then return end
4241 local z = {}
4242 z.reader = reader
4243 z.data = data or ""
4244 z.name = name
4245 -- set up additional data for reading
4246 if not data or data == "" then z.n = 0 else z.n = #data end
4247 z.p = 0
4248 return z
4249end
4250
4251------------------------------------------------------------------------
4252-- fill up input buffer
4253------------------------------------------------------------------------
4254function luaZ:fill(z)
4255 local buff = z.reader()
4256 z.data = buff
4257 if not buff or buff == "" then return "EOZ" end
4258 z.n, z.p = #buff - 1, 1
4259 return string.sub(buff, 1, 1)
4260end
4261
4262------------------------------------------------------------------------
4263-- get next character from the input stream
4264-- * local n, p are used to optimize code generation
4265------------------------------------------------------------------------
4266function luaZ:zgetc(z)
4267 local n, p = z.n, z.p + 1
4268 if n > 0 then
4269 z.n, z.p = n - 1, p
4270 return string.sub(z.data, p, p)
4271 else
4272 return self:fill(z)
4273 end
4274end
4275
4276return luaZ]]></ProtectedString>
4277 <BinaryString name="Tags"></BinaryString>
4278 </Properties>
4279 </Item>
4280 <Item class="ModuleScript" referent="RBXE3603DC05AFE43B2910C6C91F51BD84D">
4281 <Properties>
4282 <Content name="LinkedSource"><null></null></Content>
4283 <string name="Name">LuaX</string>
4284 <string name="ScriptGuid">{D04D3A84-7F26-49EF-8965-7AD7585E7E8B}</string>
4285 <ProtectedString name="Source"><![CDATA[local next = next;
4286local string = string;
4287local tonumber = tonumber;
4288local error = error;
4289local require = require;
4290local table = table;
4291local type = type;
4292local assert = assert;
4293
4294--[[--------------------------------------------------------------------
4295
4296 llex.lua
4297 Lua lexical analyzer in Lua
4298 This file is part of Yueliang.
4299
4300 Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net>
4301 The COPYRIGHT file describes the conditions
4302 under which this software may be distributed.
4303
4304 See the ChangeLog for more information.
4305
4306----------------------------------------------------------------------]]
4307
4308--[[--------------------------------------------------------------------
4309-- Notes:
4310-- * intended to 'imitate' llex.c code; performance is not a concern
4311-- * tokens are strings; code structure largely retained
4312-- * deleted stuff (compared to llex.c) are noted, comments retained
4313-- * nextc() returns the currently read character to simplify coding
4314-- here; next() in llex.c does not return anything
4315-- * compatibility code is marked with "--#" comments
4316--
4317-- Added:
4318-- * luaX:chunkid (function luaO_chunkid from lobject.c)
4319-- * luaX:str2d (function luaO_str2d from lobject.c)
4320-- * luaX.LUA_QS used in luaX:lexerror (from luaconf.h)
4321-- * luaX.LUA_COMPAT_LSTR in luaX:read_long_string (from luaconf.h)
4322-- * luaX.MAX_INT used in luaX:inclinenumber (from llimits.h)
4323--
4324-- To use the lexer:
4325-- (1) luaX:init() to initialize the lexer
4326-- (2) luaX:setinput() to set the input stream to lex
4327-- (3) call luaX:next() or luaX:luaX:lookahead() to get tokens,
4328-- until "TK_EOS": luaX:next()
4329-- * since EOZ is returned as a string, be careful when regexp testing
4330--
4331-- Not implemented:
4332-- * luaX_newstring: not required by this Lua implementation
4333-- * buffer MAX_SIZET size limit (from llimits.h) test not implemented
4334-- in the interest of performance
4335-- * locale-aware number handling is largely redundant as Lua's
4336-- tonumber() function is already capable of this
4337--
4338-- Changed in 5.1.x:
4339-- * TK_NAME token order moved down
4340-- * string representation for TK_NAME, TK_NUMBER, TK_STRING changed
4341-- * token struct renamed to lower case (LS -> ls)
4342-- * LexState struct: removed nestlevel, added decpoint
4343-- * error message functions have been greatly simplified
4344-- * token2string renamed to luaX_tokens, exposed in llex.h
4345-- * lexer now handles all kinds of newlines, including CRLF
4346-- * shbang first line handling removed from luaX:setinput;
4347-- it is now done in lauxlib.c (luaL_loadfile)
4348-- * next(ls) macro renamed to nextc(ls) due to new luaX_next function
4349-- * EXTRABUFF and MAXNOCHECK removed due to lexer changes
4350-- * checkbuffer(ls, len) macro deleted
4351-- * luaX:read_numeral now has 3 support functions: luaX:trydecpoint,
4352-- luaX:buffreplace and (luaO_str2d from lobject.c) luaX:str2d
4353-- * luaX:read_numeral is now more promiscuous in slurping characters;
4354-- hexadecimal numbers was added, locale-aware decimal points too
4355-- * luaX:skip_sep is new; used by luaX:read_long_string
4356-- * luaX:read_long_string handles new-style long blocks, with some
4357-- optional compatibility code
4358-- * luaX:llex: parts changed to support new-style long blocks
4359-- * luaX:llex: readname functionality has been folded in
4360-- * luaX:llex: removed test for control characters
4361--
4362--------------------------------------------------------------------]]
4363
4364local luaZ = require(script.Parent.LuaZ)
4365
4366local luaX = {}
4367
4368-- FIRST_RESERVED is not required as tokens are manipulated as strings
4369-- TOKEN_LEN deleted; maximum length of a reserved word not needed
4370
4371------------------------------------------------------------------------
4372-- "ORDER RESERVED" deleted; enumeration in one place: luaX.RESERVED
4373------------------------------------------------------------------------
4374
4375-- terminal symbols denoted by reserved words: TK_AND to TK_WHILE
4376-- other terminal symbols: TK_NAME to TK_EOS
4377luaX.RESERVED = [[
4378TK_AND and
4379TK_BREAK break
4380TK_DO do
4381TK_ELSE else
4382TK_ELSEIF elseif
4383TK_END end
4384TK_FALSE false
4385TK_FOR for
4386TK_FUNCTION function
4387TK_IF if
4388TK_IN in
4389TK_LOCAL local
4390TK_NIL nil
4391TK_NOT not
4392TK_OR or
4393TK_REPEAT repeat
4394TK_RETURN return
4395TK_THEN then
4396TK_TRUE true
4397TK_UNTIL until
4398TK_WHILE while
4399TK_CONCAT ..
4400TK_DOTS ...
4401TK_EQ ==
4402TK_GE >=
4403TK_LE <=
4404TK_NE ~=
4405TK_NAME <name>
4406TK_NUMBER <number>
4407TK_STRING <string>
4408TK_EOS <eof>]]
4409
4410-- NUM_RESERVED is not required; number of reserved words
4411
4412--[[--------------------------------------------------------------------
4413-- Instead of passing seminfo, the Token struct (e.g. ls.t) is passed
4414-- so that lexer functions can use its table element, ls.t.seminfo
4415--
4416-- SemInfo (struct no longer needed, a mixed-type value is used)
4417--
4418-- Token (struct of ls.t and ls.lookahead):
4419-- token -- token symbol
4420-- seminfo -- semantics information
4421--
4422-- LexState (struct of ls; ls is initialized by luaX:setinput):
4423-- current -- current character (charint)
4424-- linenumber -- input line counter
4425-- lastline -- line of last token 'consumed'
4426-- t -- current token (table: struct Token)
4427-- lookahead -- look ahead token (table: struct Token)
4428-- fs -- 'FuncState' is private to the parser
4429-- L -- LuaState
4430-- z -- input stream
4431-- buff -- buffer for tokens
4432-- source -- current source name
4433-- decpoint -- locale decimal point
4434-- nestlevel -- level of nested non-terminals
4435----------------------------------------------------------------------]]
4436
4437-- luaX.tokens (was luaX_tokens) is now a hash; see luaX:init
4438
4439luaX.MAXSRC = 80
4440luaX.MAX_INT = 2147483645 -- constants from elsewhere (see above)
4441luaX.LUA_QS = "'%s'"
4442luaX.LUA_COMPAT_LSTR = 1
4443--luaX.MAX_SIZET = 4294967293
4444
4445------------------------------------------------------------------------
4446-- initialize lexer
4447-- * original luaX_init has code to create and register token strings
4448-- * luaX.tokens: TK_* -> token
4449-- * luaX.enums: token -> TK_* (used in luaX:llex)
4450------------------------------------------------------------------------
4451function luaX:init()
4452 local tokens, enums = {}, {}
4453 for v in string.gmatch(self.RESERVED, "[^\n]+") do
4454 local _, _, tok, str = string.find(v, "(%S+)%s+(%S+)")
4455 tokens[tok] = str
4456 enums[str] = tok
4457 end
4458 self.tokens = tokens
4459 self.enums = enums
4460end
4461
4462------------------------------------------------------------------------
4463-- returns a suitably-formatted chunk name or id
4464-- * from lobject.c, used in llex.c and ldebug.c
4465-- * the result, out, is returned (was first argument)
4466------------------------------------------------------------------------
4467function luaX:chunkid(source, bufflen)
4468 local out
4469 local first = string.sub(source, 1, 1)
4470 if first == "=" then
4471 out = string.sub(source, 2, bufflen) -- remove first char
4472 else -- out = "source", or "...source"
4473 if first == "@" then
4474 source = string.sub(source, 2) -- skip the '@'
4475 bufflen = bufflen - #" '...' "
4476 local l = #source
4477 out = ""
4478 if l > bufflen then
4479 source = string.sub(source, 1 + l - bufflen) -- get last part of file name
4480 out = out.."..."
4481 end
4482 out = out..source
4483 else -- out = [string "string"]
4484 local len = string.find(source, "[\n\r]") -- stop at first newline
4485 len = len and (len - 1) or #source
4486 bufflen = bufflen - #(" [string \"...\"] ")
4487 if len > bufflen then len = bufflen end
4488 out = "[string \""
4489 if len < #source then -- must truncate?
4490 out = out..string.sub(source, 1, len).."..."
4491 else
4492 out = out..source
4493 end
4494 out = out.."\"]"
4495 end
4496 end
4497 return out
4498end
4499
4500--[[--------------------------------------------------------------------
4501-- Support functions for lexer
4502-- * all lexer errors eventually reaches lexerror:
4503 syntaxerror -> lexerror
4504----------------------------------------------------------------------]]
4505
4506------------------------------------------------------------------------
4507-- look up token and return keyword if found (also called by parser)
4508------------------------------------------------------------------------
4509function luaX:token2str(ls, token)
4510 if string.sub(token, 1, 3) ~= "TK_" then
4511 if string.find(token, "%c") then
4512 return string.format("char(%d)", string.byte(token))
4513 end
4514 return token
4515 else
4516 end
4517 return self.tokens[token]
4518end
4519
4520------------------------------------------------------------------------
4521-- throws a lexer error
4522-- * txtToken has been made local to luaX:lexerror
4523-- * can't communicate LUA_ERRSYNTAX, so it is unimplemented
4524------------------------------------------------------------------------
4525function luaX:lexerror(ls, msg, token)
4526 local function txtToken(ls, token)
4527 if token == "TK_NAME" or
4528 token == "TK_STRING" or
4529 token == "TK_NUMBER" then
4530 return ls.buff
4531 else
4532 return self:token2str(ls, token)
4533 end
4534 end
4535 local buff = self:chunkid(ls.source, self.MAXSRC)
4536 local msg = string.format("%s:%d: %s", buff, ls.linenumber, msg)
4537 if token then
4538 msg = string.format("%s near "..self.LUA_QS, msg, txtToken(ls, token))
4539 end
4540 -- luaD_throw(ls->L, LUA_ERRSYNTAX)
4541 error(msg)
4542end
4543
4544------------------------------------------------------------------------
4545-- throws a syntax error (mainly called by parser)
4546-- * ls.t.token has to be set by the function calling luaX:llex
4547-- (see luaX:next and luaX:lookahead elsewhere in this file)
4548------------------------------------------------------------------------
4549function luaX:syntaxerror(ls, msg)
4550 self:lexerror(ls, msg, ls.t.token)
4551end
4552
4553------------------------------------------------------------------------
4554-- move on to next line
4555------------------------------------------------------------------------
4556function luaX:currIsNewline(ls)
4557 return ls.current == "\n" or ls.current == "\r"
4558end
4559
4560function luaX:inclinenumber(ls)
4561 local old = ls.current
4562 -- lua_assert(currIsNewline(ls))
4563 self:nextc(ls) -- skip '\n' or '\r'
4564 if self:currIsNewline(ls) and ls.current ~= old then
4565 self:nextc(ls) -- skip '\n\r' or '\r\n'
4566 end
4567 ls.linenumber = ls.linenumber + 1
4568 if ls.linenumber >= self.MAX_INT then
4569 self:syntaxerror(ls, "chunk has too many lines")
4570 end
4571end
4572
4573------------------------------------------------------------------------
4574-- initializes an input stream for lexing
4575-- * if ls (the lexer state) is passed as a table, then it is filled in,
4576-- otherwise it has to be retrieved as a return value
4577-- * LUA_MINBUFFER not used; buffer handling not required any more
4578------------------------------------------------------------------------
4579function luaX:setinput(L, ls, z, source)
4580 if not ls then ls = {} end -- create struct
4581 if not ls.lookahead then ls.lookahead = {} end
4582 if not ls.t then ls.t = {} end
4583 ls.decpoint = "."
4584 ls.L = L
4585 ls.lookahead.token = "TK_EOS" -- no look-ahead token
4586 ls.z = z
4587 ls.fs = nil
4588 ls.linenumber = 1
4589 ls.lastline = 1
4590 ls.source = source
4591 self:nextc(ls) -- read first char
4592end
4593
4594--[[--------------------------------------------------------------------
4595-- LEXICAL ANALYZER
4596----------------------------------------------------------------------]]
4597
4598------------------------------------------------------------------------
4599-- checks if current character read is found in the set 'set'
4600------------------------------------------------------------------------
4601function luaX:check_next(ls, set)
4602 if not string.find(set, ls.current, 1, 1) then
4603 return false
4604 end
4605 self:save_and_next(ls)
4606 return true
4607end
4608
4609------------------------------------------------------------------------
4610-- retrieve next token, checking the lookahead buffer if necessary
4611-- * note that the macro next(ls) in llex.c is now luaX:nextc
4612-- * utilized used in lparser.c (various places)
4613------------------------------------------------------------------------
4614function luaX:next(ls)
4615 ls.lastline = ls.linenumber
4616 if ls.lookahead.token ~= "TK_EOS" then -- is there a look-ahead token?
4617 -- this must be copy-by-value
4618 ls.t.seminfo = ls.lookahead.seminfo -- use this one
4619 ls.t.token = ls.lookahead.token
4620 ls.lookahead.token = "TK_EOS" -- and discharge it
4621 else
4622 ls.t.token = self:llex(ls, ls.t) -- read next token
4623 end
4624end
4625
4626------------------------------------------------------------------------
4627-- fill in the lookahead buffer
4628-- * utilized used in lparser.c:constructor
4629------------------------------------------------------------------------
4630function luaX:lookahead(ls)
4631 -- lua_assert(ls.lookahead.token == "TK_EOS")
4632 ls.lookahead.token = self:llex(ls, ls.lookahead)
4633end
4634
4635------------------------------------------------------------------------
4636-- gets the next character and returns it
4637-- * this is the next() macro in llex.c; see notes at the beginning
4638------------------------------------------------------------------------
4639function luaX:nextc(ls)
4640 local c = luaZ:zgetc(ls.z)
4641 ls.current = c
4642 return c
4643end
4644
4645------------------------------------------------------------------------
4646-- saves the given character into the token buffer
4647-- * buffer handling code removed, not used in this implementation
4648-- * test for maximum token buffer length not used, makes things faster
4649------------------------------------------------------------------------
4650
4651function luaX:save(ls, c)
4652 local buff = ls.buff
4653 -- if you want to use this, please uncomment luaX.MAX_SIZET further up
4654 --if #buff > self.MAX_SIZET then
4655 -- self:lexerror(ls, "lexical element too long")
4656 --end
4657 ls.buff = buff..c
4658end
4659
4660------------------------------------------------------------------------
4661-- save current character into token buffer, grabs next character
4662-- * like luaX:nextc, returns the character read for convenience
4663------------------------------------------------------------------------
4664function luaX:save_and_next(ls)
4665 self:save(ls, ls.current)
4666 return self:nextc(ls)
4667end
4668
4669------------------------------------------------------------------------
4670-- LUA_NUMBER
4671-- * luaX:read_numeral is the main lexer function to read a number
4672-- * luaX:str2d, luaX:buffreplace, luaX:trydecpoint are support functions
4673------------------------------------------------------------------------
4674
4675------------------------------------------------------------------------
4676-- string to number converter (was luaO_str2d from lobject.c)
4677-- * returns the number, nil if fails (originally returns a boolean)
4678-- * conversion function originally lua_str2number(s,p), a macro which
4679-- maps to the strtod() function by default (from luaconf.h)
4680------------------------------------------------------------------------
4681function luaX:str2d(s)
4682 local result = tonumber(s)
4683 if result then return result end
4684 -- conversion failed
4685 if string.lower(string.sub(s, 1, 2)) == "0x" then -- maybe an hexadecimal constant?
4686 result = tonumber(s, 16)
4687 if result then return result end -- most common case
4688 -- Was: invalid trailing characters?
4689 -- In C, this function then skips over trailing spaces.
4690 -- true is returned if nothing else is found except for spaces.
4691 -- If there is still something else, then it returns a false.
4692 -- All this is not necessary using Lua's tonumber.
4693 end
4694 return nil
4695end
4696
4697------------------------------------------------------------------------
4698-- single-character replacement, for locale-aware decimal points
4699------------------------------------------------------------------------
4700function luaX:buffreplace(ls, from, to)
4701 local result, buff = "", ls.buff
4702 for p = 1, #buff do
4703 local c = string.sub(buff, p, p)
4704 if c == from then c = to end
4705 result = result..c
4706 end
4707 ls.buff = result
4708end
4709
4710------------------------------------------------------------------------
4711-- Attempt to convert a number by translating '.' decimal points to
4712-- the decimal point character used by the current locale. This is not
4713-- needed in Yueliang as Lua's tonumber() is already locale-aware.
4714-- Instead, the code is here in case the user implements localeconv().
4715------------------------------------------------------------------------
4716function luaX:trydecpoint(ls, Token)
4717 -- format error: try to update decimal point separator
4718 local old = ls.decpoint
4719 -- translate the following to Lua if you implement localeconv():
4720 -- struct lconv *cv = localeconv();
4721 -- ls->decpoint = (cv ? cv->decimal_point[0] : '.');
4722 self:buffreplace(ls, old, ls.decpoint) -- try updated decimal separator
4723 local seminfo = self:str2d(ls.buff)
4724 Token.seminfo = seminfo
4725 if not seminfo then
4726 -- format error with correct decimal point: no more options
4727 self:buffreplace(ls, ls.decpoint, ".") -- undo change (for error message)
4728 self:lexerror(ls, "malformed number", "TK_NUMBER")
4729 end
4730end
4731
4732------------------------------------------------------------------------
4733-- main number conversion function
4734-- * "^%w$" needed in the scan in order to detect "EOZ"
4735------------------------------------------------------------------------
4736function luaX:read_numeral(ls, Token)
4737 -- lua_assert(string.find(ls.current, "%d"))
4738 repeat
4739 self:save_and_next(ls)
4740 until string.find(ls.current, "%D") and ls.current ~= "."
4741 if self:check_next(ls, "Ee") then -- 'E'?
4742 self:check_next(ls, "+-") -- optional exponent sign
4743 end
4744 while string.find(ls.current, "^%w$") or ls.current == "_" do
4745 self:save_and_next(ls)
4746 end
4747 self:buffreplace(ls, ".", ls.decpoint) -- follow locale for decimal point
4748 local seminfo = self:str2d(ls.buff)
4749 Token.seminfo = seminfo
4750 if not seminfo then -- format error?
4751 self:trydecpoint(ls, Token) -- try to update decimal point separator
4752 end
4753end
4754
4755------------------------------------------------------------------------
4756-- count separators ("=") in a long string delimiter
4757-- * used by luaX:read_long_string
4758------------------------------------------------------------------------
4759function luaX:skip_sep(ls)
4760 local count = 0
4761 local s = ls.current
4762 -- lua_assert(s == "[" or s == "]")
4763 self:save_and_next(ls)
4764 while ls.current == "=" do
4765 self:save_and_next(ls)
4766 count = count + 1
4767 end
4768 return (ls.current == s) and count or (-count) - 1
4769end
4770
4771------------------------------------------------------------------------
4772-- reads a long string or long comment
4773------------------------------------------------------------------------
4774function luaX:read_long_string(ls, Token, sep)
4775 local cont = 0
4776 self:save_and_next(ls) -- skip 2nd '['
4777 if self:currIsNewline(ls) then -- string starts with a newline?
4778 self:inclinenumber(ls) -- skip it
4779 end
4780 while true do
4781 local c = ls.current
4782 if c == "EOZ" then
4783 self:lexerror(ls, Token and "unfinished long string" or
4784 "unfinished long comment", "TK_EOS")
4785 elseif c == "[" then
4786 --# compatibility code start
4787 if self.LUA_COMPAT_LSTR then
4788 if self:skip_sep(ls) == sep then
4789 self:save_and_next(ls) -- skip 2nd '['
4790 cont = cont + 1
4791 --# compatibility code start
4792 if self.LUA_COMPAT_LSTR == 1 then
4793 if sep == 0 then
4794 self:lexerror(ls, "nesting of [[...]] is deprecated", "[")
4795 end
4796 end
4797 --# compatibility code end
4798 end
4799 end
4800 --# compatibility code end
4801 elseif c == "]" then
4802 if self:skip_sep(ls) == sep then
4803 self:save_and_next(ls) -- skip 2nd ']'
4804 --# compatibility code start
4805 if self.LUA_COMPAT_LSTR and self.LUA_COMPAT_LSTR == 2 then
4806 cont = cont - 1
4807 if sep == 0 and cont >= 0 then break end
4808 end
4809 --# compatibility code end
4810 break
4811 end
4812 elseif self:currIsNewline(ls) then
4813 self:save(ls, "\n")
4814 self:inclinenumber(ls)
4815 if not Token then ls.buff = "" end -- avoid wasting space
4816 else -- default
4817 if Token then
4818 self:save_and_next(ls)
4819 else
4820 self:nextc(ls)
4821 end
4822 end--if c
4823 end--while
4824 if Token then
4825 local p = 3 + sep
4826 Token.seminfo = string.sub(ls.buff, p, -p)
4827 end
4828end
4829
4830------------------------------------------------------------------------
4831-- reads a string
4832-- * has been restructured significantly compared to the original C code
4833------------------------------------------------------------------------
4834
4835function luaX:read_string(ls, del, Token)
4836 self:save_and_next(ls)
4837 while ls.current ~= del do
4838 local c = ls.current
4839 if c == "EOZ" then
4840 self:lexerror(ls, "unfinished string", "TK_EOS")
4841 elseif self:currIsNewline(ls) then
4842 self:lexerror(ls, "unfinished string", "TK_STRING")
4843 elseif c == "\\" then
4844 c = self:nextc(ls) -- do not save the '\'
4845 if self:currIsNewline(ls) then -- go through
4846 self:save(ls, "\n")
4847 self:inclinenumber(ls)
4848 elseif c ~= "EOZ" then -- will raise an error next loop
4849 -- escapes handling greatly simplified here:
4850 local i = string.find("abfnrtv", c, 1, 1)
4851 if i then
4852 self:save(ls, string.sub("\a\b\f\n\r\t\v", i, i))
4853 self:nextc(ls)
4854 elseif not string.find(c, "%d") then
4855 self:save_and_next(ls) -- handles \\, \", \', and \?
4856 else -- \xxx
4857 c, i = 0, 0
4858 repeat
4859 c = 10 * c + ls.current
4860 self:nextc(ls)
4861 i = i + 1
4862 until i >= 3 or not string.find(ls.current, "%d")
4863 if c > 255 then -- UCHAR_MAX
4864 self:lexerror(ls, "escape sequence too large", "TK_STRING")
4865 end
4866 self:save(ls, string.char(c))
4867 end
4868 end
4869 else
4870 self:save_and_next(ls)
4871 end--if c
4872 end--while
4873 self:save_and_next(ls) -- skip delimiter
4874 Token.seminfo = string.sub(ls.buff, 2, -2)
4875end
4876
4877------------------------------------------------------------------------
4878-- main lexer function
4879------------------------------------------------------------------------
4880function luaX:llex(ls, Token)
4881 ls.buff = ""
4882 while true do
4883 local c = ls.current
4884 ----------------------------------------------------------------
4885 if self:currIsNewline(ls) then
4886 self:inclinenumber(ls)
4887 ----------------------------------------------------------------
4888 elseif c == "-" then
4889 c = self:nextc(ls)
4890 if c ~= "-" then return "-" end
4891 -- else is a comment
4892 local sep = -1
4893 if self:nextc(ls) == '[' then
4894 sep = self:skip_sep(ls)
4895 ls.buff = "" -- 'skip_sep' may dirty the buffer
4896 end
4897 if sep >= 0 then
4898 self:read_long_string(ls, nil, sep) -- long comment
4899 ls.buff = ""
4900 else -- else short comment
4901 while not self:currIsNewline(ls) and ls.current ~= "EOZ" do
4902 self:nextc(ls)
4903 end
4904 end
4905 ----------------------------------------------------------------
4906 elseif c == "[" then
4907 local sep = self:skip_sep(ls)
4908 if sep >= 0 then
4909 self:read_long_string(ls, Token, sep)
4910 return "TK_STRING"
4911 elseif sep == -1 then
4912 return "["
4913 else
4914 self:lexerror(ls, "invalid long string delimiter", "TK_STRING")
4915 end
4916 ----------------------------------------------------------------
4917 elseif c == "=" then
4918 c = self:nextc(ls)
4919 if c ~= "=" then return "="
4920 else self:nextc(ls); return "TK_EQ" end
4921 ----------------------------------------------------------------
4922 elseif c == "<" then
4923 c = self:nextc(ls)
4924 if c ~= "=" then return "<"
4925 else self:nextc(ls); return "TK_LE" end
4926 ----------------------------------------------------------------
4927 elseif c == ">" then
4928 c = self:nextc(ls)
4929 if c ~= "=" then return ">"
4930 else self:nextc(ls); return "TK_GE" end
4931 ----------------------------------------------------------------
4932 elseif c == "~" then
4933 c = self:nextc(ls)
4934 if c ~= "=" then return "~"
4935 else self:nextc(ls); return "TK_NE" end
4936 ----------------------------------------------------------------
4937 elseif c == "\"" or c == "'" then
4938 self:read_string(ls, c, Token)
4939 return "TK_STRING"
4940 ----------------------------------------------------------------
4941 elseif c == "." then
4942 c = self:save_and_next(ls)
4943 if self:check_next(ls, ".") then
4944 if self:check_next(ls, ".") then
4945 return "TK_DOTS" -- ...
4946 else return "TK_CONCAT" -- ..
4947 end
4948 elseif not string.find(c, "%d") then
4949 return "."
4950 else
4951 self:read_numeral(ls, Token)
4952 return "TK_NUMBER"
4953 end
4954 ----------------------------------------------------------------
4955 elseif c == "EOZ" then
4956 return "TK_EOS"
4957 ----------------------------------------------------------------
4958 else -- default
4959 if string.find(c, "%s") then
4960 -- lua_assert(self:currIsNewline(ls))
4961 self:nextc(ls)
4962 elseif string.find(c, "%d") then
4963 self:read_numeral(ls, Token)
4964 return "TK_NUMBER"
4965 elseif string.find(c, "[_%a]") then
4966 -- identifier or reserved word
4967 repeat
4968 c = self:save_and_next(ls)
4969 until c == "EOZ" or not string.find(c, "[_%w]")
4970 local ts = ls.buff
4971 local tok = self.enums[ts]
4972 if tok then return tok end -- reserved word?
4973 Token.seminfo = ts
4974 return "TK_NAME"
4975 else
4976 self:nextc(ls)
4977 return c -- single-char tokens (+ - / ...)
4978 end
4979 ----------------------------------------------------------------
4980 end--if c
4981 end--while
4982end
4983
4984return luaX]]></ProtectedString>
4985 <BinaryString name="Tags"></BinaryString>
4986 </Properties>
4987 </Item>
4988 <Item class="ModuleScript" referent="RBX9AFF7C1D9CCD47239548CAE63D508840">
4989 <Properties>
4990 <Content name="LinkedSource"><null></null></Content>
4991 <string name="Name">LuaY</string>
4992 <string name="ScriptGuid">{6E7CC72D-8015-4A0D-8423-04291EEBE0A7}</string>
4993 <ProtectedString name="Source"><![CDATA[local assert = assert;
4994local error = error;
4995local type = type;
4996local next = next;
4997local table = table;
4998local require = require;
4999local string = string;
5000local math = math;
5001local debug = debug;
5002local pairs = pairs;
5003
5004--[[--------------------------------------------------------------------
5005
5006 lparser.lua
5007 Lua 5 parser in Lua
5008 This file is part of Yueliang.
5009
5010 Copyright (c) 2005-2007 Kein-Hong Man <khman@users.sf.net>
5011 The COPYRIGHT file describes the conditions
5012 under which this software may be distributed.
5013
5014 See the ChangeLog for more information.
5015
5016----------------------------------------------------------------------]]
5017
5018--[[--------------------------------------------------------------------
5019-- Notes:
5020-- * some unused C code that were not converted are kept as comments
5021-- * LUA_COMPAT_VARARG option changed into a comment block
5022-- * for value/size specific code added, look for 'NOTE: '
5023--
5024-- Not implemented:
5025-- * luaX_newstring not needed by this Lua implementation
5026-- * luaG_checkcode() in assert is not currently implemented
5027--
5028-- Added:
5029-- * some constants added from various header files
5030-- * luaY.LUA_QS used in error_expected, check_match (from luaconf.h)
5031-- * luaY:LUA_QL needed for error messages (from luaconf.h)
5032-- * luaY:growvector (from lmem.h) -- skeleton only, limit checking
5033-- * luaY.SHRT_MAX (from <limits.h>) for registerlocalvar
5034-- * luaY:newproto (from lfunc.c)
5035-- * luaY:int2fb (from lobject.c)
5036-- * NOTE: HASARG_MASK, for implementing a VARARG_HASARG bit operation
5037-- * NOTE: value-specific code for VARARG_NEEDSARG to replace a bitop
5038--
5039-- Changed in 5.1.x:
5040-- * various code changes are not detailed...
5041-- * names of constants may have changed, e.g. added a LUAI_ prefix
5042-- * struct expkind: added VKNUM, VVARARG; VCALL's info changed?
5043-- * struct expdesc: added nval
5044-- * struct FuncState: upvalues data type changed to upvaldesc
5045-- * macro hasmultret is new
5046-- * function checklimit moved to parser from lexer
5047-- * functions anchor_token, errorlimit, checknext are new
5048-- * checknext is new, equivalent to 5.0.x's check, see check too
5049-- * luaY:next and luaY:lookahead moved to lexer
5050-- * break keyword no longer skipped in luaY:breakstat
5051-- * function new_localvarstr replaced by new_localvarliteral
5052-- * registerlocalvar limits local variables to SHRT_MAX
5053-- * create_local deleted, new_localvarliteral used instead
5054-- * constant LUAI_MAXUPVALUES increased to 60
5055-- * constants MAXPARAMS, LUA_MAXPARSERLEVEL, MAXSTACK removed
5056-- * function interface changed: singlevaraux, singlevar
5057-- * enterlevel and leavelevel uses nCcalls to track call depth
5058-- * added a name argument to main entry function, luaY:parser
5059-- * function luaY_index changed to yindex
5060-- * luaY:int2fb()'s table size encoding format has been changed
5061-- * luaY:log2() no longer needed for table constructors
5062-- * function code_params deleted, functionality folded in parlist
5063-- * vararg flags handling (is_vararg) changes; also see VARARG_*
5064-- * LUA_COMPATUPSYNTAX section for old-style upvalues removed
5065-- * repeatstat() calls chunk() instead of block()
5066-- * function interface changed: cond, test_then_block
5067-- * while statement implementation considerably simplified; MAXEXPWHILE
5068-- and EXTRAEXP no longer required, no limits to the complexity of a
5069-- while condition
5070-- * repeat, forbody statement implementation has major changes,
5071-- mostly due to new scoping behaviour of local variables
5072-- * OPR_MULT renamed to OPR_MUL
5073----------------------------------------------------------------------]]
5074
5075--requires luaP, luaX, luaK
5076local luaY = {}
5077local luaX = require(script.Parent.LuaX)
5078local luaK = require(script.Parent.LuaK)(luaY)
5079local luaP = require(script.Parent.LuaP)
5080
5081--[[--------------------------------------------------------------------
5082-- Expression descriptor
5083-- * expkind changed to string constants; luaY:assignment was the only
5084-- function to use a relational operator with this enumeration
5085-- VVOID -- no value
5086-- VNIL -- no value
5087-- VTRUE -- no value
5088-- VFALSE -- no value
5089-- VK -- info = index of constant in 'k'
5090-- VKNUM -- nval = numerical value
5091-- VLOCAL -- info = local register
5092-- VUPVAL, -- info = index of upvalue in 'upvalues'
5093-- VGLOBAL -- info = index of table; aux = index of global name in 'k'
5094-- VINDEXED -- info = table register; aux = index register (or 'k')
5095-- VJMP -- info = instruction pc
5096-- VRELOCABLE -- info = instruction pc
5097-- VNONRELOC -- info = result register
5098-- VCALL -- info = instruction pc
5099-- VVARARG -- info = instruction pc
5100} ----------------------------------------------------------------------]]
5101
5102--[[--------------------------------------------------------------------
5103-- * expdesc in Lua 5.1.x has a union u and another struct s; this Lua
5104-- implementation ignores all instances of u and s usage
5105-- struct expdesc:
5106-- k -- (enum: expkind)
5107-- info, aux -- (int, int)
5108-- nval -- (lua_Number)
5109-- t -- patch list of 'exit when true'
5110-- f -- patch list of 'exit when false'
5111----------------------------------------------------------------------]]
5112
5113--[[--------------------------------------------------------------------
5114-- struct upvaldesc:
5115-- k -- (lu_byte)
5116-- info -- (lu_byte)
5117----------------------------------------------------------------------]]
5118
5119--[[--------------------------------------------------------------------
5120-- state needed to generate code for a given function
5121-- struct FuncState:
5122-- f -- current function header (table: Proto)
5123-- h -- table to find (and reuse) elements in 'k' (table: Table)
5124-- prev -- enclosing function (table: FuncState)
5125-- ls -- lexical state (table: LexState)
5126-- L -- copy of the Lua state (table: lua_State)
5127-- bl -- chain of current blocks (table: BlockCnt)
5128-- pc -- next position to code (equivalent to 'ncode')
5129-- lasttarget -- 'pc' of last 'jump target'
5130-- jpc -- list of pending jumps to 'pc'
5131-- freereg -- first free register
5132-- nk -- number of elements in 'k'
5133-- np -- number of elements in 'p'
5134-- nlocvars -- number of elements in 'locvars'
5135-- nactvar -- number of active local variables
5136-- upvalues[LUAI_MAXUPVALUES] -- upvalues (table: upvaldesc)
5137-- actvar[LUAI_MAXVARS] -- declared-variable stack
5138----------------------------------------------------------------------]]
5139
5140------------------------------------------------------------------------
5141-- constants used by parser
5142-- * picks up duplicate values from luaX if required
5143------------------------------------------------------------------------
5144
5145luaY.LUA_QS = luaX.LUA_QS or "'%s'" -- (from luaconf.h)
5146
5147luaY.SHRT_MAX = 32767 -- (from <limits.h>)
5148luaY.LUAI_MAXVARS = 200 -- (luaconf.h)
5149luaY.LUAI_MAXUPVALUES = 60 -- (luaconf.h)
5150luaY.MAX_INT = luaX.MAX_INT or 2147483645 -- (from llimits.h)
5151 -- * INT_MAX-2 for 32-bit systems
5152luaY.LUAI_MAXCCALLS = 200 -- (from luaconf.h)
5153
5154luaY.VARARG_HASARG = 1 -- (from lobject.h)
5155-- NOTE: HASARG_MASK is value-specific
5156luaY.HASARG_MASK = 2 -- this was added for a bitop in parlist()
5157luaY.VARARG_ISVARARG = 2
5158-- NOTE: there is some value-specific code that involves VARARG_NEEDSARG
5159luaY.VARARG_NEEDSARG = 4
5160
5161luaY.LUA_MULTRET = -1 -- (lua.h)
5162
5163--[[--------------------------------------------------------------------
5164-- other functions
5165----------------------------------------------------------------------]]
5166
5167------------------------------------------------------------------------
5168-- LUA_QL describes how error messages quote program elements.
5169-- CHANGE it if you want a different appearance. (from luaconf.h)
5170------------------------------------------------------------------------
5171function luaY:LUA_QL(x)
5172 return "'"..x.."'"
5173end
5174
5175------------------------------------------------------------------------
5176-- this is a stripped-down luaM_growvector (from lmem.h) which is a
5177-- macro based on luaM_growaux (in lmem.c); all the following does is
5178-- reproduce the size limit checking logic of the original function
5179-- so that error behaviour is identical; all arguments preserved for
5180-- convenience, even those which are unused
5181-- * set the t field to nil, since this originally does a sizeof(t)
5182-- * size (originally a pointer) is never updated, their final values
5183-- are set by luaY:close_func(), so overall things should still work
5184------------------------------------------------------------------------
5185function luaY:growvector(L, v, nelems, size, t, limit, e)
5186 if nelems >= limit then
5187 error(e) -- was luaG_runerror
5188 end
5189end
5190
5191------------------------------------------------------------------------
5192-- initialize a new function prototype structure (from lfunc.c)
5193-- * used only in open_func()
5194------------------------------------------------------------------------
5195function luaY:newproto(L)
5196 local f = {} -- Proto
5197 -- luaC_link(L, obj2gco(f), LUA_TPROTO); /* GC */
5198 f.k = {}
5199 f.sizek = 0
5200 f.p = {}
5201 f.sizep = 0
5202 f.code = {}
5203 f.sizecode = 0
5204 f.sizelineinfo = 0
5205 f.sizeupvalues = 0
5206 f.nups = 0
5207 f.upvalues = {}
5208 f.numparams = 0
5209 f.is_vararg = 0
5210 f.maxstacksize = 0
5211 f.lineinfo = {}
5212 f.sizelocvars = 0
5213 f.locvars = {}
5214 f.lineDefined = 0
5215 f.lastlinedefined = 0
5216 f.source = nil
5217 return f
5218end
5219
5220------------------------------------------------------------------------
5221-- converts an integer to a "floating point byte", represented as
5222-- (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
5223-- eeeee != 0 and (xxx) otherwise.
5224------------------------------------------------------------------------
5225function luaY:int2fb(x)
5226 local e = 0 -- exponent
5227 while x >= 16 do
5228 x = math.floor((x + 1) / 2)
5229 e = e + 1
5230 end
5231 if x < 8 then
5232 return x
5233 else
5234 return ((e + 1) * 8) + (x - 8)
5235 end
5236end
5237
5238--[[--------------------------------------------------------------------
5239-- parser functions
5240----------------------------------------------------------------------]]
5241
5242------------------------------------------------------------------------
5243-- true of the kind of expression produces multiple return values
5244------------------------------------------------------------------------
5245function luaY:hasmultret(k)
5246 return k == "VCALL" or k == "VVARARG"
5247end
5248
5249------------------------------------------------------------------------
5250-- convenience function to access active local i, returns entry
5251------------------------------------------------------------------------
5252function luaY:getlocvar(fs, i)
5253 return fs.f.locvars[ fs.actvar[i] ]
5254end
5255
5256------------------------------------------------------------------------
5257-- check a limit, string m provided as an error message
5258------------------------------------------------------------------------
5259function luaY:checklimit(fs, v, l, m)
5260 if v > l then self:errorlimit(fs, l, m) end
5261end
5262
5263--[[--------------------------------------------------------------------
5264-- nodes for block list (list of active blocks)
5265-- struct BlockCnt:
5266-- previous -- chain (table: BlockCnt)
5267-- breaklist -- list of jumps out of this loop
5268-- nactvar -- # active local variables outside the breakable structure
5269-- upval -- true if some variable in the block is an upvalue (boolean)
5270-- isbreakable -- true if 'block' is a loop (boolean)
5271----------------------------------------------------------------------]]
5272
5273------------------------------------------------------------------------
5274-- prototypes for recursive non-terminal functions
5275------------------------------------------------------------------------
5276-- prototypes deleted; not required in Lua
5277
5278------------------------------------------------------------------------
5279-- reanchor if last token is has a constant string, see close_func()
5280-- * used only in close_func()
5281------------------------------------------------------------------------
5282function luaY:anchor_token(ls)
5283 if ls.t.token == "TK_NAME" or ls.t.token == "TK_STRING" then
5284 -- not relevant to Lua implementation of parser
5285 -- local ts = ls.t.seminfo
5286 -- luaX_newstring(ls, getstr(ts), ts->tsv.len); /* C */
5287 end
5288end
5289
5290------------------------------------------------------------------------
5291-- throws a syntax error if token expected is not there
5292------------------------------------------------------------------------
5293function luaY:error_expected(ls, token)
5294 luaX:syntaxerror(ls,
5295 string.format(self.LUA_QS.." expected", luaX:token2str(ls, token)))
5296end
5297
5298------------------------------------------------------------------------
5299-- prepares error message for display, for limits exceeded
5300-- * used only in checklimit()
5301------------------------------------------------------------------------
5302function luaY:errorlimit(fs, limit, what)
5303 local msg = (fs.f.linedefined == 0) and
5304 string.format("main function has more than %d %s", limit, what) or
5305 string.format("function at line %d has more than %d %s",
5306 fs.f.linedefined, limit, what)
5307 luaX:lexerror(fs.ls, msg, 0)
5308end
5309
5310------------------------------------------------------------------------
5311-- tests for a token, returns outcome
5312-- * return value changed to boolean
5313------------------------------------------------------------------------
5314function luaY:testnext(ls, c)
5315 if ls.t.token == c then
5316 luaX:next(ls)
5317 return true
5318 else
5319 return false
5320 end
5321end
5322
5323------------------------------------------------------------------------
5324-- check for existence of a token, throws error if not found
5325------------------------------------------------------------------------
5326function luaY:check(ls, c)
5327 if ls.t.token ~= c then
5328 self:error_expected(ls, c)
5329 end
5330end
5331
5332------------------------------------------------------------------------
5333-- verify existence of a token, then skip it
5334------------------------------------------------------------------------
5335function luaY:checknext(ls, c)
5336 self:check(ls, c)
5337 luaX:next(ls)
5338end
5339
5340------------------------------------------------------------------------
5341-- throws error if condition not matched
5342------------------------------------------------------------------------
5343function luaY:check_condition(ls, c, msg)
5344 if not c then luaX:syntaxerror(ls, msg) end
5345end
5346
5347------------------------------------------------------------------------
5348-- verifies token conditions are met or else throw error
5349------------------------------------------------------------------------
5350function luaY:check_match(ls, what, who, where)
5351 if not self:testnext(ls, what) then
5352 if where == ls.linenumber then
5353 self:error_expected(ls, what)
5354 else
5355 luaX:syntaxerror(ls, string.format(
5356 self.LUA_QS.." expected (to close "..self.LUA_QS.." at line %d)",
5357 luaX:token2str(ls, what), luaX:token2str(ls, who), where))
5358 end
5359 end
5360end
5361
5362------------------------------------------------------------------------
5363-- expect that token is a name, return the name
5364------------------------------------------------------------------------
5365function luaY:str_checkname(ls)
5366 self:check(ls, "TK_NAME")
5367 local ts = ls.t.seminfo
5368 luaX:next(ls)
5369 return ts
5370end
5371
5372------------------------------------------------------------------------
5373-- initialize a struct expdesc, expression description data structure
5374------------------------------------------------------------------------
5375function luaY:init_exp(e, k, i)
5376 e.f, e.t = luaK.NO_JUMP, luaK.NO_JUMP
5377 e.k = k
5378 e.info = i
5379end
5380
5381------------------------------------------------------------------------
5382-- adds given string s in string pool, sets e as VK
5383------------------------------------------------------------------------
5384function luaY:codestring(ls, e, s)
5385 self:init_exp(e, "VK", luaK:stringK(ls.fs, s))
5386end
5387
5388------------------------------------------------------------------------
5389-- consume a name token, adds it to string pool, sets e as VK
5390------------------------------------------------------------------------
5391function luaY:checkname(ls, e)
5392 self:codestring(ls, e, self:str_checkname(ls))
5393end
5394
5395------------------------------------------------------------------------
5396-- creates struct entry for a local variable
5397-- * used only in new_localvar()
5398------------------------------------------------------------------------
5399function luaY:registerlocalvar(ls, varname)
5400 local fs = ls.fs
5401 local f = fs.f
5402 self:growvector(ls.L, f.locvars, fs.nlocvars, f.sizelocvars,
5403 nil, self.SHRT_MAX, "too many local variables")
5404 -- loop to initialize empty f.locvar positions not required
5405 f.locvars[fs.nlocvars] = {} -- LocVar
5406 f.locvars[fs.nlocvars].varname = varname
5407 -- luaC_objbarrier(ls.L, f, varname) /* GC */
5408 local nlocvars = fs.nlocvars
5409 fs.nlocvars = fs.nlocvars + 1
5410 return nlocvars
5411end
5412
5413------------------------------------------------------------------------
5414-- creates a new local variable given a name and an offset from nactvar
5415-- * used in fornum(), forlist(), parlist(), body()
5416------------------------------------------------------------------------
5417function luaY:new_localvarliteral(ls, v, n)
5418 self:new_localvar(ls, v, n)
5419end
5420
5421------------------------------------------------------------------------
5422-- register a local variable, set in active variable list
5423------------------------------------------------------------------------
5424function luaY:new_localvar(ls, name, n)
5425 local fs = ls.fs
5426 self:checklimit(fs, fs.nactvar + n + 1, self.LUAI_MAXVARS, "local variables")
5427 fs.actvar[fs.nactvar + n] = self:registerlocalvar(ls, name)
5428end
5429
5430------------------------------------------------------------------------
5431-- adds nvars number of new local variables, set debug information
5432------------------------------------------------------------------------
5433function luaY:adjustlocalvars(ls, nvars)
5434 local fs = ls.fs
5435 fs.nactvar = fs.nactvar + nvars
5436 for i = nvars, 1, -1 do
5437 self:getlocvar(fs, fs.nactvar - i).startpc = fs.pc
5438 end
5439end
5440
5441------------------------------------------------------------------------
5442-- removes a number of locals, set debug information
5443------------------------------------------------------------------------
5444function luaY:removevars(ls, tolevel)
5445 local fs = ls.fs
5446 while fs.nactvar > tolevel do
5447 fs.nactvar = fs.nactvar - 1
5448 self:getlocvar(fs, fs.nactvar).endpc = fs.pc
5449 end
5450end
5451
5452------------------------------------------------------------------------
5453-- returns an existing upvalue index based on the given name, or
5454-- creates a new upvalue struct entry and returns the new index
5455-- * used only in singlevaraux()
5456------------------------------------------------------------------------
5457function luaY:indexupvalue(fs, name, v)
5458 local f = fs.f
5459 for i = 0, f.nups - 1 do
5460 if fs.upvalues[i].k == v.k and fs.upvalues[i].info == v.info then
5461 assert(f.upvalues[i] == name)
5462 return i
5463 end
5464 end
5465 -- new one
5466 self:checklimit(fs, f.nups + 1, self.LUAI_MAXUPVALUES, "upvalues")
5467 self:growvector(fs.L, f.upvalues, f.nups, f.sizeupvalues,
5468 nil, self.MAX_INT, "")
5469 -- loop to initialize empty f.upvalues positions not required
5470 f.upvalues[f.nups] = name
5471 -- luaC_objbarrier(fs->L, f, name); /* GC */
5472 assert(v.k == "VLOCAL" or v.k == "VUPVAL")
5473 -- this is a partial copy; only k & info fields used
5474 fs.upvalues[f.nups] = { k = v.k, info = v.info }
5475 local nups = f.nups
5476 f.nups = f.nups + 1
5477 return nups
5478end
5479
5480------------------------------------------------------------------------
5481-- search the local variable namespace of the given fs for a match
5482-- * used only in singlevaraux()
5483------------------------------------------------------------------------
5484function luaY:searchvar(fs, n)
5485 for i = fs.nactvar - 1, 0, -1 do
5486 if n == self:getlocvar(fs, i).varname then
5487 return i
5488 end
5489 end
5490 return -1 -- not found
5491end
5492
5493------------------------------------------------------------------------
5494-- * mark upvalue flags in function states up to a given level
5495-- * used only in singlevaraux()
5496------------------------------------------------------------------------
5497function luaY:markupval(fs, level)
5498 local bl = fs.bl
5499 while bl and bl.nactvar > level do bl = bl.previous end
5500 if bl then bl.upval = true end
5501end
5502
5503------------------------------------------------------------------------
5504-- handle locals, globals and upvalues and related processing
5505-- * search mechanism is recursive, calls itself to search parents
5506-- * used only in singlevar()
5507------------------------------------------------------------------------
5508function luaY:singlevaraux(fs, n, var, base)
5509 if fs == nil then -- no more levels?
5510 self:init_exp(var, "VGLOBAL", luaP.NO_REG) -- default is global variable
5511 return "VGLOBAL"
5512 else
5513 local v = self:searchvar(fs, n) -- look up at current level
5514 if v >= 0 then
5515 self:init_exp(var, "VLOCAL", v)
5516 if base == 0 then
5517 self:markupval(fs, v) -- local will be used as an upval
5518 end
5519 return "VLOCAL"
5520 else -- not found at current level; try upper one
5521 if self:singlevaraux(fs.prev, n, var, 0) == "VGLOBAL" then
5522 return "VGLOBAL"
5523 end
5524 var.info = self:indexupvalue(fs, n, var) -- else was LOCAL or UPVAL
5525 var.k = "VUPVAL" -- upvalue in this level
5526 return "VUPVAL"
5527 end--if v
5528 end--if fs
5529end
5530
5531------------------------------------------------------------------------
5532-- consume a name token, creates a variable (global|local|upvalue)
5533-- * used in prefixexp(), funcname()
5534------------------------------------------------------------------------
5535function luaY:singlevar(ls, var)
5536 local varname = self:str_checkname(ls)
5537 local fs = ls.fs
5538 if self:singlevaraux(fs, varname, var, 1) == "VGLOBAL" then
5539 var.info = luaK:stringK(fs, varname) -- info points to global name
5540 end
5541end
5542
5543------------------------------------------------------------------------
5544-- adjust RHS to match LHS in an assignment
5545-- * used in assignment(), forlist(), localstat()
5546------------------------------------------------------------------------
5547function luaY:adjust_assign(ls, nvars, nexps, e)
5548 local fs = ls.fs
5549 local extra = nvars - nexps
5550 if self:hasmultret(e.k) then
5551 extra = extra + 1 -- includes call itself
5552 if extra <= 0 then extra = 0 end
5553 luaK:setreturns(fs, e, extra) -- last exp. provides the difference
5554 if extra > 1 then luaK:reserveregs(fs, extra - 1) end
5555 else
5556 if e.k ~= "VVOID" then luaK:exp2nextreg(fs, e) end -- close last expression
5557 if extra > 0 then
5558 local reg = fs.freereg
5559 luaK:reserveregs(fs, extra)
5560 luaK:_nil(fs, reg, extra)
5561 end
5562 end
5563end
5564
5565------------------------------------------------------------------------
5566-- tracks and limits parsing depth, assert check at end of parsing
5567------------------------------------------------------------------------
5568function luaY:enterlevel(ls)
5569 ls.L.nCcalls = ls.L.nCcalls + 1
5570 if ls.L.nCcalls > self.LUAI_MAXCCALLS then
5571 luaX:lexerror(ls, "chunk has too many syntax levels", 0)
5572 end
5573end
5574
5575------------------------------------------------------------------------
5576-- tracks parsing depth, a pair with luaY:enterlevel()
5577------------------------------------------------------------------------
5578function luaY:leavelevel(ls)
5579 ls.L.nCcalls = ls.L.nCcalls - 1
5580end
5581
5582------------------------------------------------------------------------
5583-- enters a code unit, initializes elements
5584------------------------------------------------------------------------
5585function luaY:enterblock(fs, bl, isbreakable)
5586 bl.breaklist = luaK.NO_JUMP
5587 bl.isbreakable = isbreakable
5588 bl.nactvar = fs.nactvar
5589 bl.upval = false
5590 bl.previous = fs.bl
5591 fs.bl = bl
5592 assert(fs.freereg == fs.nactvar)
5593end
5594
5595------------------------------------------------------------------------
5596-- leaves a code unit, close any upvalues
5597------------------------------------------------------------------------
5598function luaY:leaveblock(fs)
5599 local bl = fs.bl
5600 fs.bl = bl.previous
5601 self:removevars(fs.ls, bl.nactvar)
5602 if bl.upval then
5603 luaK:codeABC(fs, "OP_CLOSE", bl.nactvar, 0, 0)
5604 end
5605 -- a block either controls scope or breaks (never both)
5606 assert(not bl.isbreakable or not bl.upval)
5607 assert(bl.nactvar == fs.nactvar)
5608 fs.freereg = fs.nactvar -- free registers
5609 luaK:patchtohere(fs, bl.breaklist)
5610end
5611
5612------------------------------------------------------------------------
5613-- implement the instantiation of a function prototype, append list of
5614-- upvalues after the instantiation instruction
5615-- * used only in body()
5616------------------------------------------------------------------------
5617function luaY:pushclosure(ls, func, v)
5618 local fs = ls.fs
5619 local f = fs.f
5620 self:growvector(ls.L, f.p, fs.np, f.sizep, nil,
5621 luaP.MAXARG_Bx, "constant table overflow")
5622 -- loop to initialize empty f.p positions not required
5623 f.p[fs.np] = func.f
5624 fs.np = fs.np + 1
5625 -- luaC_objbarrier(ls->L, f, func->f); /* C */
5626 self:init_exp(v, "VRELOCABLE", luaK:codeABx(fs, "OP_CLOSURE", 0, fs.np - 1))
5627 for i = 0, func.f.nups - 1 do
5628 local o = (func.upvalues[i].k == "VLOCAL") and "OP_MOVE" or "OP_GETUPVAL"
5629 luaK:codeABC(fs, o, 0, func.upvalues[i].info, 0)
5630 end
5631end
5632
5633------------------------------------------------------------------------
5634-- opening of a function
5635------------------------------------------------------------------------
5636function luaY:open_func(ls, fs)
5637 local L = ls.L
5638 local f = self:newproto(ls.L)
5639 fs.f = f
5640 fs.prev = ls.fs -- linked list of funcstates
5641 fs.ls = ls
5642 fs.L = L
5643 ls.fs = fs
5644 fs.pc = 0
5645 fs.lasttarget = -1
5646 fs.jpc = luaK.NO_JUMP
5647 fs.freereg = 0
5648 fs.nk = 0
5649 fs.np = 0
5650 fs.nlocvars = 0
5651 fs.nactvar = 0
5652 fs.bl = nil
5653 f.source = ls.source
5654 f.maxstacksize = 2 -- registers 0/1 are always valid
5655 fs.h = {} -- constant table; was luaH_new call
5656 -- anchor table of constants and prototype (to avoid being collected)
5657 -- sethvalue2s(L, L->top, fs->h); incr_top(L); /* C */
5658 -- setptvalue2s(L, L->top, f); incr_top(L);
5659end
5660
5661------------------------------------------------------------------------
5662-- closing of a function
5663------------------------------------------------------------------------
5664function luaY:close_func(ls)
5665 local L = ls.L
5666 local fs = ls.fs
5667 local f = fs.f
5668 self:removevars(ls, 0)
5669 luaK:ret(fs, 0, 0) -- final return
5670 -- luaM_reallocvector deleted for f->code, f->lineinfo, f->k, f->p,
5671 -- f->locvars, f->upvalues; not required for Lua table arrays
5672 f.sizecode = fs.pc
5673 f.sizelineinfo = fs.pc
5674 f.sizek = fs.nk
5675 f.sizep = fs.np
5676 f.sizelocvars = fs.nlocvars
5677 f.sizeupvalues = f.nups
5678 --assert(luaG_checkcode(f)) -- currently not implemented
5679 assert(fs.bl == nil)
5680 ls.fs = fs.prev
5681 -- the following is not required for this implementation; kept here
5682 -- for completeness
5683 -- L->top -= 2; /* remove table and prototype from the stack */
5684 -- last token read was anchored in defunct function; must reanchor it
5685 if fs then self:anchor_token(ls) end
5686end
5687
5688------------------------------------------------------------------------
5689-- parser initialization function
5690-- * note additional sub-tables needed for LexState, FuncState
5691------------------------------------------------------------------------
5692function luaY:parser(L, z, buff, name)
5693 local lexstate = {} -- LexState
5694 lexstate.t = {}
5695 lexstate.lookahead = {}
5696 local funcstate = {} -- FuncState
5697 funcstate.upvalues = {}
5698 funcstate.actvar = {}
5699 -- the following nCcalls initialization added for convenience
5700 L.nCcalls = 0
5701 lexstate.buff = buff
5702 luaX:setinput(L, lexstate, z, name)
5703 self:open_func(lexstate, funcstate)
5704 funcstate.f.is_vararg = self.VARARG_ISVARARG -- main func. is always vararg
5705 luaX:next(lexstate) -- read first token
5706 self:chunk(lexstate)
5707 self:check(lexstate, "TK_EOS")
5708 self:close_func(lexstate)
5709 assert(funcstate.prev == nil)
5710 assert(funcstate.f.nups == 0)
5711 assert(lexstate.fs == nil)
5712 return funcstate.f
5713end
5714
5715--[[--------------------------------------------------------------------
5716-- GRAMMAR RULES
5717----------------------------------------------------------------------]]
5718
5719------------------------------------------------------------------------
5720-- parse a function name suffix, for function call specifications
5721-- * used in primaryexp(), funcname()
5722------------------------------------------------------------------------
5723function luaY:field(ls, v)
5724 -- field -> ['.' | ':'] NAME
5725 local fs = ls.fs
5726 local key = {} -- expdesc
5727 luaK:exp2anyreg(fs, v)
5728 luaX:next(ls) -- skip the dot or colon
5729 self:checkname(ls, key)
5730 luaK:indexed(fs, v, key)
5731end
5732
5733------------------------------------------------------------------------
5734-- parse a table indexing suffix, for constructors, expressions
5735-- * used in recfield(), primaryexp()
5736------------------------------------------------------------------------
5737function luaY:yindex(ls, v)
5738 -- index -> '[' expr ']'
5739 luaX:next(ls) -- skip the '['
5740 self:expr(ls, v)
5741 luaK:exp2val(ls.fs, v)
5742 self:checknext(ls, "]")
5743end
5744
5745--[[--------------------------------------------------------------------
5746-- Rules for Constructors
5747----------------------------------------------------------------------]]
5748
5749--[[--------------------------------------------------------------------
5750-- struct ConsControl:
5751-- v -- last list item read (table: struct expdesc)
5752-- t -- table descriptor (table: struct expdesc)
5753-- nh -- total number of 'record' elements
5754-- na -- total number of array elements
5755-- tostore -- number of array elements pending to be stored
5756----------------------------------------------------------------------]]
5757
5758------------------------------------------------------------------------
5759-- parse a table record (hash) field
5760-- * used in constructor()
5761------------------------------------------------------------------------
5762function luaY:recfield(ls, cc)
5763 -- recfield -> (NAME | '['exp1']') = exp1
5764 local fs = ls.fs
5765 local reg = ls.fs.freereg
5766 local key, val = {}, {} -- expdesc
5767 if ls.t.token == "TK_NAME" then
5768 self:checklimit(fs, cc.nh, self.MAX_INT, "items in a constructor")
5769 self:checkname(ls, key)
5770 else -- ls->t.token == '['
5771 self:yindex(ls, key)
5772 end
5773 cc.nh = cc.nh + 1
5774 self:checknext(ls, "=")
5775 local rkkey = luaK:exp2RK(fs, key)
5776 self:expr(ls, val)
5777 luaK:codeABC(fs, "OP_SETTABLE", cc.t.info, rkkey, luaK:exp2RK(fs, val))
5778 fs.freereg = reg -- free registers
5779end
5780
5781------------------------------------------------------------------------
5782-- emit a set list instruction if enough elements (LFIELDS_PER_FLUSH)
5783-- * used in constructor()
5784------------------------------------------------------------------------
5785function luaY:closelistfield(fs, cc)
5786 if cc.v.k == "VVOID" then return end -- there is no list item
5787 luaK:exp2nextreg(fs, cc.v)
5788 cc.v.k = "VVOID"
5789 if cc.tostore == luaP.LFIELDS_PER_FLUSH then
5790 luaK:setlist(fs, cc.t.info, cc.na, cc.tostore) -- flush
5791 cc.tostore = 0 -- no more items pending
5792 end
5793end
5794
5795------------------------------------------------------------------------
5796-- emit a set list instruction at the end of parsing list constructor
5797-- * used in constructor()
5798------------------------------------------------------------------------
5799function luaY:lastlistfield(fs, cc)
5800 if cc.tostore == 0 then return end
5801 if self:hasmultret(cc.v.k) then
5802 luaK:setmultret(fs, cc.v)
5803 luaK:setlist(fs, cc.t.info, cc.na, self.LUA_MULTRET)
5804 cc.na = cc.na - 1 -- do not count last expression (unknown number of elements)
5805 else
5806 if cc.v.k ~= "VVOID" then
5807 luaK:exp2nextreg(fs, cc.v)
5808 end
5809 luaK:setlist(fs, cc.t.info, cc.na, cc.tostore)
5810 end
5811end
5812
5813------------------------------------------------------------------------
5814-- parse a table list (array) field
5815-- * used in constructor()
5816------------------------------------------------------------------------
5817function luaY:listfield(ls, cc)
5818 self:expr(ls, cc.v)
5819 self:checklimit(ls.fs, cc.na, self.MAX_INT, "items in a constructor")
5820 cc.na = cc.na + 1
5821 cc.tostore = cc.tostore + 1
5822end
5823
5824------------------------------------------------------------------------
5825-- parse a table constructor
5826-- * used in funcargs(), simpleexp()
5827------------------------------------------------------------------------
5828function luaY:constructor(ls, t)
5829 -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}'
5830 -- field -> recfield | listfield
5831 -- fieldsep -> ',' | ';'
5832 local fs = ls.fs
5833 local line = ls.linenumber
5834 local pc = luaK:codeABC(fs, "OP_NEWTABLE", 0, 0, 0)
5835 local cc = {} -- ConsControl
5836 cc.v = {}
5837 cc.na, cc.nh, cc.tostore = 0, 0, 0
5838 cc.t = t
5839 self:init_exp(t, "VRELOCABLE", pc)
5840 self:init_exp(cc.v, "VVOID", 0) -- no value (yet)
5841 luaK:exp2nextreg(ls.fs, t) -- fix it at stack top (for gc)
5842 self:checknext(ls, "{")
5843 repeat
5844 assert(cc.v.k == "VVOID" or cc.tostore > 0)
5845 if ls.t.token == "}" then break end
5846 self:closelistfield(fs, cc)
5847 local c = ls.t.token
5848
5849 if c == "TK_NAME" then -- may be listfields or recfields
5850 luaX:lookahead(ls)
5851 if ls.lookahead.token ~= "=" then -- expression?
5852 self:listfield(ls, cc)
5853 else
5854 self:recfield(ls, cc)
5855 end
5856 elseif c == "[" then -- constructor_item -> recfield
5857 self:recfield(ls, cc)
5858 else -- constructor_part -> listfield
5859 self:listfield(ls, cc)
5860 end
5861 until not self:testnext(ls, ",") and not self:testnext(ls, ";")
5862 self:check_match(ls, "}", "{", line)
5863 self:lastlistfield(fs, cc)
5864 luaP:SETARG_B(fs.f.code[pc], self:int2fb(cc.na)) -- set initial array size
5865 luaP:SETARG_C(fs.f.code[pc], self:int2fb(cc.nh)) -- set initial table size
5866end
5867
5868-- }======================================================================
5869
5870------------------------------------------------------------------------
5871-- parse the arguments (parameters) of a function declaration
5872-- * used in body()
5873------------------------------------------------------------------------
5874function luaY:parlist(ls)
5875 -- parlist -> [ param { ',' param } ]
5876 local fs = ls.fs
5877 local f = fs.f
5878 local nparams = 0
5879 f.is_vararg = 0
5880 if ls.t.token ~= ")" then -- is 'parlist' not empty?
5881 repeat
5882 local c = ls.t.token
5883 if c == "TK_NAME" then -- param -> NAME
5884 self:new_localvar(ls, self:str_checkname(ls), nparams)
5885 nparams = nparams + 1
5886 elseif c == "TK_DOTS" then -- param -> `...'
5887 luaX:next(ls)
5888-- [[
5889-- #if defined(LUA_COMPAT_VARARG)
5890 -- use `arg' as default name
5891 self:new_localvarliteral(ls, "arg", nparams)
5892 nparams = nparams + 1
5893 f.is_vararg = self.VARARG_HASARG + self.VARARG_NEEDSARG
5894-- #endif
5895--]]
5896 f.is_vararg = f.is_vararg + self.VARARG_ISVARARG
5897 else
5898 luaX:syntaxerror(ls, "<name> or "..self:LUA_QL("...").." expected")
5899 end
5900 until f.is_vararg ~= 0 or not self:testnext(ls, ",")
5901 end--if
5902 self:adjustlocalvars(ls, nparams)
5903 -- NOTE: the following works only when HASARG_MASK is 2!
5904 f.numparams = fs.nactvar - (f.is_vararg % self.HASARG_MASK)
5905 luaK:reserveregs(fs, fs.nactvar) -- reserve register for parameters
5906end
5907
5908------------------------------------------------------------------------
5909-- parse function declaration body
5910-- * used in simpleexp(), localfunc(), funcstat()
5911------------------------------------------------------------------------
5912function luaY:body(ls, e, needself, line)
5913 -- body -> '(' parlist ')' chunk END
5914 local new_fs = {} -- FuncState
5915 new_fs.upvalues = {}
5916 new_fs.actvar = {}
5917 self:open_func(ls, new_fs)
5918 new_fs.f.lineDefined = line
5919 self:checknext(ls, "(")
5920 if needself then
5921 self:new_localvarliteral(ls, "self", 0)
5922 self:adjustlocalvars(ls, 1)
5923 end
5924 self:parlist(ls)
5925 self:checknext(ls, ")")
5926 self:chunk(ls)
5927 new_fs.f.lastlinedefined = ls.linenumber
5928 self:check_match(ls, "TK_END", "TK_FUNCTION", line)
5929 self:close_func(ls)
5930 self:pushclosure(ls, new_fs, e)
5931end
5932
5933------------------------------------------------------------------------
5934-- parse a list of comma-separated expressions
5935-- * used is multiple locations
5936------------------------------------------------------------------------
5937function luaY:explist1(ls, v)
5938 -- explist1 -> expr { ',' expr }
5939 local n = 1 -- at least one expression
5940 self:expr(ls, v)
5941 while self:testnext(ls, ",") do
5942 luaK:exp2nextreg(ls.fs, v)
5943 self:expr(ls, v)
5944 n = n + 1
5945 end
5946 return n
5947end
5948
5949------------------------------------------------------------------------
5950-- parse the parameters of a function call
5951-- * contrast with parlist(), used in function declarations
5952-- * used in primaryexp()
5953------------------------------------------------------------------------
5954function luaY:funcargs(ls, f)
5955 local fs = ls.fs
5956 local args = {} -- expdesc
5957 local nparams
5958 local line = ls.linenumber
5959 local c = ls.t.token
5960 if c == "(" then -- funcargs -> '(' [ explist1 ] ')'
5961 if line ~= ls.lastline then
5962 luaX:syntaxerror(ls, "ambiguous syntax (function call x new statement)")
5963 end
5964 luaX:next(ls)
5965 if ls.t.token == ")" then -- arg list is empty?
5966 args.k = "VVOID"
5967 else
5968 self:explist1(ls, args)
5969 luaK:setmultret(fs, args)
5970 end
5971 self:check_match(ls, ")", "(", line)
5972 elseif c == "{" then -- funcargs -> constructor
5973 self:constructor(ls, args)
5974 elseif c == "TK_STRING" then -- funcargs -> STRING
5975 self:codestring(ls, args, ls.t.seminfo)
5976 luaX:next(ls) -- must use 'seminfo' before 'next'
5977 else
5978 luaX:syntaxerror(ls, "function arguments expected")
5979 return
5980 end
5981 assert(f.k == "VNONRELOC")
5982 local base = f.info -- base register for call
5983 if self:hasmultret(args.k) then
5984 nparams = self.LUA_MULTRET -- open call
5985 else
5986 if args.k ~= "VVOID" then
5987 luaK:exp2nextreg(fs, args) -- close last argument
5988 end
5989 nparams = fs.freereg - (base + 1)
5990 end
5991 self:init_exp(f, "VCALL", luaK:codeABC(fs, "OP_CALL", base, nparams + 1, 2))
5992 luaK:fixline(fs, line)
5993 fs.freereg = base + 1 -- call remove function and arguments and leaves
5994 -- (unless changed) one result
5995end
5996
5997--[[--------------------------------------------------------------------
5998-- Expression parsing
5999----------------------------------------------------------------------]]
6000
6001------------------------------------------------------------------------
6002-- parses an expression in parentheses or a single variable
6003-- * used in primaryexp()
6004------------------------------------------------------------------------
6005function luaY:prefixexp(ls, v)
6006 -- prefixexp -> NAME | '(' expr ')'
6007 local c = ls.t.token
6008 if c == "(" then
6009 local line = ls.linenumber
6010 luaX:next(ls)
6011 self:expr(ls, v)
6012 self:check_match(ls, ")", "(", line)
6013 luaK:dischargevars(ls.fs, v)
6014 elseif c == "TK_NAME" then
6015 self:singlevar(ls, v)
6016 else
6017 luaX:syntaxerror(ls, "unexpected symbol")
6018 end--if c
6019 return
6020end
6021
6022------------------------------------------------------------------------
6023-- parses a prefixexp (an expression in parentheses or a single variable)
6024-- or a function call specification
6025-- * used in simpleexp(), assignment(), exprstat()
6026------------------------------------------------------------------------
6027function luaY:primaryexp(ls, v)
6028 -- primaryexp ->
6029 -- prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs }
6030 local fs = ls.fs
6031 self:prefixexp(ls, v)
6032 while true do
6033 local c = ls.t.token
6034 if c == "." then -- field
6035 self:field(ls, v)
6036 elseif c == "[" then -- '[' exp1 ']'
6037 local key = {} -- expdesc
6038 luaK:exp2anyreg(fs, v)
6039 self:yindex(ls, key)
6040 luaK:indexed(fs, v, key)
6041 elseif c == ":" then -- ':' NAME funcargs
6042 local key = {} -- expdesc
6043 luaX:next(ls)
6044 self:checkname(ls, key)
6045 luaK:_self(fs, v, key)
6046 self:funcargs(ls, v)
6047 elseif c == "(" or c == "TK_STRING" or c == "{" then -- funcargs
6048 luaK:exp2nextreg(fs, v)
6049 self:funcargs(ls, v)
6050 else
6051 return
6052 end--if c
6053 end--while
6054end
6055
6056------------------------------------------------------------------------
6057-- parses general expression types, constants handled here
6058-- * used in subexpr()
6059------------------------------------------------------------------------
6060function luaY:simpleexp(ls, v)
6061 -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... |
6062 -- constructor | FUNCTION body | primaryexp
6063 local c = ls.t.token
6064 if c == "TK_NUMBER" then
6065 self:init_exp(v, "VKNUM", 0)
6066 v.nval = ls.t.seminfo
6067 elseif c == "TK_STRING" then
6068 self:codestring(ls, v, ls.t.seminfo)
6069 elseif c == "TK_NIL" then
6070 self:init_exp(v, "VNIL", 0)
6071 elseif c == "TK_TRUE" then
6072 self:init_exp(v, "VTRUE", 0)
6073 elseif c == "TK_FALSE" then
6074 self:init_exp(v, "VFALSE", 0)
6075 elseif c == "TK_DOTS" then -- vararg
6076 local fs = ls.fs
6077 self:check_condition(ls, fs.f.is_vararg ~= 0,
6078 "cannot use "..self:LUA_QL("...").." outside a vararg function");
6079 -- NOTE: the following substitutes for a bitop, but is value-specific
6080 local is_vararg = fs.f.is_vararg
6081 if is_vararg >= self.VARARG_NEEDSARG then
6082 fs.f.is_vararg = is_vararg - self.VARARG_NEEDSARG -- don't need 'arg'
6083 end
6084 self:init_exp(v, "VVARARG", luaK:codeABC(fs, "OP_VARARG", 0, 1, 0))
6085 elseif c == "{" then -- constructor
6086 self:constructor(ls, v)
6087 return
6088 elseif c == "TK_FUNCTION" then
6089 luaX:next(ls)
6090 self:body(ls, v, false, ls.linenumber)
6091 return
6092 else
6093 self:primaryexp(ls, v)
6094 return
6095 end--if c
6096 luaX:next(ls)
6097end
6098
6099------------------------------------------------------------------------
6100-- Translates unary operators tokens if found, otherwise returns
6101-- OPR_NOUNOPR. getunopr() and getbinopr() are used in subexpr().
6102-- * used in subexpr()
6103------------------------------------------------------------------------
6104function luaY:getunopr(op)
6105 if op == "TK_NOT" then
6106 return "OPR_NOT"
6107 elseif op == "-" then
6108 return "OPR_MINUS"
6109 elseif op == "#" then
6110 return "OPR_LEN"
6111 else
6112 return "OPR_NOUNOPR"
6113 end
6114end
6115
6116------------------------------------------------------------------------
6117-- Translates binary operator tokens if found, otherwise returns
6118-- OPR_NOBINOPR. Code generation uses OPR_* style tokens.
6119-- * used in subexpr()
6120------------------------------------------------------------------------
6121luaY.getbinopr_table = {
6122 ["+"] = "OPR_ADD",
6123 ["-"] = "OPR_SUB",
6124 ["*"] = "OPR_MUL",
6125 ["/"] = "OPR_DIV",
6126 ["%"] = "OPR_MOD",
6127 ["^"] = "OPR_POW",
6128 ["TK_CONCAT"] = "OPR_CONCAT",
6129 ["TK_NE"] = "OPR_NE",
6130 ["TK_EQ"] = "OPR_EQ",
6131 ["<"] = "OPR_LT",
6132 ["TK_LE"] = "OPR_LE",
6133 [">"] = "OPR_GT",
6134 ["TK_GE"] = "OPR_GE",
6135 ["TK_AND"] = "OPR_AND",
6136 ["TK_OR"] = "OPR_OR",
6137}
6138function luaY:getbinopr(op)
6139 local opr = self.getbinopr_table[op]
6140 if opr then return opr else return "OPR_NOBINOPR" end
6141end
6142
6143------------------------------------------------------------------------
6144-- the following priority table consists of pairs of left/right values
6145-- for binary operators (was a static const struct); grep for ORDER OPR
6146-- * the following struct is replaced:
6147-- static const struct {
6148-- lu_byte left; /* left priority for each binary operator */
6149-- lu_byte right; /* right priority */
6150-- } priority[] = { /* ORDER OPR */
6151------------------------------------------------------------------------
6152luaY.priority = {
6153 {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, -- `+' `-' `/' `%'
6154 {10, 9}, {5, 4}, -- power and concat (right associative)
6155 {3, 3}, {3, 3}, -- equality
6156 {3, 3}, {3, 3}, {3, 3}, {3, 3}, -- order
6157 {2, 2}, {1, 1} -- logical (and/or)
6158}
6159
6160luaY.UNARY_PRIORITY = 8 -- priority for unary operators
6161
6162------------------------------------------------------------------------
6163-- Parse subexpressions. Includes handling of unary operators and binary
6164-- operators. A subexpr is given the rhs priority level of the operator
6165-- immediately left of it, if any (limit is -1 if none,) and if a binop
6166-- is found, limit is compared with the lhs priority level of the binop
6167-- in order to determine which executes first.
6168------------------------------------------------------------------------
6169
6170------------------------------------------------------------------------
6171-- subexpr -> (simpleexp | unop subexpr) { binop subexpr }
6172-- where 'binop' is any binary operator with a priority higher than 'limit'
6173-- * for priority lookups with self.priority[], 1=left and 2=right
6174-- * recursively called
6175-- * used in expr()
6176------------------------------------------------------------------------
6177function luaY:subexpr(ls, v, limit)
6178 self:enterlevel(ls)
6179 local uop = self:getunopr(ls.t.token)
6180 if uop ~= "OPR_NOUNOPR" then
6181 luaX:next(ls)
6182 self:subexpr(ls, v, self.UNARY_PRIORITY)
6183 luaK:prefix(ls.fs, uop, v)
6184 else
6185 self:simpleexp(ls, v)
6186 end
6187 -- expand while operators have priorities higher than 'limit'
6188 local op = self:getbinopr(ls.t.token)
6189 while op ~= "OPR_NOBINOPR" and self.priority[luaK.BinOpr[op] + 1][1] > limit do
6190 local v2 = {} -- expdesc
6191 luaX:next(ls)
6192 luaK:infix(ls.fs, op, v)
6193 -- read sub-expression with higher priority
6194 local nextop = self:subexpr(ls, v2, self.priority[luaK.BinOpr[op] + 1][2])
6195 luaK:posfix(ls.fs, op, v, v2)
6196 op = nextop
6197 end
6198 self:leavelevel(ls)
6199 return op -- return first untreated operator
6200end
6201
6202------------------------------------------------------------------------
6203-- Expression parsing starts here. Function subexpr is entered with the
6204-- left operator (which is non-existent) priority of -1, which is lower
6205-- than all actual operators. Expr information is returned in parm v.
6206-- * used in multiple locations
6207------------------------------------------------------------------------
6208function luaY:expr(ls, v)
6209 self:subexpr(ls, v, 0)
6210end
6211
6212-- }====================================================================
6213
6214--[[--------------------------------------------------------------------
6215-- Rules for Statements
6216----------------------------------------------------------------------]]
6217
6218------------------------------------------------------------------------
6219-- checks next token, used as a look-ahead
6220-- * returns boolean instead of 0|1
6221-- * used in retstat(), chunk()
6222------------------------------------------------------------------------
6223function luaY:block_follow(token)
6224 if token == "TK_ELSE" or token == "TK_ELSEIF" or token == "TK_END"
6225 or token == "TK_UNTIL" or token == "TK_EOS" then
6226 return true
6227 else
6228 return false
6229 end
6230end
6231
6232------------------------------------------------------------------------
6233-- parse a code block or unit
6234-- * used in multiple functions
6235------------------------------------------------------------------------
6236function luaY:block(ls)
6237 -- block -> chunk
6238 local fs = ls.fs
6239 local bl = {} -- BlockCnt
6240 self:enterblock(fs, bl, false)
6241 self:chunk(ls)
6242 assert(bl.breaklist == luaK.NO_JUMP)
6243 self:leaveblock(fs)
6244end
6245
6246------------------------------------------------------------------------
6247-- structure to chain all variables in the left-hand side of an
6248-- assignment
6249-- struct LHS_assign:
6250-- prev -- (table: struct LHS_assign)
6251-- v -- variable (global, local, upvalue, or indexed) (table: expdesc)
6252------------------------------------------------------------------------
6253
6254------------------------------------------------------------------------
6255-- check whether, in an assignment to a local variable, the local variable
6256-- is needed in a previous assignment (to a table). If so, save original
6257-- local value in a safe place and use this safe copy in the previous
6258-- assignment.
6259-- * used in assignment()
6260------------------------------------------------------------------------
6261function luaY:check_conflict(ls, lh, v)
6262 local fs = ls.fs
6263 local extra = fs.freereg -- eventual position to save local variable
6264 local conflict = false
6265 while lh do
6266 if lh.v.k == "VINDEXED" then
6267 if lh.v.info == v.info then -- conflict?
6268 conflict = true
6269 lh.v.info = extra -- previous assignment will use safe copy
6270 end
6271 if lh.v.aux == v.info then -- conflict?
6272 conflict = true
6273 lh.v.aux = extra -- previous assignment will use safe copy
6274 end
6275 end
6276 lh = lh.prev
6277 end
6278 if conflict then
6279 luaK:codeABC(fs, "OP_MOVE", fs.freereg, v.info, 0) -- make copy
6280 luaK:reserveregs(fs, 1)
6281 end
6282end
6283
6284------------------------------------------------------------------------
6285-- parse a variable assignment sequence
6286-- * recursively called
6287-- * used in exprstat()
6288------------------------------------------------------------------------
6289function luaY:assignment(ls, lh, nvars)
6290 local e = {} -- expdesc
6291 -- test was: VLOCAL <= lh->v.k && lh->v.k <= VINDEXED
6292 local c = lh.v.k
6293 self:check_condition(ls, c == "VLOCAL" or c == "VUPVAL" or c == "VGLOBAL"
6294 or c == "VINDEXED", "syntax error")
6295 if self:testnext(ls, ",") then -- assignment -> ',' primaryexp assignment
6296 local nv = {} -- LHS_assign
6297 nv.v = {}
6298 nv.prev = lh
6299 self:primaryexp(ls, nv.v)
6300 if nv.v.k == "VLOCAL" then
6301 self:check_conflict(ls, lh, nv.v)
6302 end
6303 self:checklimit(ls.fs, nvars, self.LUAI_MAXCCALLS - ls.L.nCcalls,
6304 "variables in assignment")
6305 self:assignment(ls, nv, nvars + 1)
6306 else -- assignment -> '=' explist1
6307 self:checknext(ls, "=")
6308 local nexps = self:explist1(ls, e)
6309 if nexps ~= nvars then
6310 self:adjust_assign(ls, nvars, nexps, e)
6311 if nexps > nvars then
6312 ls.fs.freereg = ls.fs.freereg - (nexps - nvars) -- remove extra values
6313 end
6314 else
6315 luaK:setoneret(ls.fs, e) -- close last expression
6316 luaK:storevar(ls.fs, lh.v, e)
6317 return -- avoid default
6318 end
6319 end
6320 self:init_exp(e, "VNONRELOC", ls.fs.freereg - 1) -- default assignment
6321 luaK:storevar(ls.fs, lh.v, e)
6322end
6323
6324------------------------------------------------------------------------
6325-- parse condition in a repeat statement or an if control structure
6326-- * used in repeatstat(), test_then_block()
6327------------------------------------------------------------------------
6328function luaY:cond(ls)
6329 -- cond -> exp
6330 local v = {} -- expdesc
6331 self:expr(ls, v) -- read condition
6332 if v.k == "VNIL" then v.k = "VFALSE" end -- 'falses' are all equal here
6333 luaK:goiftrue(ls.fs, v)
6334 return v.f
6335end
6336
6337------------------------------------------------------------------------
6338-- parse a break statement
6339-- * used in statements()
6340------------------------------------------------------------------------
6341function luaY:breakstat(ls)
6342 -- stat -> BREAK
6343 local fs = ls.fs
6344 local bl = fs.bl
6345 local upval = false
6346 while bl and not bl.isbreakable do
6347 if bl.upval then upval = true end
6348 bl = bl.previous
6349 end
6350 if not bl then
6351 luaX:syntaxerror(ls, "no loop to break")
6352 end
6353 if upval then
6354 luaK:codeABC(fs, "OP_CLOSE", bl.nactvar, 0, 0)
6355 end
6356 bl.breaklist = luaK:concat(fs, bl.breaklist, luaK:jump(fs))
6357end
6358
6359------------------------------------------------------------------------
6360-- parse a while-do control structure, body processed by block()
6361-- * with dynamic array sizes, MAXEXPWHILE + EXTRAEXP limits imposed by
6362-- the function's implementation can be removed
6363-- * used in statements()
6364------------------------------------------------------------------------
6365function luaY:whilestat(ls, line)
6366 -- whilestat -> WHILE cond DO block END
6367 local fs = ls.fs
6368 local bl = {} -- BlockCnt
6369 luaX:next(ls) -- skip WHILE
6370 local whileinit = luaK:getlabel(fs)
6371 local condexit = self:cond(ls)
6372 self:enterblock(fs, bl, true)
6373 self:checknext(ls, "TK_DO")
6374 self:block(ls)
6375 luaK:patchlist(fs, luaK:jump(fs), whileinit)
6376 self:check_match(ls, "TK_END", "TK_WHILE", line)
6377 self:leaveblock(fs)
6378 luaK:patchtohere(fs, condexit) -- false conditions finish the loop
6379end
6380
6381------------------------------------------------------------------------
6382-- parse a repeat-until control structure, body parsed by chunk()
6383-- * used in statements()
6384------------------------------------------------------------------------
6385function luaY:repeatstat(ls, line)
6386 -- repeatstat -> REPEAT block UNTIL cond
6387 local fs = ls.fs
6388 local repeat_init = luaK:getlabel(fs)
6389 local bl1, bl2 = {}, {} -- BlockCnt
6390 self:enterblock(fs, bl1, true) -- loop block
6391 self:enterblock(fs, bl2, false) -- scope block
6392 luaX:next(ls) -- skip REPEAT
6393 self:chunk(ls)
6394 self:check_match(ls, "TK_UNTIL", "TK_REPEAT", line)
6395 local condexit = self:cond(ls) -- read condition (inside scope block)
6396 if not bl2.upval then -- no upvalues?
6397 self:leaveblock(fs) -- finish scope
6398 luaK:patchlist(ls.fs, condexit, repeat_init) -- close the loop
6399 else -- complete semantics when there are upvalues
6400 self:breakstat(ls) -- if condition then break
6401 luaK:patchtohere(ls.fs, condexit) -- else...
6402 self:leaveblock(fs) -- finish scope...
6403 luaK:patchlist(ls.fs, luaK:jump(fs), repeat_init) -- and repeat
6404 end
6405 self:leaveblock(fs) -- finish loop
6406end
6407
6408------------------------------------------------------------------------
6409-- parse the single expressions needed in numerical for loops
6410-- * used in fornum()
6411------------------------------------------------------------------------
6412function luaY:exp1(ls)
6413 local e = {} -- expdesc
6414 self:expr(ls, e)
6415 local k = e.k
6416 luaK:exp2nextreg(ls.fs, e)
6417 return k
6418end
6419
6420------------------------------------------------------------------------
6421-- parse a for loop body for both versions of the for loop
6422-- * used in fornum(), forlist()
6423------------------------------------------------------------------------
6424function luaY:forbody(ls, base, line, nvars, isnum)
6425 -- forbody -> DO block
6426 local bl = {} -- BlockCnt
6427 local fs = ls.fs
6428 self:adjustlocalvars(ls, 3) -- control variables
6429 self:checknext(ls, "TK_DO")
6430 local prep = isnum and luaK:codeAsBx(fs, "OP_FORPREP", base, luaK.NO_JUMP)
6431 or luaK:jump(fs)
6432 self:enterblock(fs, bl, false) -- scope for declared variables
6433 self:adjustlocalvars(ls, nvars)
6434 luaK:reserveregs(fs, nvars)
6435 self:block(ls)
6436 self:leaveblock(fs) -- end of scope for declared variables
6437 luaK:patchtohere(fs, prep)
6438 local endfor = isnum and luaK:codeAsBx(fs, "OP_FORLOOP", base, luaK.NO_JUMP)
6439 or luaK:codeABC(fs, "OP_TFORLOOP", base, 0, nvars)
6440 luaK:fixline(fs, line) -- pretend that `OP_FOR' starts the loop
6441 luaK:patchlist(fs, isnum and endfor or luaK:jump(fs), prep + 1)
6442end
6443
6444------------------------------------------------------------------------
6445-- parse a numerical for loop, calls forbody()
6446-- * used in forstat()
6447------------------------------------------------------------------------
6448function luaY:fornum(ls, varname, line)
6449 -- fornum -> NAME = exp1,exp1[,exp1] forbody
6450 local fs = ls.fs
6451 local base = fs.freereg
6452 self:new_localvarliteral(ls, "(for index)", 0)
6453 self:new_localvarliteral(ls, "(for limit)", 1)
6454 self:new_localvarliteral(ls, "(for step)", 2)
6455 self:new_localvar(ls, varname, 3)
6456 self:checknext(ls, '=')
6457 self:exp1(ls) -- initial value
6458 self:checknext(ls, ",")
6459 self:exp1(ls) -- limit
6460 if self:testnext(ls, ",") then
6461 self:exp1(ls) -- optional step
6462 else -- default step = 1
6463 luaK:codeABx(fs, "OP_LOADK", fs.freereg, luaK:numberK(fs, 1))
6464 luaK:reserveregs(fs, 1)
6465 end
6466 self:forbody(ls, base, line, 1, true)
6467end
6468
6469------------------------------------------------------------------------
6470-- parse a generic for loop, calls forbody()
6471-- * used in forstat()
6472------------------------------------------------------------------------
6473function luaY:forlist(ls, indexname)
6474 -- forlist -> NAME {,NAME} IN explist1 forbody
6475 local fs = ls.fs
6476 local e = {} -- expdesc
6477 local nvars = 0
6478 local base = fs.freereg
6479 -- create control variables
6480 self:new_localvarliteral(ls, "(for generator)", nvars)
6481 nvars = nvars + 1
6482 self:new_localvarliteral(ls, "(for state)", nvars)
6483 nvars = nvars + 1
6484 self:new_localvarliteral(ls, "(for control)", nvars)
6485 nvars = nvars + 1
6486 -- create declared variables
6487 self:new_localvar(ls, indexname, nvars)
6488 nvars = nvars + 1
6489 while self:testnext(ls, ",") do
6490 self:new_localvar(ls, self:str_checkname(ls), nvars)
6491 nvars = nvars + 1
6492 end
6493 self:checknext(ls, "TK_IN")
6494 local line = ls.linenumber
6495 self:adjust_assign(ls, 3, self:explist1(ls, e), e)
6496 luaK:checkstack(fs, 3) -- extra space to call generator
6497 self:forbody(ls, base, line, nvars - 3, false)
6498end
6499
6500------------------------------------------------------------------------
6501-- initial parsing for a for loop, calls fornum() or forlist()
6502-- * used in statements()
6503------------------------------------------------------------------------
6504function luaY:forstat(ls, line)
6505 -- forstat -> FOR (fornum | forlist) END
6506 local fs = ls.fs
6507 local bl = {} -- BlockCnt
6508 self:enterblock(fs, bl, true) -- scope for loop and control variables
6509 luaX:next(ls) -- skip `for'
6510 local varname = self:str_checkname(ls) -- first variable name
6511 local c = ls.t.token
6512 if c == "=" then
6513 self:fornum(ls, varname, line)
6514 elseif c == "," or c == "TK_IN" then
6515 self:forlist(ls, varname)
6516 else
6517 luaX:syntaxerror(ls, self:LUA_QL("=").." or "..self:LUA_QL("in").." expected")
6518 end
6519 self:check_match(ls, "TK_END", "TK_FOR", line)
6520 self:leaveblock(fs) -- loop scope (`break' jumps to this point)
6521end
6522
6523------------------------------------------------------------------------
6524-- parse part of an if control structure, including the condition
6525-- * used in ifstat()
6526------------------------------------------------------------------------
6527function luaY:test_then_block(ls)
6528 -- test_then_block -> [IF | ELSEIF] cond THEN block
6529 luaX:next(ls) -- skip IF or ELSEIF
6530 local condexit = self:cond(ls)
6531 self:checknext(ls, "TK_THEN")
6532 self:block(ls) -- `then' part
6533 return condexit
6534end
6535
6536------------------------------------------------------------------------
6537-- parse an if control structure
6538-- * used in statements()
6539------------------------------------------------------------------------
6540function luaY:ifstat(ls, line)
6541 -- ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END
6542 local fs = ls.fs
6543 local escapelist = luaK.NO_JUMP
6544 local flist = self:test_then_block(ls) -- IF cond THEN block
6545 while ls.t.token == "TK_ELSEIF" do
6546 escapelist = luaK:concat(fs, escapelist, luaK:jump(fs))
6547 luaK:patchtohere(fs, flist)
6548 flist = self:test_then_block(ls) -- ELSEIF cond THEN block
6549 end
6550 if ls.t.token == "TK_ELSE" then
6551 escapelist = luaK:concat(fs, escapelist, luaK:jump(fs))
6552 luaK:patchtohere(fs, flist)
6553 luaX:next(ls) -- skip ELSE (after patch, for correct line info)
6554 self:block(ls) -- 'else' part
6555 else
6556 escapelist = luaK:concat(fs, escapelist, flist)
6557 end
6558 luaK:patchtohere(fs, escapelist)
6559 self:check_match(ls, "TK_END", "TK_IF", line)
6560end
6561
6562------------------------------------------------------------------------
6563-- parse a local function statement
6564-- * used in statements()
6565------------------------------------------------------------------------
6566function luaY:localfunc(ls)
6567 local v, b = {}, {} -- expdesc
6568 local fs = ls.fs
6569 self:new_localvar(ls, self:str_checkname(ls), 0)
6570 self:init_exp(v, "VLOCAL", fs.freereg)
6571 luaK:reserveregs(fs, 1)
6572 self:adjustlocalvars(ls, 1)
6573 self:body(ls, b, false, ls.linenumber)
6574 luaK:storevar(fs, v, b)
6575 -- debug information will only see the variable after this point!
6576 self:getlocvar(fs, fs.nactvar - 1).startpc = fs.pc
6577end
6578
6579------------------------------------------------------------------------
6580-- parse a local variable declaration statement
6581-- * used in statements()
6582------------------------------------------------------------------------
6583function luaY:localstat(ls)
6584 -- stat -> LOCAL NAME {',' NAME} ['=' explist1]
6585 local nvars = 0
6586 local nexps
6587 local e = {} -- expdesc
6588 repeat
6589 self:new_localvar(ls, self:str_checkname(ls), nvars)
6590 nvars = nvars + 1
6591 until not self:testnext(ls, ",")
6592 if self:testnext(ls, "=") then
6593 nexps = self:explist1(ls, e)
6594 else
6595 e.k = "VVOID"
6596 nexps = 0
6597 end
6598 self:adjust_assign(ls, nvars, nexps, e)
6599 self:adjustlocalvars(ls, nvars)
6600end
6601
6602------------------------------------------------------------------------
6603-- parse a function name specification
6604-- * used in funcstat()
6605------------------------------------------------------------------------
6606function luaY:funcname(ls, v)
6607 -- funcname -> NAME {field} [':' NAME]
6608 local needself = false
6609 self:singlevar(ls, v)
6610 while ls.t.token == "." do
6611 self:field(ls, v)
6612 end
6613 if ls.t.token == ":" then
6614 needself = true
6615 self:field(ls, v)
6616 end
6617 return needself
6618end
6619
6620------------------------------------------------------------------------
6621-- parse a function statement
6622-- * used in statements()
6623------------------------------------------------------------------------
6624function luaY:funcstat(ls, line)
6625 -- funcstat -> FUNCTION funcname body
6626 local v, b = {}, {} -- expdesc
6627 luaX:next(ls) -- skip FUNCTION
6628 local needself = self:funcname(ls, v)
6629 self:body(ls, b, needself, line)
6630 luaK:storevar(ls.fs, v, b)
6631 luaK:fixline(ls.fs, line) -- definition 'happens' in the first line
6632end
6633
6634------------------------------------------------------------------------
6635-- parse a function call with no returns or an assignment statement
6636-- * used in statements()
6637------------------------------------------------------------------------
6638function luaY:exprstat(ls)
6639 -- stat -> func | assignment
6640 local fs = ls.fs
6641 local v = {} -- LHS_assign
6642 v.v = {}
6643 self:primaryexp(ls, v.v)
6644 if v.v.k == "VCALL" then -- stat -> func
6645 luaP:SETARG_C(luaK:getcode(fs, v.v), 1) -- call statement uses no results
6646 else -- stat -> assignment
6647 v.prev = nil
6648 self:assignment(ls, v, 1)
6649 end
6650end
6651
6652------------------------------------------------------------------------
6653-- parse a return statement
6654-- * used in statements()
6655------------------------------------------------------------------------
6656function luaY:retstat(ls)
6657 -- stat -> RETURN explist
6658 local fs = ls.fs
6659 local e = {} -- expdesc
6660 local first, nret -- registers with returned values
6661 luaX:next(ls) -- skip RETURN
6662 if self:block_follow(ls.t.token) or ls.t.token == ";" then
6663 first, nret = 0, 0 -- return no values
6664 else
6665 nret = self:explist1(ls, e) -- optional return values
6666 if self:hasmultret(e.k) then
6667 luaK:setmultret(fs, e)
6668 if e.k == "VCALL" and nret == 1 then -- tail call?
6669 luaP:SET_OPCODE(luaK:getcode(fs, e), "OP_TAILCALL")
6670 assert(luaP:GETARG_A(luaK:getcode(fs, e)) == fs.nactvar)
6671 end
6672 first = fs.nactvar
6673 nret = self.LUA_MULTRET -- return all values
6674 else
6675 if nret == 1 then -- only one single value?
6676 first = luaK:exp2anyreg(fs, e)
6677 else
6678 luaK:exp2nextreg(fs, e) -- values must go to the 'stack'
6679 first = fs.nactvar -- return all 'active' values
6680 assert(nret == fs.freereg - first)
6681 end
6682 end--if
6683 end--if
6684 luaK:ret(fs, first, nret)
6685end
6686
6687------------------------------------------------------------------------
6688-- initial parsing for statements, calls a lot of functions
6689-- * returns boolean instead of 0|1
6690-- * used in chunk()
6691------------------------------------------------------------------------
6692function luaY:statement(ls)
6693 local line = ls.linenumber -- may be needed for error messages
6694 local c = ls.t.token
6695 if c == "TK_IF" then -- stat -> ifstat
6696 self:ifstat(ls, line)
6697 return false
6698 elseif c == "TK_WHILE" then -- stat -> whilestat
6699 self:whilestat(ls, line)
6700 return false
6701 elseif c == "TK_DO" then -- stat -> DO block END
6702 luaX:next(ls) -- skip DO
6703 self:block(ls)
6704 self:check_match(ls, "TK_END", "TK_DO", line)
6705 return false
6706 elseif c == "TK_FOR" then -- stat -> forstat
6707 self:forstat(ls, line)
6708 return false
6709 elseif c == "TK_REPEAT" then -- stat -> repeatstat
6710 self:repeatstat(ls, line)
6711 return false
6712 elseif c == "TK_FUNCTION" then -- stat -> funcstat
6713 self:funcstat(ls, line)
6714 return false
6715 elseif c == "TK_LOCAL" then -- stat -> localstat
6716 luaX:next(ls) -- skip LOCAL
6717 if self:testnext(ls, "TK_FUNCTION") then -- local function?
6718 self:localfunc(ls)
6719 else
6720 self:localstat(ls)
6721 end
6722 return false
6723 elseif c == "TK_RETURN" then -- stat -> retstat
6724 self:retstat(ls)
6725 return true -- must be last statement
6726 elseif c == "TK_BREAK" then -- stat -> breakstat
6727 luaX:next(ls) -- skip BREAK
6728 self:breakstat(ls)
6729 return true -- must be last statement
6730 else
6731 self:exprstat(ls)
6732 return false -- to avoid warnings
6733 end--if c
6734end
6735
6736------------------------------------------------------------------------
6737-- parse a chunk, which consists of a bunch of statements
6738-- * used in parser(), body(), block(), repeatstat()
6739------------------------------------------------------------------------
6740function luaY:chunk(ls)
6741 -- chunk -> { stat [';'] }
6742 local islast = false
6743 self:enterlevel(ls)
6744 while not islast and not self:block_follow(ls.t.token) do
6745 islast = self:statement(ls)
6746 self:testnext(ls, ";")
6747 assert(ls.fs.f.maxstacksize >= ls.fs.freereg and
6748 ls.fs.freereg >= ls.fs.nactvar)
6749 ls.fs.freereg = ls.fs.nactvar -- free registers
6750 end
6751 self:leavelevel(ls)
6752end
6753
6754-- }======================================================================
6755return luaY]]></ProtectedString>
6756 <BinaryString name="Tags"></BinaryString>
6757 </Properties>
6758 </Item>
6759 <Item class="ModuleScript" referent="RBX1E87DFB667CA48C2AEAEFA48C0C00C1D">
6760 <Properties>
6761 <Content name="LinkedSource"><null></null></Content>
6762 <string name="Name">LuaK</string>
6763 <string name="ScriptGuid">{2C3B786F-7F97-4344-9B7E-5ACD70991843}</string>
6764 <ProtectedString name="Source"><![CDATA[local type = type;
6765local table = table;
6766local assert = assert;
6767local require = require;
6768local math = math;
6769local next = next;
6770local string = string;
6771local debug = debug;
6772
6773--[[--------------------------------------------------------------------
6774
6775 lcode.lua
6776 Lua 5 code generator in Lua
6777 This file is part of Yueliang.
6778
6779 Copyright (c) 2005-2007 Kein-Hong Man <khman@users.sf.net>
6780 The COPYRIGHT file describes the conditions
6781 under which this software may be distributed.
6782
6783 See the ChangeLog for more information.
6784
6785----------------------------------------------------------------------]]
6786
6787--[[--------------------------------------------------------------------
6788-- Notes:
6789-- * one function manipulate a pointer argument with a simple data type
6790-- (can't be emulated by a table, ambiguous), now returns that value:
6791-- luaK:concat(fs, l1, l2)
6792-- * luaM_growvector uses the faux luaY:growvector, for limit checking
6793-- * some function parameters changed to boolean, additional code
6794-- translates boolean back to 1/0 for instruction fields
6795--
6796-- Not implemented:
6797-- * NOTE there is a failed assert in luaK:addk, a porting problem
6798--
6799-- Added:
6800-- * constant MAXSTACK from llimits.h
6801-- * luaK:ttisnumber(o) (from lobject.h)
6802-- * luaK:nvalue(o) (from lobject.h)
6803-- * luaK:setnilvalue(o) (from lobject.h)
6804-- * luaK:setnvalue(o, x) (from lobject.h)
6805-- * luaK:setbvalue(o, x) (from lobject.h)
6806-- * luaK:sethvalue(o, x) (from lobject.h), parameter L deleted
6807-- * luaK:setsvalue(o, x) (from lobject.h), parameter L deleted
6808-- * luaK:numadd, luaK:numsub, luaK:nummul, luaK:numdiv, luaK:nummod,
6809-- luaK:numpow, luaK:numunm, luaK:numisnan (from luaconf.h)
6810-- * copyexp(e1, e2) added in luaK:posfix to copy expdesc struct
6811--
6812-- Changed in 5.1.x:
6813-- * enum BinOpr has a new entry, OPR_MOD
6814-- * enum UnOpr has a new entry, OPR_LEN
6815-- * binopistest, unused in 5.0.x, has been deleted
6816-- * macro setmultret is new
6817-- * functions isnumeral, luaK_ret, boolK are new
6818-- * funcion nilK was named nil_constant in 5.0.x
6819-- * function interface changed: need_value, patchtestreg, concat
6820-- * TObject now a TValue
6821-- * functions luaK_setreturns, luaK_setoneret are new
6822-- * function luaK:setcallreturns deleted, to be replaced by:
6823-- luaK:setmultret, luaK:ret, luaK:setreturns, luaK:setoneret
6824-- * functions constfolding, codearith, codecomp are new
6825-- * luaK:codebinop has been deleted
6826-- * function luaK_setlist is new
6827-- * OPR_MULT renamed to OPR_MUL
6828----------------------------------------------------------------------]]
6829
6830-- requires luaP, luaX, luaY
6831local luaK = {}
6832local luaP = require(script.Parent.LuaP)
6833local luaX = require(script.Parent.LuaX)
6834
6835------------------------------------------------------------------------
6836-- constants used by code generator
6837------------------------------------------------------------------------
6838-- maximum stack for a Lua function
6839luaK.MAXSTACK = 250 -- (from llimits.h)
6840
6841--[[--------------------------------------------------------------------
6842-- other functions
6843----------------------------------------------------------------------]]
6844
6845------------------------------------------------------------------------
6846-- emulation of TValue macros (these are from lobject.h)
6847-- * TValue is a table since lcode passes references around
6848-- * tt member field removed, using Lua's type() instead
6849-- * for setsvalue, sethvalue, parameter L (deleted here) in lobject.h
6850-- is used in an assert for testing, see checkliveness(g,obj)
6851------------------------------------------------------------------------
6852function luaK:ttisnumber(o)
6853 if o then return type(o.value) == "number" else return false end
6854end
6855function luaK:nvalue(o) return o.value end
6856function luaK:setnilvalue(o) o.value = nil end
6857function luaK:setsvalue(o, x) o.value = x end
6858luaK.setnvalue = luaK.setsvalue
6859luaK.sethvalue = luaK.setsvalue
6860luaK.setbvalue = luaK.setsvalue
6861
6862------------------------------------------------------------------------
6863-- The luai_num* macros define the primitive operations over numbers.
6864-- * this is not the entire set of primitive operations from luaconf.h
6865-- * used in luaK:constfolding()
6866------------------------------------------------------------------------
6867function luaK:numadd(a, b) return a + b end
6868function luaK:numsub(a, b) return a - b end
6869function luaK:nummul(a, b) return a * b end
6870function luaK:numdiv(a, b) return a / b end
6871function luaK:nummod(a, b) return a % b end
6872 -- ((a) - floor((a)/(b))*(b)) /* actual, for reference */
6873function luaK:numpow(a, b) return a ^ b end
6874function luaK:numunm(a) return -a end
6875function luaK:numisnan(a) return not a == a end
6876 -- a NaN cannot equal another NaN
6877
6878--[[--------------------------------------------------------------------
6879-- code generator functions
6880----------------------------------------------------------------------]]
6881
6882------------------------------------------------------------------------
6883-- Marks the end of a patch list. It is an invalid value both as an absolute
6884-- address, and as a list link (would link an element to itself).
6885------------------------------------------------------------------------
6886luaK.NO_JUMP = -1
6887
6888------------------------------------------------------------------------
6889-- grep "ORDER OPR" if you change these enums
6890------------------------------------------------------------------------
6891luaK.BinOpr = {
6892 OPR_ADD = 0, OPR_SUB = 1, OPR_MUL = 2, OPR_DIV = 3, OPR_MOD = 4, OPR_POW = 5,
6893 OPR_CONCAT = 6,
6894 OPR_NE = 7, OPR_EQ = 8,
6895 OPR_LT = 9, OPR_LE = 10, OPR_GT = 11, OPR_GE = 12,
6896 OPR_AND = 13, OPR_OR = 14,
6897 OPR_NOBINOPR = 15,
6898}
6899
6900-- * UnOpr is used by luaK:prefix's op argument, but not directly used
6901-- because the function receives the symbols as strings, e.g. "OPR_NOT"
6902luaK.UnOpr = {
6903 OPR_MINUS = 0, OPR_NOT = 1, OPR_LEN = 2, OPR_NOUNOPR = 3
6904}
6905
6906------------------------------------------------------------------------
6907-- returns the instruction object for given e (expdesc), was a macro
6908------------------------------------------------------------------------
6909function luaK:getcode(fs, e)
6910 return fs.f.code[e.info]
6911end
6912
6913------------------------------------------------------------------------
6914-- codes an instruction with a signed Bx (sBx) field, was a macro
6915-- * used in luaK:jump(), (lparser) luaY:forbody()
6916------------------------------------------------------------------------
6917function luaK:codeAsBx(fs, o, A, sBx)
6918 return self:codeABx(fs, o, A, sBx + luaP.MAXARG_sBx)
6919end
6920
6921------------------------------------------------------------------------
6922-- set the expdesc e instruction for multiple returns, was a macro
6923------------------------------------------------------------------------
6924function luaK:setmultret(fs, e)
6925 self:setreturns(fs, e, luaY.LUA_MULTRET)
6926end
6927
6928------------------------------------------------------------------------
6929-- there is a jump if patch lists are not identical, was a macro
6930-- * used in luaK:exp2reg(), luaK:exp2anyreg(), luaK:exp2val()
6931------------------------------------------------------------------------
6932function luaK:hasjumps(e)
6933 return e.t ~= e.f
6934end
6935
6936------------------------------------------------------------------------
6937-- true if the expression is a constant number (for constant folding)
6938-- * used in constfolding(), infix()
6939------------------------------------------------------------------------
6940function luaK:isnumeral(e)
6941 return e.k == "VKNUM" and e.t == self.NO_JUMP and e.f == self.NO_JUMP
6942end
6943
6944------------------------------------------------------------------------
6945-- codes loading of nil, optimization done if consecutive locations
6946-- * used in luaK:discharge2reg(), (lparser) luaY:adjust_assign()
6947------------------------------------------------------------------------
6948function luaK:_nil(fs, from, n)
6949 if fs.pc > fs.lasttarget then -- no jumps to current position?
6950 if fs.pc == 0 then -- function start?
6951 if from >= fs.nactvar then
6952 return -- positions are already clean
6953 end
6954 else
6955 local previous = fs.f.code[fs.pc - 1]
6956 if luaP:GET_OPCODE(previous) == "OP_LOADNIL" then
6957 local pfrom = luaP:GETARG_A(previous)
6958 local pto = luaP:GETARG_B(previous)
6959 if pfrom <= from and from <= pto + 1 then -- can connect both?
6960 if from + n - 1 > pto then
6961 luaP:SETARG_B(previous, from + n - 1)
6962 end
6963 return
6964 end
6965 end
6966 end
6967 end
6968 self:codeABC(fs, "OP_LOADNIL", from, from + n - 1, 0) -- else no optimization
6969end
6970
6971------------------------------------------------------------------------
6972--
6973-- * used in multiple locations
6974------------------------------------------------------------------------
6975function luaK:jump(fs)
6976 local jpc = fs.jpc -- save list of jumps to here
6977 fs.jpc = self.NO_JUMP
6978 local j = self:codeAsBx(fs, "OP_JMP", 0, self.NO_JUMP)
6979 j = self:concat(fs, j, jpc) -- keep them on hold
6980 return j
6981end
6982
6983------------------------------------------------------------------------
6984-- codes a RETURN instruction
6985-- * used in luaY:close_func(), luaY:retstat()
6986------------------------------------------------------------------------
6987function luaK:ret(fs, first, nret)
6988 self:codeABC(fs, "OP_RETURN", first, nret + 1, 0)
6989end
6990
6991------------------------------------------------------------------------
6992--
6993-- * used in luaK:jumponcond(), luaK:codecomp()
6994------------------------------------------------------------------------
6995function luaK:condjump(fs, op, A, B, C)
6996 self:codeABC(fs, op, A, B, C)
6997 return self:jump(fs)
6998end
6999
7000------------------------------------------------------------------------
7001--
7002-- * used in luaK:patchlistaux(), luaK:concat()
7003------------------------------------------------------------------------
7004function luaK:fixjump(fs, pc, dest)
7005 local jmp = fs.f.code[pc]
7006 local offset = dest - (pc + 1)
7007 assert(dest ~= self.NO_JUMP)
7008 if math.abs(offset) > luaP.MAXARG_sBx then
7009 luaX:syntaxerror(fs.ls, "control structure too long")
7010 end
7011 luaP:SETARG_sBx(jmp, offset)
7012end
7013
7014------------------------------------------------------------------------
7015-- returns current 'pc' and marks it as a jump target (to avoid wrong
7016-- optimizations with consecutive instructions not in the same basic block).
7017-- * used in multiple locations
7018-- * fs.lasttarget tested only by luaK:_nil() when optimizing OP_LOADNIL
7019------------------------------------------------------------------------
7020function luaK:getlabel(fs)
7021 fs.lasttarget = fs.pc
7022 return fs.pc
7023end
7024
7025------------------------------------------------------------------------
7026--
7027-- * used in luaK:need_value(), luaK:removevalues(), luaK:patchlistaux(),
7028-- luaK:concat()
7029------------------------------------------------------------------------
7030function luaK:getjump(fs, pc)
7031 local offset = luaP:GETARG_sBx(fs.f.code[pc])
7032 if offset == self.NO_JUMP then -- point to itself represents end of list
7033 return self.NO_JUMP -- end of list
7034 else
7035 return (pc + 1) + offset -- turn offset into absolute position
7036 end
7037end
7038
7039------------------------------------------------------------------------
7040--
7041-- * used in luaK:need_value(), luaK:patchtestreg(), luaK:invertjump()
7042------------------------------------------------------------------------
7043function luaK:getjumpcontrol(fs, pc)
7044 local pi = fs.f.code[pc]
7045 local ppi = fs.f.code[pc - 1]
7046 if pc >= 1 and luaP:testTMode(luaP:GET_OPCODE(ppi)) ~= 0 then
7047 return ppi
7048 else
7049 return pi
7050 end
7051end
7052
7053------------------------------------------------------------------------
7054-- check whether list has any jump that do not produce a value
7055-- (or produce an inverted value)
7056-- * return value changed to boolean
7057-- * used only in luaK:exp2reg()
7058------------------------------------------------------------------------
7059function luaK:need_value(fs, list)
7060 while list ~= self.NO_JUMP do
7061 local i = self:getjumpcontrol(fs, list)
7062 if luaP:GET_OPCODE(i) ~= "OP_TESTSET" then return true end
7063 list = self:getjump(fs, list)
7064 end
7065 return false -- not found
7066end
7067
7068------------------------------------------------------------------------
7069--
7070-- * used in luaK:removevalues(), luaK:patchlistaux()
7071------------------------------------------------------------------------
7072function luaK:patchtestreg(fs, node, reg)
7073 local i = self:getjumpcontrol(fs, node)
7074 if luaP:GET_OPCODE(i) ~= "OP_TESTSET" then
7075 return false -- cannot patch other instructions
7076 end
7077 if reg ~= luaP.NO_REG and reg ~= luaP:GETARG_B(i) then
7078 luaP:SETARG_A(i, reg)
7079 else -- no register to put value or register already has the value
7080 -- due to use of a table as i, i cannot be replaced by another table
7081 -- so the following is required; there is no change to ARG_C
7082 luaP:SET_OPCODE(i, "OP_TEST")
7083 local b = luaP:GETARG_B(i)
7084 luaP:SETARG_A(i, b)
7085 luaP:SETARG_B(i, 0)
7086 -- *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); /* C */
7087 end
7088 return true
7089end
7090
7091------------------------------------------------------------------------
7092--
7093-- * used only in luaK:codenot()
7094------------------------------------------------------------------------
7095function luaK:removevalues(fs, list)
7096 while list ~= self.NO_JUMP do
7097 self:patchtestreg(fs, list, luaP.NO_REG)
7098 list = self:getjump(fs, list)
7099 end
7100end
7101
7102------------------------------------------------------------------------
7103--
7104-- * used in luaK:dischargejpc(), luaK:patchlist(), luaK:exp2reg()
7105------------------------------------------------------------------------
7106function luaK:patchlistaux(fs, list, vtarget, reg, dtarget)
7107 while list ~= self.NO_JUMP do
7108 local _next = self:getjump(fs, list)
7109 if self:patchtestreg(fs, list, reg) then
7110 self:fixjump(fs, list, vtarget)
7111 else
7112 self:fixjump(fs, list, dtarget) -- jump to default target
7113 end
7114 list = _next
7115 end
7116end
7117
7118------------------------------------------------------------------------
7119--
7120-- * used only in luaK:code()
7121------------------------------------------------------------------------
7122function luaK:dischargejpc(fs)
7123 self:patchlistaux(fs, fs.jpc, fs.pc, luaP.NO_REG, fs.pc)
7124 fs.jpc = self.NO_JUMP
7125end
7126
7127------------------------------------------------------------------------
7128--
7129-- * used in (lparser) luaY:whilestat(), luaY:repeatstat(), luaY:forbody()
7130------------------------------------------------------------------------
7131function luaK:patchlist(fs, list, target)
7132 if target == fs.pc then
7133 self:patchtohere(fs, list)
7134 else
7135 assert(target < fs.pc)
7136 self:patchlistaux(fs, list, target, luaP.NO_REG, target)
7137 end
7138end
7139
7140------------------------------------------------------------------------
7141--
7142-- * used in multiple locations
7143------------------------------------------------------------------------
7144function luaK:patchtohere(fs, list)
7145 self:getlabel(fs)
7146 fs.jpc = self:concat(fs, fs.jpc, list)
7147end
7148
7149------------------------------------------------------------------------
7150-- * l1 was a pointer, now l1 is returned and callee assigns the value
7151-- * used in multiple locations
7152------------------------------------------------------------------------
7153function luaK:concat(fs, l1, l2)
7154 if l2 == self.NO_JUMP then return l1
7155 elseif l1 == self.NO_JUMP then
7156 return l2
7157 else
7158 local list = l1
7159 local _next = self:getjump(fs, list)
7160 while _next ~= self.NO_JUMP do -- find last element
7161 list = _next
7162 _next = self:getjump(fs, list)
7163 end
7164 self:fixjump(fs, list, l2)
7165 end
7166 return l1
7167end
7168
7169------------------------------------------------------------------------
7170--
7171-- * used in luaK:reserveregs(), (lparser) luaY:forlist()
7172------------------------------------------------------------------------
7173function luaK:checkstack(fs, n)
7174 local newstack = fs.freereg + n
7175 if newstack > fs.f.maxstacksize then
7176 if newstack >= self.MAXSTACK then
7177 luaX:syntaxerror(fs.ls, "function or expression too complex")
7178 end
7179 fs.f.maxstacksize = newstack
7180 end
7181end
7182
7183------------------------------------------------------------------------
7184--
7185-- * used in multiple locations
7186------------------------------------------------------------------------
7187function luaK:reserveregs(fs, n)
7188 self:checkstack(fs, n)
7189 fs.freereg = fs.freereg + n
7190end
7191
7192------------------------------------------------------------------------
7193--
7194-- * used in luaK:freeexp(), luaK:dischargevars()
7195------------------------------------------------------------------------
7196function luaK:freereg(fs, reg)
7197 if not luaP:ISK(reg) and reg >= fs.nactvar then
7198 fs.freereg = fs.freereg - 1
7199 assert(reg == fs.freereg)
7200 end
7201end
7202
7203------------------------------------------------------------------------
7204--
7205-- * used in multiple locations
7206------------------------------------------------------------------------
7207function luaK:freeexp(fs, e)
7208 if e.k == "VNONRELOC" then
7209 self:freereg(fs, e.info)
7210 end
7211end
7212
7213------------------------------------------------------------------------
7214-- * TODO NOTE implementation is not 100% correct, since the assert fails
7215-- * luaH_set, setobj deleted; direct table access used instead
7216-- * used in luaK:stringK(), luaK:numberK(), luaK:boolK(), luaK:nilK()
7217------------------------------------------------------------------------
7218function luaK:addk(fs, k, v)
7219 local L = fs.L
7220 local idx = fs.h[k.value]
7221 --TValue *idx = luaH_set(L, fs->h, k); /* C */
7222 local f = fs.f
7223 if self:ttisnumber(idx) then
7224 --TODO this assert currently FAILS (last tested for 5.0.2)
7225 --assert(fs.f.k[self:nvalue(idx)] == v)
7226 --assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); /* C */
7227 return self:nvalue(idx)
7228 else -- constant not found; create a new entry
7229 idx = {}
7230 self:setnvalue(idx, fs.nk)
7231 fs.h[k.value] = idx
7232 -- setnvalue(idx, cast_num(fs->nk)); /* C */
7233 luaY:growvector(L, f.k, fs.nk, f.sizek, nil,
7234 luaP.MAXARG_Bx, "constant table overflow")
7235 -- loop to initialize empty f.k positions not required
7236 f.k[fs.nk] = v
7237 -- setobj(L, &f->k[fs->nk], v); /* C */
7238 -- luaC_barrier(L, f, v); /* GC */
7239 local nk = fs.nk
7240 fs.nk = fs.nk + 1
7241 return nk
7242 end
7243
7244end
7245
7246------------------------------------------------------------------------
7247-- creates and sets a string object
7248-- * used in (lparser) luaY:codestring(), luaY:singlevar()
7249------------------------------------------------------------------------
7250function luaK:stringK(fs, s)
7251 local o = {} -- TValue
7252 self:setsvalue(o, s)
7253 return self:addk(fs, o, o)
7254end
7255
7256------------------------------------------------------------------------
7257-- creates and sets a number object
7258-- * used in luaK:prefix() for negative (or negation of) numbers
7259-- * used in (lparser) luaY:simpleexp(), luaY:fornum()
7260------------------------------------------------------------------------
7261function luaK:numberK(fs, r)
7262 local o = {} -- TValue
7263 self:setnvalue(o, r)
7264 return self:addk(fs, o, o)
7265end
7266
7267------------------------------------------------------------------------
7268-- creates and sets a boolean object
7269-- * used only in luaK:exp2RK()
7270------------------------------------------------------------------------
7271function luaK:boolK(fs, b)
7272 local o = {} -- TValue
7273 self:setbvalue(o, b)
7274 return self:addk(fs, o, o)
7275end
7276
7277------------------------------------------------------------------------
7278-- creates and sets a nil object
7279-- * used only in luaK:exp2RK()
7280------------------------------------------------------------------------
7281function luaK:nilK(fs)
7282 local k, v = {}, {} -- TValue
7283 self:setnilvalue(v)
7284 -- cannot use nil as key; instead use table itself to represent nil
7285 self:sethvalue(k, fs.h)
7286 return self:addk(fs, k, v)
7287end
7288
7289------------------------------------------------------------------------
7290--
7291-- * used in luaK:setmultret(), (lparser) luaY:adjust_assign()
7292------------------------------------------------------------------------
7293function luaK:setreturns(fs, e, nresults)
7294 if e.k == "VCALL" then -- expression is an open function call?
7295 luaP:SETARG_C(self:getcode(fs, e), nresults + 1)
7296 elseif e.k == "VVARARG" then
7297 luaP:SETARG_B(self:getcode(fs, e), nresults + 1);
7298 luaP:SETARG_A(self:getcode(fs, e), fs.freereg);
7299 luaK:reserveregs(fs, 1)
7300 end
7301end
7302
7303------------------------------------------------------------------------
7304--
7305-- * used in luaK:dischargevars(), (lparser) luaY:assignment()
7306------------------------------------------------------------------------
7307function luaK:setoneret(fs, e)
7308 if e.k == "VCALL" then -- expression is an open function call?
7309 e.k = "VNONRELOC"
7310 e.info = luaP:GETARG_A(self:getcode(fs, e))
7311 elseif e.k == "VVARARG" then
7312 luaP:SETARG_B(self:getcode(fs, e), 2)
7313 e.k = "VRELOCABLE" -- can relocate its simple result
7314 end
7315end
7316
7317------------------------------------------------------------------------
7318--
7319-- * used in multiple locations
7320------------------------------------------------------------------------
7321function luaK:dischargevars(fs, e)
7322 local k = e.k
7323 if k == "VLOCAL" then
7324 e.k = "VNONRELOC"
7325 elseif k == "VUPVAL" then
7326 e.info = self:codeABC(fs, "OP_GETUPVAL", 0, e.info, 0)
7327 e.k = "VRELOCABLE"
7328 elseif k == "VGLOBAL" then
7329 e.info = self:codeABx(fs, "OP_GETGLOBAL", 0, e.info)
7330 e.k = "VRELOCABLE"
7331 elseif k == "VINDEXED" then
7332 self:freereg(fs, e.aux)
7333 self:freereg(fs, e.info)
7334 e.info = self:codeABC(fs, "OP_GETTABLE", 0, e.info, e.aux)
7335 e.k = "VRELOCABLE"
7336 elseif k == "VVARARG" or k == "VCALL" then
7337 self:setoneret(fs, e)
7338 else
7339 -- there is one value available (somewhere)
7340 end
7341end
7342
7343------------------------------------------------------------------------
7344--
7345-- * used only in luaK:exp2reg()
7346------------------------------------------------------------------------
7347function luaK:code_label(fs, A, b, jump)
7348 self:getlabel(fs) -- those instructions may be jump targets
7349 return self:codeABC(fs, "OP_LOADBOOL", A, b, jump)
7350end
7351
7352------------------------------------------------------------------------
7353--
7354-- * used in luaK:discharge2anyreg(), luaK:exp2reg()
7355------------------------------------------------------------------------
7356function luaK:discharge2reg(fs, e, reg)
7357 self:dischargevars(fs, e)
7358 local k = e.k
7359 if k == "VNIL" then
7360 self:_nil(fs, reg, 1)
7361 elseif k == "VFALSE" or k == "VTRUE" then
7362 self:codeABC(fs, "OP_LOADBOOL", reg, (e.k == "VTRUE") and 1 or 0, 0)
7363 elseif k == "VK" then
7364 self:codeABx(fs, "OP_LOADK", reg, e.info)
7365 elseif k == "VKNUM" then
7366 self:codeABx(fs, "OP_LOADK", reg, self:numberK(fs, e.nval))
7367 elseif k == "VRELOCABLE" then
7368 local pc = self:getcode(fs, e)
7369 luaP:SETARG_A(pc, reg)
7370 elseif k == "VNONRELOC" then
7371 if reg ~= e.info then
7372 self:codeABC(fs, "OP_MOVE", reg, e.info, 0)
7373 end
7374 else
7375 assert(e.k == "VVOID" or e.k == "VJMP")
7376 return -- nothing to do...
7377 end
7378 e.info = reg
7379 e.k = "VNONRELOC"
7380end
7381
7382------------------------------------------------------------------------
7383--
7384-- * used in luaK:jumponcond(), luaK:codenot()
7385------------------------------------------------------------------------
7386function luaK:discharge2anyreg(fs, e)
7387 if e.k ~= "VNONRELOC" then
7388 self:reserveregs(fs, 1)
7389 self:discharge2reg(fs, e, fs.freereg - 1)
7390 end
7391end
7392
7393------------------------------------------------------------------------
7394--
7395-- * used in luaK:exp2nextreg(), luaK:exp2anyreg(), luaK:storevar()
7396------------------------------------------------------------------------
7397function luaK:exp2reg(fs, e, reg)
7398 self:discharge2reg(fs, e, reg)
7399 if e.k == "VJMP" then
7400 e.t = self:concat(fs, e.t, e.info) -- put this jump in 't' list
7401 end
7402 if self:hasjumps(e) then
7403 local final -- position after whole expression
7404 local p_f = self.NO_JUMP -- position of an eventual LOAD false
7405 local p_t = self.NO_JUMP -- position of an eventual LOAD true
7406 if self:need_value(fs, e.t) or self:need_value(fs, e.f) then
7407 local fj = (e.k == "VJMP") and self.NO_JUMP or self:jump(fs)
7408 p_f = self:code_label(fs, reg, 0, 1)
7409 p_t = self:code_label(fs, reg, 1, 0)
7410 self:patchtohere(fs, fj)
7411 end
7412 final = self:getlabel(fs)
7413 self:patchlistaux(fs, e.f, final, reg, p_f)
7414 self:patchlistaux(fs, e.t, final, reg, p_t)
7415 end
7416 e.f, e.t = self.NO_JUMP, self.NO_JUMP
7417 e.info = reg
7418 e.k = "VNONRELOC"
7419end
7420
7421------------------------------------------------------------------------
7422--
7423-- * used in multiple locations
7424------------------------------------------------------------------------
7425function luaK:exp2nextreg(fs, e)
7426 self:dischargevars(fs, e)
7427 self:freeexp(fs, e)
7428 self:reserveregs(fs, 1)
7429 self:exp2reg(fs, e, fs.freereg - 1)
7430end
7431
7432------------------------------------------------------------------------
7433--
7434-- * used in multiple locations
7435------------------------------------------------------------------------
7436function luaK:exp2anyreg(fs, e)
7437 self:dischargevars(fs, e)
7438 if e.k == "VNONRELOC" then
7439 if not self:hasjumps(e) then -- exp is already in a register
7440 return e.info
7441 end
7442 if e.info >= fs.nactvar then -- reg. is not a local?
7443 self:exp2reg(fs, e, e.info) -- put value on it
7444 return e.info
7445 end
7446 end
7447 self:exp2nextreg(fs, e) -- default
7448 return e.info
7449end
7450
7451------------------------------------------------------------------------
7452--
7453-- * used in luaK:exp2RK(), luaK:prefix(), luaK:posfix()
7454-- * used in (lparser) luaY:yindex()
7455------------------------------------------------------------------------
7456function luaK:exp2val(fs, e)
7457 if self:hasjumps(e) then
7458 self:exp2anyreg(fs, e)
7459 else
7460 self:dischargevars(fs, e)
7461 end
7462end
7463
7464------------------------------------------------------------------------
7465--
7466-- * used in multiple locations
7467------------------------------------------------------------------------
7468function luaK:exp2RK(fs, e)
7469 self:exp2val(fs, e)
7470 local k = e.k
7471 if k == "VKNUM" or k == "VTRUE" or k == "VFALSE" or k == "VNIL" then
7472 if fs.nk <= luaP.MAXINDEXRK then -- constant fit in RK operand?
7473 -- converted from a 2-deep ternary operator expression
7474 if e.k == "VNIL" then
7475 e.info = self:nilK(fs)
7476 else
7477 e.info = (e.k == "VKNUM") and self:numberK(fs, e.nval)
7478 or self:boolK(fs, e.k == "VTRUE")
7479 end
7480 e.k = "VK"
7481 return luaP:RKASK(e.info)
7482 end
7483 elseif k == "VK" then
7484 if e.info <= luaP.MAXINDEXRK then -- constant fit in argC?
7485 return luaP:RKASK(e.info)
7486 end
7487 else
7488 -- default
7489 end
7490 -- not a constant in the right range: put it in a register
7491 return self:exp2anyreg(fs, e)
7492end
7493
7494------------------------------------------------------------------------
7495--
7496-- * used in (lparser) luaY:assignment(), luaY:localfunc(), luaY:funcstat()
7497------------------------------------------------------------------------
7498function luaK:storevar(fs, var, ex)
7499 local k = var.k
7500 if k == "VLOCAL" then
7501 self:freeexp(fs, ex)
7502 self:exp2reg(fs, ex, var.info)
7503 return
7504 elseif k == "VUPVAL" then
7505 local e = self:exp2anyreg(fs, ex)
7506 self:codeABC(fs, "OP_SETUPVAL", e, var.info, 0)
7507 elseif k == "VGLOBAL" then
7508 local e = self:exp2anyreg(fs, ex)
7509 self:codeABx(fs, "OP_SETGLOBAL", e, var.info)
7510 elseif k == "VINDEXED" then
7511 local e = self:exp2RK(fs, ex)
7512 self:codeABC(fs, "OP_SETTABLE", var.info, var.aux, e)
7513 else
7514 assert(0) -- invalid var kind to store
7515 end
7516 self:freeexp(fs, ex)
7517end
7518
7519------------------------------------------------------------------------
7520--
7521-- * used only in (lparser) luaY:primaryexp()
7522------------------------------------------------------------------------
7523function luaK:_self(fs, e, key)
7524 self:exp2anyreg(fs, e)
7525 self:freeexp(fs, e)
7526 local func = fs.freereg
7527 self:reserveregs(fs, 2)
7528 self:codeABC(fs, "OP_SELF", func, e.info, self:exp2RK(fs, key))
7529 self:freeexp(fs, key)
7530 e.info = func
7531 e.k = "VNONRELOC"
7532end
7533
7534------------------------------------------------------------------------
7535--
7536-- * used in luaK:goiftrue(), luaK:codenot()
7537------------------------------------------------------------------------
7538function luaK:invertjump(fs, e)
7539 local pc = self:getjumpcontrol(fs, e.info)
7540 assert(luaP:testTMode(luaP:GET_OPCODE(pc)) ~= 0 and
7541 luaP:GET_OPCODE(pc) ~= "OP_TESTSET" and
7542 luaP:GET_OPCODE(pc) ~= "OP_TEST")
7543 luaP:SETARG_A(pc, (luaP:GETARG_A(pc) == 0) and 1 or 0)
7544end
7545
7546------------------------------------------------------------------------
7547--
7548-- * used in luaK:goiftrue(), luaK:goiffalse()
7549------------------------------------------------------------------------
7550function luaK:jumponcond(fs, e, cond)
7551 if e.k == "VRELOCABLE" then
7552 local ie = self:getcode(fs, e)
7553 if luaP:GET_OPCODE(ie) == "OP_NOT" then
7554 fs.pc = fs.pc - 1 -- remove previous OP_NOT
7555 return self:condjump(fs, "OP_TEST", luaP:GETARG_B(ie), 0, cond and 0 or 1)
7556 end
7557 -- else go through
7558 end
7559 self:discharge2anyreg(fs, e)
7560 self:freeexp(fs, e)
7561 return self:condjump(fs, "OP_TESTSET", luaP.NO_REG, e.info, cond and 1 or 0)
7562end
7563
7564------------------------------------------------------------------------
7565--
7566-- * used in luaK:infix(), (lparser) luaY:cond()
7567------------------------------------------------------------------------
7568function luaK:goiftrue(fs, e)
7569 local pc -- pc of last jump
7570 self:dischargevars(fs, e)
7571 local k = e.k
7572 if k == "VK" or k == "VKNUM" or k == "VTRUE" then
7573 pc = self.NO_JUMP -- always true; do nothing
7574 elseif k == "VFALSE" then
7575 pc = self:jump(fs) -- always jump
7576 elseif k == "VJMP" then
7577 self:invertjump(fs, e)
7578 pc = e.info
7579 else
7580 pc = self:jumponcond(fs, e, false)
7581 end
7582 e.f = self:concat(fs, e.f, pc) -- insert last jump in `f' list
7583 self:patchtohere(fs, e.t)
7584 e.t = self.NO_JUMP
7585end
7586
7587------------------------------------------------------------------------
7588--
7589-- * used in luaK:infix()
7590------------------------------------------------------------------------
7591function luaK:goiffalse(fs, e)
7592 local pc -- pc of last jump
7593 self:dischargevars(fs, e)
7594 local k = e.k
7595 if k == "VNIL" or k == "VFALSE"then
7596 pc = self.NO_JUMP -- always false; do nothing
7597 elseif k == "VTRUE" then
7598 pc = self:jump(fs) -- always jump
7599 elseif k == "VJMP" then
7600 pc = e.info
7601 else
7602 pc = self:jumponcond(fs, e, true)
7603 end
7604 e.t = self:concat(fs, e.t, pc) -- insert last jump in `t' list
7605 self:patchtohere(fs, e.f)
7606 e.f = self.NO_JUMP
7607end
7608
7609------------------------------------------------------------------------
7610--
7611-- * used only in luaK:prefix()
7612------------------------------------------------------------------------
7613function luaK:codenot(fs, e)
7614 self:dischargevars(fs, e)
7615 local k = e.k
7616 if k == "VNIL" or k == "VFALSE" then
7617 e.k = "VTRUE"
7618 elseif k == "VK" or k == "VKNUM" or k == "VTRUE" then
7619 e.k = "VFALSE"
7620 elseif k == "VJMP" then
7621 self:invertjump(fs, e)
7622 elseif k == "VRELOCABLE" or k == "VNONRELOC" then
7623 self:discharge2anyreg(fs, e)
7624 self:freeexp(fs, e)
7625 e.info = self:codeABC(fs, "OP_NOT", 0, e.info, 0)
7626 e.k = "VRELOCABLE"
7627 else
7628 assert(0) -- cannot happen
7629 end
7630 -- interchange true and false lists
7631 e.f, e.t = e.t, e.f
7632 self:removevalues(fs, e.f)
7633 self:removevalues(fs, e.t)
7634end
7635
7636------------------------------------------------------------------------
7637--
7638-- * used in (lparser) luaY:field(), luaY:primaryexp()
7639------------------------------------------------------------------------
7640function luaK:indexed(fs, t, k)
7641 t.aux = self:exp2RK(fs, k)
7642 t.k = "VINDEXED"
7643end
7644
7645------------------------------------------------------------------------
7646--
7647-- * used only in luaK:codearith()
7648------------------------------------------------------------------------
7649function luaK:constfolding(op, e1, e2)
7650 local r
7651 if not self:isnumeral(e1) or not self:isnumeral(e2) then return false end
7652 local v1 = e1.nval
7653 local v2 = e2.nval
7654 if op == "OP_ADD" then
7655 r = self:numadd(v1, v2)
7656 elseif op == "OP_SUB" then
7657 r = self:numsub(v1, v2)
7658 elseif op == "OP_MUL" then
7659 r = self:nummul(v1, v2)
7660 elseif op == "OP_DIV" then
7661 if v2 == 0 then return false end -- do not attempt to divide by 0
7662 r = self:numdiv(v1, v2)
7663 elseif op == "OP_MOD" then
7664 if v2 == 0 then return false end -- do not attempt to divide by 0
7665 r = self:nummod(v1, v2)
7666 elseif op == "OP_POW" then
7667 r = self:numpow(v1, v2)
7668 elseif op == "OP_UNM" then
7669 r = self:numunm(v1)
7670 elseif op == "OP_LEN" then
7671 return false -- no constant folding for 'len'
7672 else
7673 assert(0)
7674 r = 0
7675 end
7676 if self:numisnan(r) then return false end -- do not attempt to produce NaN
7677 e1.nval = r
7678 return true
7679end
7680
7681------------------------------------------------------------------------
7682--
7683-- * used in luaK:prefix(), luaK:posfix()
7684------------------------------------------------------------------------
7685function luaK:codearith(fs, op, e1, e2)
7686 if self:constfolding(op, e1, e2) then
7687 return
7688 else
7689 local o2 = (op ~= "OP_UNM" and op ~= "OP_LEN") and self:exp2RK(fs, e2) or 0
7690 local o1 = self:exp2RK(fs, e1)
7691 if o1 > o2 then
7692 self:freeexp(fs, e1)
7693 self:freeexp(fs, e2)
7694 else
7695 self:freeexp(fs, e2)
7696 self:freeexp(fs, e1)
7697 end
7698 e1.info = self:codeABC(fs, op, 0, o1, o2)
7699 e1.k = "VRELOCABLE"
7700 end
7701end
7702
7703------------------------------------------------------------------------
7704--
7705-- * used only in luaK:posfix()
7706------------------------------------------------------------------------
7707function luaK:codecomp(fs, op, cond, e1, e2)
7708 local o1 = self:exp2RK(fs, e1)
7709 local o2 = self:exp2RK(fs, e2)
7710 self:freeexp(fs, e2)
7711 self:freeexp(fs, e1)
7712 if cond == 0 and op ~= "OP_EQ" then
7713 -- exchange args to replace by `<' or `<='
7714 o1, o2 = o2, o1 -- o1 <==> o2
7715 cond = 1
7716 end
7717 e1.info = self:condjump(fs, op, cond, o1, o2)
7718 e1.k = "VJMP"
7719end
7720
7721------------------------------------------------------------------------
7722--
7723-- * used only in (lparser) luaY:subexpr()
7724------------------------------------------------------------------------
7725function luaK:prefix(fs, op, e)
7726 local e2 = {} -- expdesc
7727 e2.t, e2.f = self.NO_JUMP, self.NO_JUMP
7728 e2.k = "VKNUM"
7729 e2.nval = 0
7730 if op == "OPR_MINUS" then
7731 if not self:isnumeral(e) then
7732 self:exp2anyreg(fs, e) -- cannot operate on non-numeric constants
7733 end
7734 self:codearith(fs, "OP_UNM", e, e2)
7735 elseif op == "OPR_NOT" then
7736 self:codenot(fs, e)
7737 elseif op == "OPR_LEN" then
7738 self:exp2anyreg(fs, e) -- cannot operate on constants
7739 self:codearith(fs, "OP_LEN", e, e2)
7740 else
7741 assert(0)
7742 end
7743end
7744
7745------------------------------------------------------------------------
7746--
7747-- * used only in (lparser) luaY:subexpr()
7748------------------------------------------------------------------------
7749function luaK:infix(fs, op, v)
7750 if op == "OPR_AND" then
7751 self:goiftrue(fs, v)
7752 elseif op == "OPR_OR" then
7753 self:goiffalse(fs, v)
7754 elseif op == "OPR_CONCAT" then
7755 self:exp2nextreg(fs, v) -- operand must be on the 'stack'
7756 elseif op == "OPR_ADD" or op == "OPR_SUB" or
7757 op == "OPR_MUL" or op == "OPR_DIV" or
7758 op == "OPR_MOD" or op == "OPR_POW" then
7759 if not self:isnumeral(v) then self:exp2RK(fs, v) end
7760 else
7761 self:exp2RK(fs, v)
7762 end
7763end
7764
7765------------------------------------------------------------------------
7766--
7767-- * used only in (lparser) luaY:subexpr()
7768------------------------------------------------------------------------
7769-- table lookups to simplify testing
7770luaK.arith_op = {
7771 OPR_ADD = "OP_ADD", OPR_SUB = "OP_SUB", OPR_MUL = "OP_MUL",
7772 OPR_DIV = "OP_DIV", OPR_MOD = "OP_MOD", OPR_POW = "OP_POW",
7773}
7774luaK.comp_op = {
7775 OPR_EQ = "OP_EQ", OPR_NE = "OP_EQ", OPR_LT = "OP_LT",
7776 OPR_LE = "OP_LE", OPR_GT = "OP_LT", OPR_GE = "OP_LE",
7777}
7778luaK.comp_cond = {
7779 OPR_EQ = 1, OPR_NE = 0, OPR_LT = 1,
7780 OPR_LE = 1, OPR_GT = 0, OPR_GE = 0,
7781}
7782function luaK:posfix(fs, op, e1, e2)
7783 -- needed because e1 = e2 doesn't copy values...
7784 -- * in 5.0.x, only k/info/aux/t/f copied, t for AND, f for OR
7785 -- but here, all elements are copied for completeness' sake
7786 local function copyexp(e1, e2)
7787 e1.k = e2.k
7788 e1.info = e2.info; e1.aux = e2.aux
7789 e1.nval = e2.nval
7790 e1.t = e2.t; e1.f = e2.f
7791 end
7792 if op == "OPR_AND" then
7793 assert(e1.t == self.NO_JUMP) -- list must be closed
7794 self:dischargevars(fs, e2)
7795 e2.f = self:concat(fs, e2.f, e1.f)
7796 copyexp(e1, e2)
7797 elseif op == "OPR_OR" then
7798 assert(e1.f == self.NO_JUMP) -- list must be closed
7799 self:dischargevars(fs, e2)
7800 e2.t = self:concat(fs, e2.t, e1.t)
7801 copyexp(e1, e2)
7802 elseif op == "OPR_CONCAT" then
7803 self:exp2val(fs, e2)
7804 if e2.k == "VRELOCABLE" and luaP:GET_OPCODE(self:getcode(fs, e2)) == "OP_CONCAT" then
7805 assert(e1.info == luaP:GETARG_B(self:getcode(fs, e2)) - 1)
7806 self:freeexp(fs, e1)
7807 luaP:SETARG_B(self:getcode(fs, e2), e1.info)
7808 e1.k = "VRELOCABLE"
7809 e1.info = e2.info
7810 else
7811 self:exp2nextreg(fs, e2) -- operand must be on the 'stack'
7812 self:codearith(fs, "OP_CONCAT", e1, e2)
7813 end
7814 else
7815 -- the following uses a table lookup in place of conditionals
7816 local arith = self.arith_op[op]
7817 if arith then
7818 self:codearith(fs, arith, e1, e2)
7819 else
7820 local comp = self.comp_op[op]
7821 if comp then
7822 self:codecomp(fs, comp, self.comp_cond[op], e1, e2)
7823 else
7824 assert(0)
7825 end
7826 end--if arith
7827 end--if op
7828end
7829
7830------------------------------------------------------------------------
7831-- adjusts debug information for last instruction written, in order to
7832-- change the line where item comes into existence
7833-- * used in (lparser) luaY:funcargs(), luaY:forbody(), luaY:funcstat()
7834------------------------------------------------------------------------
7835function luaK:fixline(fs, line)
7836 fs.f.lineinfo[fs.pc - 1] = line
7837end
7838
7839------------------------------------------------------------------------
7840-- general function to write an instruction into the instruction buffer,
7841-- sets debug information too
7842-- * used in luaK:codeABC(), luaK:codeABx()
7843-- * called directly by (lparser) luaY:whilestat()
7844------------------------------------------------------------------------
7845function luaK:code(fs, i, line)
7846 local f = fs.f
7847 self:dischargejpc(fs) -- 'pc' will change
7848 -- put new instruction in code array
7849 luaY:growvector(fs.L, f.code, fs.pc, f.sizecode, nil,
7850 luaY.MAX_INT, "code size overflow")
7851 f.code[fs.pc] = i
7852 -- save corresponding line information
7853 luaY:growvector(fs.L, f.lineinfo, fs.pc, f.sizelineinfo, nil,
7854 luaY.MAX_INT, "code size overflow")
7855 f.lineinfo[fs.pc] = line
7856 local pc = fs.pc
7857 fs.pc = fs.pc + 1
7858 return pc
7859end
7860
7861------------------------------------------------------------------------
7862-- writes an instruction of type ABC
7863-- * calls luaK:code()
7864------------------------------------------------------------------------
7865function luaK:codeABC(fs, o, a, b, c)
7866 assert(luaP:getOpMode(o) == luaP.OpMode.iABC)
7867 assert(luaP:getBMode(o) ~= luaP.OpArgMask.OpArgN or b == 0)
7868 assert(luaP:getCMode(o) ~= luaP.OpArgMask.OpArgN or c == 0)
7869 return self:code(fs, luaP:CREATE_ABC(o, a, b, c), fs.ls.lastline)
7870end
7871
7872------------------------------------------------------------------------
7873-- writes an instruction of type ABx
7874-- * calls luaK:code(), called by luaK:codeAsBx()
7875------------------------------------------------------------------------
7876function luaK:codeABx(fs, o, a, bc)
7877 assert(luaP:getOpMode(o) == luaP.OpMode.iABx or
7878 luaP:getOpMode(o) == luaP.OpMode.iAsBx)
7879 assert(luaP:getCMode(o) == luaP.OpArgMask.OpArgN)
7880 return self:code(fs, luaP:CREATE_ABx(o, a, bc), fs.ls.lastline)
7881end
7882
7883------------------------------------------------------------------------
7884--
7885-- * used in (lparser) luaY:closelistfield(), luaY:lastlistfield()
7886------------------------------------------------------------------------
7887function luaK:setlist(fs, base, nelems, tostore)
7888 local c = math.floor((nelems - 1)/luaP.LFIELDS_PER_FLUSH) + 1
7889 local b = (tostore == luaY.LUA_MULTRET) and 0 or tostore
7890 assert(tostore ~= 0)
7891 if c <= luaP.MAXARG_C then
7892 self:codeABC(fs, "OP_SETLIST", base, b, c)
7893 else
7894 self:codeABC(fs, "OP_SETLIST", base, b, 0)
7895 self:code(fs, luaP:CREATE_Inst(c), fs.ls.lastline)
7896 end
7897 fs.freereg = base + 1 -- free registers with list values
7898end
7899
7900return function(a) luaY = a return luaK end]]></ProtectedString>
7901 <BinaryString name="Tags"></BinaryString>
7902 </Properties>
7903 </Item>
7904 <Item class="ModuleScript" referent="RBX82A08A032D8747CFA198FEA2A95DD5E2">
7905 <Properties>
7906 <Content name="LinkedSource"><null></null></Content>
7907 <string name="Name">LuaU</string>
7908 <string name="ScriptGuid">{21232045-4BF5-4A9E-A6DA-AC03A546A2E7}</string>
7909 <ProtectedString name="Source"><![CDATA[local type = type;
7910local table = table;
7911local string = string;
7912local error = error;
7913local debug = debug;
7914local require = require;
7915local version = version;
7916local math = math;
7917local assert = assert;
7918
7919--[[--------------------------------------------------------------------
7920
7921 ldump.lua
7922 Save precompiled Lua chunks
7923 This file is part of Yueliang.
7924
7925 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
7926 The COPYRIGHT file describes the conditions
7927 under which this software may be distributed.
7928
7929 See the ChangeLog for more information.
7930
7931----------------------------------------------------------------------]]
7932
7933--[[--------------------------------------------------------------------
7934-- Notes:
7935-- * WARNING! byte order (little endian) and data type sizes for header
7936-- signature values hard-coded; see luaU:header
7937-- * chunk writer generators are included, see below
7938-- * one significant difference is that instructions are still in table
7939-- form (with OP/A/B/C/Bx fields) and luaP:Instruction() is needed to
7940-- convert them into 4-char strings
7941--
7942-- Not implemented:
7943-- * DumpVar, DumpMem has been removed
7944-- * DumpVector folded into folded into DumpDebug, DumpCode
7945--
7946-- Added:
7947-- * for convenience, the following two functions have been added:
7948-- luaU:make_setS: create a chunk writer that writes to a string
7949-- luaU:make_setF: create a chunk writer that writes to a file
7950-- (lua.h contains a typedef for lua_Writer/lua_Chunkwriter, and
7951-- a Lua-based implementation exists, writer() in lstrlib.c)
7952-- * luaU:ttype(o) (from lobject.h)
7953-- * for converting number types to its binary equivalent:
7954-- luaU:from_double(x): encode double value for writing
7955-- luaU:from_int(x): encode integer value for writing
7956-- (error checking is limited for these conversion functions)
7957-- (double conversion does not support denormals or NaNs)
7958--
7959-- Changed in 5.1.x:
7960-- * the dumper was mostly rewritten in Lua 5.1.x, so notes on the
7961-- differences between 5.0.x and 5.1.x is limited
7962-- * LUAC_VERSION bumped to 0x51, LUAC_FORMAT added
7963-- * developer is expected to adjust LUAC_FORMAT in order to identify
7964-- non-standard binary chunk formats
7965-- * header signature code is smaller, has been simplified, and is
7966-- tested as a single unit; its logic is shared with the undumper
7967-- * no more endian conversion, invalid endianness mean rejection
7968-- * opcode field sizes are no longer exposed in the header
7969-- * code moved to front of a prototype, followed by constants
7970-- * debug information moved to the end of the binary chunk, and the
7971-- relevant functions folded into a single function
7972-- * luaU:dump returns a writer status code
7973-- * chunk writer now implements status code because dumper uses it
7974-- * luaU:endianness removed
7975----------------------------------------------------------------------]]
7976
7977--requires luaP
7978local luaU = {}
7979local luaP = require(script.Parent.LuaP)
7980
7981-- mark for precompiled code ('<esc>Lua') (from lua.h)
7982luaU.LUA_SIGNATURE = "\27Lua"
7983
7984-- constants used by dumper (from lua.h)
7985luaU.LUA_TNUMBER = 3
7986luaU.LUA_TSTRING = 4
7987luaU.LUA_TNIL = 0
7988luaU.LUA_TBOOLEAN = 1
7989luaU.LUA_TNONE = -1
7990
7991-- constants for header of binary files (from lundump.h)
7992luaU.LUAC_VERSION = 0x51 -- this is Lua 5.1
7993luaU.LUAC_FORMAT = 0 -- this is the official format
7994luaU.LUAC_HEADERSIZE = 12 -- size of header of binary files
7995
7996--[[--------------------------------------------------------------------
7997-- Additional functions to handle chunk writing
7998-- * to use make_setS and make_setF, see test_ldump.lua elsewhere
7999----------------------------------------------------------------------]]
8000
8001------------------------------------------------------------------------
8002-- create a chunk writer that writes to a string
8003-- * returns the writer function and a table containing the string
8004-- * to get the final result, look in buff.data
8005------------------------------------------------------------------------
8006function luaU:make_setS()
8007 local buff = {}
8008 buff.data = ""
8009 local writer =
8010 function(s, buff) -- chunk writer
8011 if not s then return 0 end
8012 buff.data = buff.data..s
8013 return 0
8014 end
8015 return writer, buff
8016end
8017
8018------------------------------------------------------------------------
8019-- create a chunk writer that writes to a file
8020-- * returns the writer function and a table containing the file handle
8021-- * if a nil is passed, then writer should close the open file
8022------------------------------------------------------------------------
8023
8024--[[
8025function luaU:make_setF(filename)
8026 local buff = {}
8027 buff.h = io.open(filename, "wb")
8028 if not buff.h then return nil end
8029 local writer =
8030 function(s, buff) -- chunk writer
8031 if not buff.h then return 0 end
8032 if not s then
8033 if buff.h:close() then return 0 end
8034 else
8035 if buff.h:write(s) then return 0 end
8036 end
8037 return 1
8038 end
8039 return writer, buff
8040end--]]
8041
8042------------------------------------------------------------------------
8043-- works like the lobject.h version except that TObject used in these
8044-- scripts only has a 'value' field, no 'tt' field (native types used)
8045------------------------------------------------------------------------
8046function luaU:ttype(o)
8047 local tt = type(o.value)
8048 if tt == "number" then return self.LUA_TNUMBER
8049 elseif tt == "string" then return self.LUA_TSTRING
8050 elseif tt == "nil" then return self.LUA_TNIL
8051 elseif tt == "boolean" then return self.LUA_TBOOLEAN
8052 else
8053 return self.LUA_TNONE -- the rest should not appear
8054 end
8055end
8056
8057-----------------------------------------------------------------------
8058-- converts a IEEE754 double number to an 8-byte little-endian string
8059-- * luaU:from_double() and luaU:from_int() are adapted from ChunkBake
8060-- * supports +/- Infinity, but not denormals or NaNs
8061-----------------------------------------------------------------------
8062function luaU:from_double(x)
8063 local function grab_byte(v)
8064 local c = v % 256
8065 return (v - c) / 256, string.char(c)
8066 end
8067 local sign = 0
8068 if x < 0 then sign = 1; x = -x end
8069 local mantissa, exponent = math.frexp(x)
8070 if x == 0 then -- zero
8071 mantissa, exponent = 0, 0
8072 elseif x == 1/0 then
8073 mantissa, exponent = 0, 2047
8074 else
8075 mantissa = (mantissa * 2 - 1) * math.ldexp(0.5, 53)
8076 exponent = exponent + 1022
8077 end
8078 local v, byte = "" -- convert to bytes
8079 x = math.floor(mantissa)
8080 for i = 1,6 do
8081 x, byte = grab_byte(x); v = v..byte -- 47:0
8082 end
8083 x, byte = grab_byte(exponent * 16 + x); v = v..byte -- 55:48
8084 x, byte = grab_byte(sign * 128 + x); v = v..byte -- 63:56
8085 return v
8086end
8087
8088-----------------------------------------------------------------------
8089-- converts a number to a little-endian 32-bit integer string
8090-- * input value assumed to not overflow, can be signed/unsigned
8091-----------------------------------------------------------------------
8092function luaU:from_int(x)
8093 local v = ""
8094 x = math.floor(x)
8095 if x < 0 then x = 4294967296 + x end -- ULONG_MAX+1
8096 for i = 1, 4 do
8097 local c = x % 256
8098 v = v..string.char(c); x = math.floor(x / 256)
8099 end
8100 return v
8101end
8102
8103--[[--------------------------------------------------------------------
8104-- Functions to make a binary chunk
8105-- * many functions have the size parameter removed, since output is
8106-- in the form of a string and some sizes are implicit or hard-coded
8107----------------------------------------------------------------------]]
8108
8109--[[--------------------------------------------------------------------
8110-- struct DumpState:
8111-- L -- lua_State (not used in this script)
8112-- writer -- lua_Writer (chunk writer function)
8113-- data -- void* (chunk writer context or data already written)
8114-- strip -- if true, don't write any debug information
8115-- status -- if non-zero, an error has occured
8116----------------------------------------------------------------------]]
8117
8118------------------------------------------------------------------------
8119-- dumps a block of bytes
8120-- * lua_unlock(D.L), lua_lock(D.L) unused
8121------------------------------------------------------------------------
8122function luaU:DumpBlock(b, D)
8123 if D.status == 0 then
8124 -- lua_unlock(D->L);
8125 D.status = D.write(b, D.data)
8126 -- lua_lock(D->L);
8127 end
8128end
8129
8130------------------------------------------------------------------------
8131-- dumps a char
8132------------------------------------------------------------------------
8133function luaU:DumpChar(y, D)
8134 self:DumpBlock(string.char(y), D)
8135end
8136
8137------------------------------------------------------------------------
8138-- dumps a 32-bit signed or unsigned integer (for int) (hard-coded)
8139------------------------------------------------------------------------
8140function luaU:DumpInt(x, D)
8141 self:DumpBlock(self:from_int(x), D)
8142end
8143
8144------------------------------------------------------------------------
8145-- dumps a lua_Number (hard-coded as a double)
8146------------------------------------------------------------------------
8147function luaU:DumpNumber(x, D)
8148 self:DumpBlock(self:from_double(x), D)
8149end
8150
8151------------------------------------------------------------------------
8152-- dumps a Lua string (size type is hard-coded)
8153------------------------------------------------------------------------
8154function luaU:DumpString(s, D)
8155 if s == nil then
8156 self:DumpInt(0, D)
8157 else
8158 s = s.."\0" -- include trailing '\0'
8159 self:DumpInt(#s, D)
8160 self:DumpBlock(s, D)
8161 end
8162end
8163
8164------------------------------------------------------------------------
8165-- dumps instruction block from function prototype
8166------------------------------------------------------------------------
8167function luaU:DumpCode(f, D)
8168 local n = f.sizecode
8169 --was DumpVector
8170 self:DumpInt(n, D)
8171 for i = 0, n - 1 do
8172 self:DumpBlock(luaP:Instruction(f.code[i]), D)
8173 end
8174end
8175
8176------------------------------------------------------------------------
8177-- dump constant pool from function prototype
8178-- * bvalue(o), nvalue(o) and rawtsvalue(o) macros removed
8179------------------------------------------------------------------------
8180function luaU:DumpConstants(f, D)
8181 local n = f.sizek
8182 self:DumpInt(n, D)
8183 for i = 0, n - 1 do
8184 local o = f.k[i] -- TValue
8185 local tt = self:ttype(o)
8186 self:DumpChar(tt, D)
8187 if tt == self.LUA_TNIL then
8188 elseif tt == self.LUA_TBOOLEAN then
8189 self:DumpChar(o.value and 1 or 0, D)
8190 elseif tt == self.LUA_TNUMBER then
8191 self:DumpNumber(o.value, D)
8192 elseif tt == self.LUA_TSTRING then
8193 self:DumpString(o.value, D)
8194 else
8195 --lua_assert(0) -- cannot happen
8196 end
8197 end
8198 n = f.sizep
8199 self:DumpInt(n, D)
8200 for i = 0, n - 1 do
8201 self:DumpFunction(f.p[i], f.source, D)
8202 end
8203end
8204
8205------------------------------------------------------------------------
8206-- dump debug information
8207------------------------------------------------------------------------
8208function luaU:DumpDebug(f, D)
8209 local n
8210 n = D.strip and 0 or f.sizelineinfo -- dump line information
8211 --was DumpVector
8212 self:DumpInt(n, D)
8213 for i = 0, n - 1 do
8214 self:DumpInt(f.lineinfo[i], D)
8215 end
8216 n = D.strip and 0 or f.sizelocvars -- dump local information
8217 self:DumpInt(n, D)
8218 for i = 0, n - 1 do
8219 self:DumpString(f.locvars[i].varname, D)
8220 self:DumpInt(f.locvars[i].startpc, D)
8221 self:DumpInt(f.locvars[i].endpc, D)
8222 end
8223 n = D.strip and 0 or f.sizeupvalues -- dump upvalue information
8224 self:DumpInt(n, D)
8225 for i = 0, n - 1 do
8226 self:DumpString(f.upvalues[i], D)
8227 end
8228end
8229
8230------------------------------------------------------------------------
8231-- dump child function prototypes from function prototype
8232------------------------------------------------------------------------
8233function luaU:DumpFunction(f, p, D)
8234 local source = f.source
8235 if source == p or D.strip then source = nil end
8236 self:DumpString(source, D)
8237 self:DumpInt(f.lineDefined, D)
8238 self:DumpInt(f.lastlinedefined, D)
8239 self:DumpChar(f.nups, D)
8240 self:DumpChar(f.numparams, D)
8241 self:DumpChar(f.is_vararg, D)
8242 self:DumpChar(f.maxstacksize, D)
8243 self:DumpCode(f, D)
8244 self:DumpConstants(f, D)
8245 self:DumpDebug(f, D)
8246end
8247
8248------------------------------------------------------------------------
8249-- dump Lua header section (some sizes hard-coded)
8250------------------------------------------------------------------------
8251function luaU:DumpHeader(D)
8252 local h = self:header()
8253 assert(#h == self.LUAC_HEADERSIZE) -- fixed buffer now an assert
8254 self:DumpBlock(h, D)
8255end
8256
8257------------------------------------------------------------------------
8258-- make header (from lundump.c)
8259-- returns the header string
8260------------------------------------------------------------------------
8261function luaU:header()
8262 local x = 1
8263 return self.LUA_SIGNATURE..
8264 string.char(
8265 self.LUAC_VERSION,
8266 self.LUAC_FORMAT,
8267 x, -- endianness (1=little)
8268 4, -- sizeof(int)
8269 4, -- sizeof(size_t)
8270 4, -- sizeof(Instruction)
8271 8, -- sizeof(lua_Number)
8272 0) -- is lua_Number integral?
8273end
8274
8275------------------------------------------------------------------------
8276-- dump Lua function as precompiled chunk
8277-- (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
8278-- * w, data are created from make_setS, make_setF
8279------------------------------------------------------------------------
8280function luaU:dump(L, f, w, data, strip)
8281 local D = {} -- DumpState
8282 D.L = L
8283 D.write = w
8284 D.data = data
8285 D.strip = strip
8286 D.status = 0
8287 self:DumpHeader(D)
8288 self:DumpFunction(f, nil, D)
8289 -- added: for a chunk writer writing to a file, this final call with
8290 -- nil data is to indicate to the writer to close the file
8291 D.write(nil, D.data)
8292 return D.status
8293end
8294
8295return luaU]]></ProtectedString>
8296 <BinaryString name="Tags"></BinaryString>
8297 </Properties>
8298 </Item>
8299 <Item class="ModuleScript" referent="RBX16DA520961114F59B8CFFD100AB25521">
8300 <Properties>
8301 <Content name="LinkedSource"><null></null></Content>
8302 <string name="Name">LuaP</string>
8303 <string name="ScriptGuid">{D51AF6B4-0317-406B-B194-0A76ADD86A18}</string>
8304 <ProtectedString name="Source"><![CDATA[local table = table;
8305local string = string;
8306local math = math;
8307local tonumber = tonumber;
8308local next = next;
8309
8310--[[--------------------------------------------------------------------
8311
8312 lopcodes.lua
8313 Lua 5 virtual machine opcodes in Lua
8314 This file is part of Yueliang.
8315
8316 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8317 The COPYRIGHT file describes the conditions
8318 under which this software may be distributed.
8319
8320 See the ChangeLog for more information.
8321
8322----------------------------------------------------------------------]]
8323
8324--[[--------------------------------------------------------------------
8325-- Notes:
8326-- * an Instruction is a table with OP, A, B, C, Bx elements; this
8327-- makes the code easy to follow and should allow instruction handling
8328-- to work with doubles and ints
8329-- * WARNING luaP:Instruction outputs instructions encoded in little-
8330-- endian form and field size and positions are hard-coded
8331--
8332-- Not implemented:
8333-- *
8334--
8335-- Added:
8336-- * luaP:CREATE_Inst(c): create an inst from a number (for OP_SETLIST)
8337-- * luaP:Instruction(i): convert field elements to a 4-char string
8338-- * luaP:DecodeInst(x): convert 4-char string into field elements
8339--
8340-- Changed in 5.1.x:
8341-- * POS_OP added, instruction field positions changed
8342-- * some symbol names may have changed, e.g. LUAI_BITSINT
8343-- * new operators for RK indices: BITRK, ISK(x), INDEXK(r), RKASK(x)
8344-- * OP_MOD, OP_LEN is new
8345-- * OP_TEST is now OP_TESTSET, OP_TEST is new
8346-- * OP_FORLOOP, OP_TFORLOOP adjusted, OP_FORPREP is new
8347-- * OP_TFORPREP deleted
8348-- * OP_SETLIST and OP_SETLISTO merged and extended
8349-- * OP_VARARG is new
8350-- * many changes to implementation of OpMode data
8351----------------------------------------------------------------------]]
8352
8353local luaP = {}
8354
8355--[[
8356===========================================================================
8357 We assume that instructions are unsigned numbers.
8358 All instructions have an opcode in the first 6 bits.
8359 Instructions can have the following fields:
8360 'A' : 8 bits
8361 'B' : 9 bits
8362 'C' : 9 bits
8363 'Bx' : 18 bits ('B' and 'C' together)
8364 'sBx' : signed Bx
8365
8366 A signed argument is represented in excess K; that is, the number
8367 value is the unsigned value minus K. K is exactly the maximum value
8368 for that argument (so that -max is represented by 0, and +max is
8369 represented by 2*max), which is half the maximum for the corresponding
8370 unsigned argument.
8371===========================================================================
8372--]]
8373
8374luaP.OpMode = { iABC = 0, iABx = 1, iAsBx = 2 } -- basic instruction format
8375
8376------------------------------------------------------------------------
8377-- size and position of opcode arguments.
8378-- * WARNING size and position is hard-coded elsewhere in this script
8379------------------------------------------------------------------------
8380luaP.SIZE_C = 9
8381luaP.SIZE_B = 9
8382luaP.SIZE_Bx = luaP.SIZE_C + luaP.SIZE_B
8383luaP.SIZE_A = 8
8384
8385luaP.SIZE_OP = 6
8386
8387luaP.POS_OP = 0
8388luaP.POS_A = luaP.POS_OP + luaP.SIZE_OP
8389luaP.POS_C = luaP.POS_A + luaP.SIZE_A
8390luaP.POS_B = luaP.POS_C + luaP.SIZE_C
8391luaP.POS_Bx = luaP.POS_C
8392
8393------------------------------------------------------------------------
8394-- limits for opcode arguments.
8395-- we use (signed) int to manipulate most arguments,
8396-- so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
8397------------------------------------------------------------------------
8398-- removed "#if SIZE_Bx < BITS_INT-1" test, assume this script is
8399-- running on a Lua VM with double or int as LUA_NUMBER
8400
8401luaP.MAXARG_Bx = math.ldexp(1, luaP.SIZE_Bx) - 1
8402luaP.MAXARG_sBx = math.floor(luaP.MAXARG_Bx / 2) -- 'sBx' is signed
8403
8404luaP.MAXARG_A = math.ldexp(1, luaP.SIZE_A) - 1
8405luaP.MAXARG_B = math.ldexp(1, luaP.SIZE_B) - 1
8406luaP.MAXARG_C = math.ldexp(1, luaP.SIZE_C) - 1
8407
8408-- creates a mask with 'n' 1 bits at position 'p'
8409-- MASK1(n,p) deleted, not required
8410-- creates a mask with 'n' 0 bits at position 'p'
8411-- MASK0(n,p) deleted, not required
8412
8413--[[--------------------------------------------------------------------
8414 Visual representation for reference:
8415
8416 31 | | | 0 bit position
8417 +-----+-----+-----+----------+
8418 | B | C | A | Opcode | iABC format
8419 +-----+-----+-----+----------+
8420 - 9 - 9 - 8 - 6 - field sizes
8421 +-----+-----+-----+----------+
8422 | [s]Bx | A | Opcode | iABx | iAsBx format
8423 +-----+-----+-----+----------+
8424
8425----------------------------------------------------------------------]]
8426
8427------------------------------------------------------------------------
8428-- the following macros help to manipulate instructions
8429-- * changed to a table object representation, very clean compared to
8430-- the [nightmare] alternatives of using a number or a string
8431-- * Bx is a separate element from B and C, since there is never a need
8432-- to split Bx in the parser or code generator
8433------------------------------------------------------------------------
8434
8435-- these accept or return opcodes in the form of string names
8436function luaP:GET_OPCODE(i) return self.ROpCode[i.OP] end
8437function luaP:SET_OPCODE(i, o) i.OP = self.OpCode[o] end
8438
8439function luaP:GETARG_A(i) return i.A end
8440function luaP:SETARG_A(i, u) i.A = u end
8441
8442function luaP:GETARG_B(i) return i.B end
8443function luaP:SETARG_B(i, b) i.B = b end
8444
8445function luaP:GETARG_C(i) return i.C end
8446function luaP:SETARG_C(i, b) i.C = b end
8447
8448function luaP:GETARG_Bx(i) return i.Bx end
8449function luaP:SETARG_Bx(i, b) i.Bx = b end
8450
8451function luaP:GETARG_sBx(i) return i.Bx - self.MAXARG_sBx end
8452function luaP:SETARG_sBx(i, b) i.Bx = b + self.MAXARG_sBx end
8453
8454function luaP:CREATE_ABC(o,a,b,c)
8455 return {OP = self.OpCode[o], A = a, B = b, C = c}
8456end
8457
8458function luaP:CREATE_ABx(o,a,bc)
8459 return {OP = self.OpCode[o], A = a, Bx = bc}
8460end
8461
8462------------------------------------------------------------------------
8463-- create an instruction from a number (for OP_SETLIST)
8464------------------------------------------------------------------------
8465function luaP:CREATE_Inst(c)
8466 local o = c % 64
8467 c = (c - o) / 64
8468 local a = c % 256
8469 c = (c - a) / 256
8470 return self:CREATE_ABx(o, a, c)
8471end
8472
8473------------------------------------------------------------------------
8474-- returns a 4-char string little-endian encoded form of an instruction
8475------------------------------------------------------------------------
8476function luaP:Instruction(i)
8477 if i.Bx then
8478 -- change to OP/A/B/C format
8479 i.C = i.Bx % 512
8480 i.B = (i.Bx - i.C) / 512
8481 end
8482 local I = i.A * 64 + i.OP
8483 local c0 = I % 256
8484 I = i.C * 64 + (I - c0) / 256 -- 6 bits of A left
8485 local c1 = I % 256
8486 I = i.B * 128 + (I - c1) / 256 -- 7 bits of C left
8487 local c2 = I % 256
8488 local c3 = (I - c2) / 256
8489 return string.char(c0, c1, c2, c3)
8490end
8491
8492------------------------------------------------------------------------
8493-- decodes a 4-char little-endian string into an instruction struct
8494------------------------------------------------------------------------
8495function luaP:DecodeInst(x)
8496 local byte = string.byte
8497 local i = {}
8498 local I = byte(x, 1)
8499 local op = I % 64
8500 i.OP = op
8501 I = byte(x, 2) * 4 + (I - op) / 64 -- 2 bits of c0 left
8502 local a = I % 256
8503 i.A = a
8504 I = byte(x, 3) * 4 + (I - a) / 256 -- 2 bits of c1 left
8505 local c = I % 512
8506 i.C = c
8507 i.B = byte(x, 4) * 2 + (I - c) / 512 -- 1 bits of c2 left
8508 local opmode = self.OpMode[tonumber(string.sub(self.opmodes[op + 1], 7, 7))]
8509 if opmode ~= "iABC" then
8510 i.Bx = i.B * 512 + i.C
8511 end
8512 return i
8513end
8514
8515------------------------------------------------------------------------
8516-- Macros to operate RK indices
8517-- * these use arithmetic instead of bit ops
8518------------------------------------------------------------------------
8519
8520-- this bit 1 means constant (0 means register)
8521luaP.BITRK = math.ldexp(1, luaP.SIZE_B - 1)
8522
8523-- test whether value is a constant
8524function luaP:ISK(x) return x >= self.BITRK end
8525
8526-- gets the index of the constant
8527function luaP:INDEXK(x) return x - self.BITRK end
8528
8529luaP.MAXINDEXRK = luaP.BITRK - 1
8530
8531-- code a constant index as a RK value
8532function luaP:RKASK(x) return x + self.BITRK end
8533
8534------------------------------------------------------------------------
8535-- invalid register that fits in 8 bits
8536------------------------------------------------------------------------
8537luaP.NO_REG = luaP.MAXARG_A
8538
8539------------------------------------------------------------------------
8540-- R(x) - register
8541-- Kst(x) - constant (in constant table)
8542-- RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
8543------------------------------------------------------------------------
8544
8545------------------------------------------------------------------------
8546-- grep "ORDER OP" if you change these enums
8547------------------------------------------------------------------------
8548
8549--[[--------------------------------------------------------------------
8550Lua virtual machine opcodes (enum OpCode):
8551------------------------------------------------------------------------
8552name args description
8553------------------------------------------------------------------------
8554OP_MOVE A B R(A) := R(B)
8555OP_LOADK A Bx R(A) := Kst(Bx)
8556OP_LOADBOOL A B C R(A) := (Bool)B; if (C) pc++
8557OP_LOADNIL A B R(A) := ... := R(B) := nil
8558OP_GETUPVAL A B R(A) := UpValue[B]
8559OP_GETGLOBAL A Bx R(A) := Gbl[Kst(Bx)]
8560OP_GETTABLE A B C R(A) := R(B)[RK(C)]
8561OP_SETGLOBAL A Bx Gbl[Kst(Bx)] := R(A)
8562OP_SETUPVAL A B UpValue[B] := R(A)
8563OP_SETTABLE A B C R(A)[RK(B)] := RK(C)
8564OP_NEWTABLE A B C R(A) := {} (size = B,C)
8565OP_SELF A B C R(A+1) := R(B); R(A) := R(B)[RK(C)]
8566OP_ADD A B C R(A) := RK(B) + RK(C)
8567OP_SUB A B C R(A) := RK(B) - RK(C)
8568OP_MUL A B C R(A) := RK(B) * RK(C)
8569OP_DIV A B C R(A) := RK(B) / RK(C)
8570OP_MOD A B C R(A) := RK(B) % RK(C)
8571OP_POW A B C R(A) := RK(B) ^ RK(C)
8572OP_UNM A B R(A) := -R(B)
8573OP_NOT A B R(A) := not R(B)
8574OP_LEN A B R(A) := length of R(B)
8575OP_CONCAT A B C R(A) := R(B).. ... ..R(C)
8576OP_JMP sBx pc+=sBx
8577OP_EQ A B C if ((RK(B) == RK(C)) ~= A) then pc++
8578OP_LT A B C if ((RK(B) < RK(C)) ~= A) then pc++
8579OP_LE A B C if ((RK(B) <= RK(C)) ~= A) then pc++
8580OP_TEST A C if not (R(A) <=> C) then pc++
8581OP_TESTSET A B C if (R(B) <=> C) then R(A) := R(B) else pc++
8582OP_CALL A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1))
8583OP_TAILCALL A B C return R(A)(R(A+1), ... ,R(A+B-1))
8584OP_RETURN A B return R(A), ... ,R(A+B-2) (see note)
8585OP_FORLOOP A sBx R(A)+=R(A+2);
8586 if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }
8587OP_FORPREP A sBx R(A)-=R(A+2); pc+=sBx
8588OP_TFORLOOP A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
8589 if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++
8590OP_SETLIST A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B
8591OP_CLOSE A close all variables in the stack up to (>=) R(A)
8592OP_CLOSURE A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n))
8593OP_VARARG A B R(A), R(A+1), ..., R(A+B-1) = vararg
8594----------------------------------------------------------------------]]
8595
8596luaP.opnames = {} -- opcode names
8597luaP.OpCode = {} -- lookup name -> number
8598luaP.ROpCode = {} -- lookup number -> name
8599
8600------------------------------------------------------------------------
8601-- ORDER OP
8602------------------------------------------------------------------------
8603local i = 0
8604for v in string.gmatch([[
8605MOVE LOADK LOADBOOL LOADNIL GETUPVAL
8606GETGLOBAL GETTABLE SETGLOBAL SETUPVAL SETTABLE
8607NEWTABLE SELF ADD SUB MUL
8608DIV MOD POW UNM NOT
8609LEN CONCAT JMP EQ LT
8610LE TEST TESTSET CALL TAILCALL
8611RETURN FORLOOP FORPREP TFORLOOP SETLIST
8612CLOSE CLOSURE VARARG
8613]], "%S+") do
8614 local n = "OP_"..v
8615 luaP.opnames[i] = v
8616 luaP.OpCode[n] = i
8617 luaP.ROpCode[i] = n
8618 i = i + 1
8619end
8620luaP.NUM_OPCODES = i
8621
8622--[[
8623===========================================================================
8624 Notes:
8625 (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
8626 and can be 0: OP_CALL then sets 'top' to last_result+1, so
8627 next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use 'top'.
8628 (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
8629 set top (like in OP_CALL with C == 0).
8630 (*) In OP_RETURN, if (B == 0) then return up to 'top'
8631 (*) In OP_SETLIST, if (B == 0) then B = 'top';
8632 if (C == 0) then next 'instruction' is real C
8633 (*) For comparisons, A specifies what condition the test should accept
8634 (true or false).
8635 (*) All 'skips' (pc++) assume that next instruction is a jump
8636===========================================================================
8637--]]
8638
8639--[[--------------------------------------------------------------------
8640 masks for instruction properties. The format is:
8641 bits 0-1: op mode
8642 bits 2-3: C arg mode
8643 bits 4-5: B arg mode
8644 bit 6: instruction set register A
8645 bit 7: operator is a test
8646
8647 for OpArgMask:
8648 OpArgN - argument is not used
8649 OpArgU - argument is used
8650 OpArgR - argument is a register or a jump offset
8651 OpArgK - argument is a constant or register/constant
8652----------------------------------------------------------------------]]
8653
8654-- was enum OpArgMask
8655luaP.OpArgMask = { OpArgN = 0, OpArgU = 1, OpArgR = 2, OpArgK = 3 }
8656
8657------------------------------------------------------------------------
8658-- e.g. to compare with symbols, luaP:getOpMode(...) == luaP.OpCode.iABC
8659-- * accepts opcode parameter as strings, e.g. "OP_MOVE"
8660------------------------------------------------------------------------
8661
8662function luaP:getOpMode(m)
8663 return self.opmodes[self.OpCode[m]] % 4
8664end
8665
8666function luaP:getBMode(m)
8667 return math.floor(self.opmodes[self.OpCode[m]] / 16) % 4
8668end
8669
8670function luaP:getCMode(m)
8671 return math.floor(self.opmodes[self.OpCode[m]] / 4) % 4
8672end
8673
8674function luaP:testAMode(m)
8675 return math.floor(self.opmodes[self.OpCode[m]] / 64) % 2
8676end
8677
8678function luaP:testTMode(m)
8679 return math.floor(self.opmodes[self.OpCode[m]] / 128)
8680end
8681
8682-- luaP_opnames[] is set above, as the luaP.opnames table
8683
8684-- number of list items to accumulate before a SETLIST instruction
8685luaP.LFIELDS_PER_FLUSH = 50
8686
8687------------------------------------------------------------------------
8688-- build instruction properties array
8689-- * deliberately coded to look like the C equivalent
8690------------------------------------------------------------------------
8691local function opmode(t, a, b, c, m)
8692 local luaP = luaP
8693 return t * 128 + a * 64 +
8694 luaP.OpArgMask[b] * 16 + luaP.OpArgMask[c] * 4 + luaP.OpMode[m]
8695end
8696
8697-- ORDER OP
8698luaP.opmodes = {
8699-- T A B C mode opcode
8700 opmode(0, 1, "OpArgK", "OpArgN", "iABx"), -- OP_LOADK
8701 opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_LOADBOOL
8702 opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_LOADNIL
8703 opmode(0, 1, "OpArgU", "OpArgN", "iABC"), -- OP_GETUPVAL
8704 opmode(0, 1, "OpArgK", "OpArgN", "iABx"), -- OP_GETGLOBAL
8705 opmode(0, 1, "OpArgR", "OpArgK", "iABC"), -- OP_GETTABLE
8706 opmode(0, 0, "OpArgK", "OpArgN", "iABx"), -- OP_SETGLOBAL
8707 opmode(0, 0, "OpArgU", "OpArgN", "iABC"), -- OP_SETUPVAL
8708 opmode(0, 0, "OpArgK", "OpArgK", "iABC"), -- OP_SETTABLE
8709 opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_NEWTABLE
8710 opmode(0, 1, "OpArgR", "OpArgK", "iABC"), -- OP_SELF
8711 opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_ADD
8712 opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_SUB
8713 opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_MUL
8714 opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_DIV
8715 opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_MOD
8716 opmode(0, 1, "OpArgK", "OpArgK", "iABC"), -- OP_POW
8717 opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_UNM
8718 opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_NOT
8719 opmode(0, 1, "OpArgR", "OpArgN", "iABC"), -- OP_LEN
8720 opmode(0, 1, "OpArgR", "OpArgR", "iABC"), -- OP_CONCAT
8721 opmode(0, 0, "OpArgR", "OpArgN", "iAsBx"), -- OP_JMP
8722 opmode(1, 0, "OpArgK", "OpArgK", "iABC"), -- OP_EQ
8723 opmode(1, 0, "OpArgK", "OpArgK", "iABC"), -- OP_LT
8724 opmode(1, 0, "OpArgK", "OpArgK", "iABC"), -- OP_LE
8725 opmode(1, 1, "OpArgR", "OpArgU", "iABC"), -- OP_TEST
8726 opmode(1, 1, "OpArgR", "OpArgU", "iABC"), -- OP_TESTSET
8727 opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_CALL
8728 opmode(0, 1, "OpArgU", "OpArgU", "iABC"), -- OP_TAILCALL
8729 opmode(0, 0, "OpArgU", "OpArgN", "iABC"), -- OP_RETURN
8730 opmode(0, 1, "OpArgR", "OpArgN", "iAsBx"), -- OP_FORLOOP
8731 opmode(0, 1, "OpArgR", "OpArgN", "iAsBx"), -- OP_FORPREP
8732 opmode(1, 0, "OpArgN", "OpArgU", "iABC"), -- OP_TFORLOOP
8733 opmode(0, 0, "OpArgU", "OpArgU", "iABC"), -- OP_SETLIST
8734 opmode(0, 0, "OpArgN", "OpArgN", "iABC"), -- OP_CLOSE
8735 opmode(0, 1, "OpArgU", "OpArgN", "iABx"), -- OP_CLOSURE
8736 opmode(0, 1, "OpArgU", "OpArgN", "iABC"), -- OP_VARARG
8737}
8738-- an awkward way to set a zero-indexed table...
8739luaP.opmodes[0] =
8740 opmode(0, 1, "OpArgR", "OpArgN", "iABC") -- OP_MOVE
8741
8742return luaP]]></ProtectedString>
8743 <BinaryString name="Tags"></BinaryString>
8744 </Properties>
8745 </Item>
8746 <Item class="ModuleScript" referent="RBX68094A1A110F498A83F5CEDB1F443708">
8747 <Properties>
8748 <Content name="LinkedSource"><null></null></Content>
8749 <string name="Name">LBI</string>
8750 <string name="ScriptGuid">{2BE59B0B-195F-469C-85F5-44A03A60C098}</string>
8751 <ProtectedString name="Source"><![CDATA[local advanced_debug
8752local newEnv
8753local customErrorHandler
8754
8755local debug = debug;
8756local next = next;
8757local string = string;
8758local type = type;
8759local assert = assert;
8760local table = table;
8761local error = error;
8762local select = select;
8763local unpack = unpack;
8764local setmetatable = setmetatable;
8765local coroutine = coroutine;
8766local tostring = tostring;
8767local print = print;
8768local pcall = pcall;
8769local getfenv = getfenv;
8770
8771local lua_opcode_types = {
8772 "ABC", "ABx", "ABC", "ABC",
8773 "ABC", "ABx", "ABC", "ABx",
8774 "ABC", "ABC", "ABC", "ABC",
8775 "ABC", "ABC", "ABC", "ABC",
8776 "ABC", "ABC", "ABC", "ABC",
8777 "ABC", "ABC", "AsBx", "ABC",
8778 "ABC", "ABC", "ABC", "ABC",
8779 "ABC", "ABC", "ABC", "AsBx",
8780 "AsBx", "ABC", "ABC", "ABC",
8781 "ABx", "ABC",
8782}
8783
8784local lua_opcode_names = {
8785 "MOVE", "LOADK", "LOADBOOL", "LOADNIL",
8786 "GETUPVAL", "GETGLOBAL", "GETTABLE", "SETGLOBAL",
8787 "SETUPVAL", "SETTABLE", "NEWTABLE", "SELF",
8788 "ADD", "SUB", "MUL", "DIV",
8789 "MOD", "POW", "UNM", "NOT",
8790 "LEN", "CONCAT", "JMP", "EQ",
8791 "LT", "LE", "TEST", "TESTSET",
8792 "CALL", "TAILCALL", "RETURN", "FORLOOP",
8793 "FORPREP", "TFORLOOP", "SETLIST", "CLOSE",
8794 "CLOSURE", "VARARG"
8795};
8796
8797--[[
8798local lua_opcode_numbers = {};
8799for number, name in next, lua_opcode_names do
8800 lua_opcode_numbers[name] = number;
8801end
8802--]]
8803
8804--- Extract bits from an integer
8805--@author: Stravant
8806local function get_bits(input, n, n2)
8807 if n2 then
8808 local total = 0
8809 local digitn = 0
8810 for i = n, n2 do
8811 total = total + 2^digitn*get_bits(input, i)
8812 digitn = digitn + 1
8813 end
8814 return total
8815 else
8816 local pn = 2^(n-1)
8817 return (input % (pn + pn) >= pn) and 1 or 0
8818 end
8819end
8820
8821local function decode_bytecode(bytecode)
8822 local index = 1
8823 local big_endian = false
8824 local int_size;
8825 local size_t;
8826
8827 -- Actual binary decoding functions. Dependant on the bytecode.
8828 local get_int, get_size_t;
8829
8830 -- Binary decoding helper functions
8831 local get_int8, get_int32, get_int64, get_float64, get_string;
8832 do
8833 function get_int8()
8834 local a = bytecode:byte(index, index);
8835 index = index + 1
8836 return a
8837 end
8838 function get_int32()
8839 local a, b, c, d = bytecode:byte(index, index + 3);
8840 index = index + 4;
8841 return d*16777216 + c*65536 + b*256 + a
8842 end
8843 function get_int64()
8844 local a = get_int32();
8845 local b = get_int32();
8846 return b*4294967296 + a;
8847 end
8848 function get_float64()
8849 local a = get_int32()
8850 local b = get_int32()
8851 return (-2*get_bits(b, 32)+1)*(2^(get_bits(b, 21, 31)-1023))*
8852 ((get_bits(b, 1, 20)*(2^32) + a)/(2^52)+1)
8853 end
8854 function get_string(len)
8855 local str;
8856 if len then
8857 str = bytecode:sub(index, index + len - 1);
8858 index = index + len;
8859 else
8860 len = get_size_t();
8861 if len == 0 then return; end
8862 str = bytecode:sub(index, index + len - 1);
8863 index = index + len;
8864 end
8865 return str;
8866 end
8867 end
8868
8869 local function decode_chunk()
8870 local chunk;
8871 local instructions = {};
8872 local constants = {};
8873 local prototypes = {};
8874 local debug = {
8875 lines = {};
8876 };
8877
8878 chunk = {
8879 instructions = instructions;
8880 constants = constants;
8881 prototypes = prototypes;
8882 debug = debug;
8883 };
8884
8885 local num;
8886
8887 chunk.name = get_string();-- Function name
8888 chunk.first_line = get_int(); -- First line
8889 chunk.last_line = get_int(); -- Last line
8890
8891 if chunk.name then chunk.name = chunk.name:sub(1, -2); end
8892
8893 chunk.upvalues = get_int8();
8894 chunk.arguments = get_int8();
8895 chunk.varg = get_int8();
8896 chunk.stack = get_int8();
8897
8898 -- TODO: realign lists to 1
8899 -- Decode instructions
8900 do
8901 num = get_int();
8902 for i = 1, num do
8903 local instruction = {
8904 -- opcode = opcode number;
8905 -- type = [ABC, ABx, AsBx]
8906 -- A, B, C, Bx, or sBx depending on type
8907 };
8908
8909 local data = get_int32();
8910 local opcode = get_bits(data, 1, 6);
8911 local type = lua_opcode_types[opcode + 1];
8912
8913 instruction.opcode = opcode;
8914 instruction.type = type;
8915
8916 instruction.A = get_bits(data, 7, 14);
8917 if type == "ABC" then
8918 instruction.B = get_bits(data, 24, 32);
8919 instruction.C = get_bits(data, 15, 23);
8920 elseif type == "ABx" then
8921 instruction.Bx = get_bits(data, 15, 32);
8922 elseif type == "AsBx" then
8923 instruction.sBx = get_bits(data, 15, 32) - 131071;
8924 end
8925
8926 instructions[i] = instruction;
8927 end
8928 end
8929
8930 -- Decode constants
8931 do
8932 num = get_int();
8933 for i = 1, num do
8934 local constant = {
8935 -- type = constant type;
8936 -- data = constant data;
8937 };
8938 local type = get_int8();
8939 constant.type = type;
8940
8941 if type == 1 then
8942 constant.data = (get_int8() ~= 0);
8943 elseif type == 3 then
8944 constant.data = get_float64();
8945 elseif type == 4 then
8946 constant.data = get_string():sub(1, -2);
8947 end
8948
8949 constants[i-1] = constant;
8950 end
8951 end
8952
8953 -- Decode Prototypes
8954 do
8955 num = get_int();
8956 for i = 1, num do
8957 prototypes[i-1] = decode_chunk();
8958 end
8959 end
8960
8961 -- Decode debug info
8962 -- Not all of which is used yet.
8963 do
8964 -- line numbers
8965 local data = debug.lines
8966 num = get_int();
8967 for i = 1, num do
8968 data[i] = get_int32();
8969 end
8970
8971 -- locals
8972 num = get_int();
8973 for i = 1, num do
8974 get_string():sub(1, -2); -- local name
8975 get_int32(); -- local start PC
8976 get_int32(); -- local end PC
8977 end
8978
8979 -- upvalues
8980 num = get_int();
8981 for i = 1, num do
8982 get_string(); -- upvalue name
8983 end
8984 end
8985
8986 return chunk;
8987 end
8988
8989 -- Verify bytecode header
8990 do
8991 assert(get_string(4) == "\27Lua", "Lua bytecode expected.");
8992 assert(get_int8() == 0x51, "Only Lua 5.1 is supported.");
8993 get_int8(); -- Oficial bytecode
8994 big_endian = (get_int8() == 0);
8995 int_size = get_int8();
8996 size_t = get_int8();
8997
8998 if int_size == 4 then
8999 get_int = get_int32;
9000 elseif int_size == 8 then
9001 get_int = get_int64;
9002 else
9003 -- TODO: refactor errors into table
9004 error("Unsupported bytecode target platform");
9005 end
9006
9007 if size_t == 4 then
9008 get_size_t = get_int32;
9009 elseif size_t == 8 then
9010 get_size_t = get_int64;
9011 else
9012 error("Unsupported bytecode target platform");
9013 end
9014
9015 assert(get_string(3) == "\4\8\0",
9016 "Unsupported bytecode target platform");
9017 end
9018
9019 return decode_chunk();
9020end
9021
9022local function handle_return(...)
9023 local c = select("#", ...)
9024 local t = {...}
9025 return c, t
9026end
9027
9028local function create_wrapper(cache, upvalues)
9029 local instructions = cache.instructions;
9030 local constants = cache.constants;
9031 local prototypes = cache.prototypes;
9032
9033 local stack, top
9034 local environment
9035 local IP = 1; -- instruction pointer
9036 local vararg, vararg_size
9037
9038 local opcode_funcs = {
9039 [0] = function(instruction) -- MOVE
9040 stack[instruction.A] = stack[instruction.B];
9041 end,
9042 [1] = function(instruction) -- LOADK
9043 stack[instruction.A] = constants[instruction.Bx].data;
9044 end,
9045 [2] = function(instruction) -- LOADBOOL
9046 stack[instruction.A] = instruction.B ~= 0
9047 if instruction.C ~= 0 then
9048 IP = IP + 1
9049 end
9050 end,
9051 [3] = function(instruction) -- LOADNIL
9052 local stack = stack
9053 for i = instruction.A, instruction.B do
9054 stack[i] = nil
9055 end
9056 end,
9057 [4] = function(instruction) -- GETUPVAL
9058 stack[instruction.A] = upvalues[instruction.B]
9059 end,
9060 [5] = function(instruction) -- GETGLOBAL
9061 local key = constants[instruction.Bx].data;
9062 stack[instruction.A] = environment[key];
9063 end,
9064 [6] = function(instruction) -- GETTABLE
9065 local C = instruction.C
9066 local stack = stack
9067 C = C > 255 and constants[C-256].data or stack[C]
9068 stack[instruction.A] = stack[instruction.B][C];
9069 end,
9070 [7] = function(instruction) -- SETGLOBAL
9071 local key = constants[instruction.Bx].data;
9072 environment[key] = stack[instruction.A];
9073 end,
9074 [8] = function (instruction) -- SETUPVAL
9075 upvalues[instruction.B] = stack[instruction.A]
9076 end,
9077 [9] = function (instruction) -- SETTABLE
9078 local B = instruction.B;
9079 local C = instruction.C;
9080 local stack, constants = stack, constants;
9081
9082 B = B > 255 and constants[B-256].data or stack[B];
9083 C = C > 255 and constants[C-256].data or stack[C];
9084
9085 stack[instruction.A][B] = C
9086 end,
9087 [10] = function (instruction) -- NEWTABLE
9088 stack[instruction.A] = {}
9089 end,
9090 [11] = function (instruction) -- SELF
9091 local A = instruction.A
9092 local B = instruction.B
9093 local C = instruction.C
9094 local stack = stack
9095
9096 B = stack[B]
9097 C = C > 255 and constants[C-256].data or stack[C]
9098
9099 stack[A+1] = B
9100 stack[A] = B[C]
9101 end,
9102 [12] = function(instruction) -- ADD
9103 local B = instruction.B;
9104 local C = instruction.C;
9105 local stack, constants = stack, constants;
9106
9107 B = B > 255 and constants[B-256].data or stack[B];
9108 C = C > 255 and constants[C-256].data or stack[C];
9109
9110 stack[instruction.A] = B+C;
9111 end,
9112 [13] = function(instruction) -- SUB
9113 local B = instruction.B;
9114 local C = instruction.C;
9115 local stack, constants = stack, constants;
9116
9117 B = B > 255 and constants[B-256].data or stack[B];
9118 C = C > 255 and constants[C-256].data or stack[C];
9119
9120 stack[instruction.A] = B - C;
9121 end,
9122 [14] = function(instruction) -- MUL
9123 local B = instruction.B;
9124 local C = instruction.C;
9125 local stack, constants = stack, constants;
9126
9127 B = B > 255 and constants[B-256].data or stack[B];
9128 C = C > 255 and constants[C-256].data or stack[C];
9129
9130 stack[instruction.A] = B * C;
9131 end,
9132 [15] = function(instruction) --DIV
9133 local B = instruction.B;
9134 local C = instruction.C;
9135 local stack, constants = stack, constants;
9136
9137 B = B > 255 and constants[B-256].data or stack[B];
9138 C = C > 255 and constants[C-256].data or stack[C];
9139
9140 stack[instruction.A] = B / C;
9141 end,
9142 [16] = function(instruction) -- MOD
9143 local B = instruction.B;
9144 local C = instruction.C;
9145 local stack, constants = stack, constants;
9146
9147 B = B > 255 and constants[B-256].data or stack[B];
9148 C = C > 255 and constants[C-256].data or stack[C];
9149
9150 stack[instruction.A] = B % C;
9151 end,
9152 [17] = function(instruction) -- POW
9153 local B = instruction.B;
9154 local C = instruction.C;
9155 local stack, constants = stack, constants;
9156
9157 B = B > 255 and constants[B-256].data or stack[B];
9158 C = C > 255 and constants[C-256].data or stack[C];
9159
9160 stack[instruction.A] = B ^ C;
9161 end,
9162 [18] = function(instruction) -- UNM
9163 stack[instruction.A] = -stack[instruction.B]
9164 end,
9165 [19] = function(instruction) -- NOT
9166 stack[instruction.A] = not stack[instruction.B]
9167 end,
9168 [20] = function(instruction) -- LEN
9169 stack[instruction.A] = #stack[instruction.B]
9170 end,
9171 [21] = function(instruction) -- CONCAT
9172 local B = instruction.B
9173 local result = stack[B]
9174 for i = B+1, instruction.C do
9175 result = result .. stack[i]
9176 end
9177 stack[instruction.A] = result
9178 end,
9179 [22] = function(instruction) -- JUMP
9180 IP = IP + instruction.sBx
9181 end,
9182 [23] = function(instruction) -- EQ
9183 local A = instruction.A
9184 local B = instruction.B
9185 local C = instruction.C
9186 local stack, constants = stack, constants
9187
9188 A = A ~= 0
9189 B = B > 255 and constants[B-256].data or stack[B]
9190 C = C > 255 and constants[C-256].data or stack[C]
9191 if (B == C) ~= A then
9192 IP = IP + 1
9193 end
9194 end,
9195 [24] = function(instruction) -- LT
9196 local A = instruction.A
9197 local B = instruction.B
9198 local C = instruction.C
9199 local stack, constants = stack, constants
9200
9201 A = A ~= 0
9202 B = B > 255 and constants[B-256].data or stack[B]
9203 C = C > 255 and constants[C-256].data or stack[C]
9204 if (B < C) ~= A then
9205 IP = IP + 1
9206 end
9207 end,
9208 [25] = function(instruction) -- LT
9209 local A = instruction.A
9210 local B = instruction.B
9211 local C = instruction.C
9212 local stack, constants = stack, constants
9213
9214 A = A ~= 0
9215 B = B > 255 and constants[B-256].data or stack[B]
9216 C = C > 255 and constants[C-256].data or stack[C]
9217 if (B <= C) ~= A then
9218 IP = IP + 1
9219 end
9220 end,
9221 [26] = function(instruction) -- TEST
9222 if (not not stack[instruction.A]) == (instruction.C == 0) then
9223 IP = IP + 1
9224 end
9225 end,
9226 [27] = function(instruction) -- TESTSET
9227 local stack = stack
9228 local B = stack[instruction.B]
9229 if (not not B) == (instruction.C == 0) then
9230 IP = IP + 1
9231 else
9232 stack[instruction.A] = B
9233 end
9234 end,
9235 [28] = function(instruction) -- CALL
9236 local A = instruction.A;
9237 local B = instruction.B;
9238 local C = instruction.C;
9239 local stack = stack;
9240 local args, results;
9241 local limit, loop
9242
9243 args = {};
9244 if B ~= 1 then
9245 if B ~= 0 then
9246 limit = A+B-1;
9247 else
9248 limit = top
9249 end
9250
9251 loop = 0
9252 for i = A+1, limit do
9253 loop = loop + 1
9254 args[loop] = stack[i];
9255 end
9256
9257 limit, results = handle_return(stack[A](unpack(args, 1, limit-A)))
9258 else
9259 limit, results = handle_return(stack[A]())
9260 end
9261
9262 top = A - 1
9263
9264 if C ~= 1 then
9265 if C ~= 0 then
9266 limit = A+C-2;
9267 else
9268 limit = limit+A
9269 end
9270
9271 loop = 0;
9272 for i = A, limit do
9273 loop = loop + 1;
9274 stack[i] = results[loop];
9275 end
9276 end
9277 end,
9278 [29] = function (instruction) -- TAILCALL
9279 local A = instruction.A;
9280 local B = instruction.B;
9281 local C = instruction.C;
9282 local stack = stack;
9283 local args, results;
9284 local top, limit, loop = top
9285
9286 args = {};
9287 if B ~= 1 then
9288 if B ~= 0 then
9289 limit = A+B-1;
9290 else
9291 limit = top
9292 end
9293
9294 loop = 0
9295 for i = A+1, limit do
9296 loop = loop + 1
9297 args[#args+1] = stack[i];
9298 end
9299
9300 results = {stack[A](unpack(args, 1, limit-A))};
9301 else
9302 results = {stack[A]()};
9303 end
9304
9305 return true, results
9306 end,
9307 [30] = function(instruction) -- RETURN
9308 --TODO: CLOSE
9309 local A = instruction.A;
9310 local B = instruction.B;
9311 local stack = stack;
9312 local limit;
9313 local loop, output;
9314
9315 if B == 1 then
9316 return true;
9317 end
9318 if B == 0 then
9319 limit = top
9320 else
9321 limit = A + B - 2;
9322 end
9323
9324 output = {};
9325 local loop = 0
9326 for i = A, limit do
9327 loop = loop + 1
9328 output[loop] = stack[i];
9329 end
9330 return true, output;
9331 end,
9332 [31] = function(instruction) -- FORLOOP
9333 local A = instruction.A
9334 local stack = stack
9335
9336 local step = stack[A+2]
9337 local index = stack[A] + step
9338 stack[A] = index
9339
9340 if step > 0 then
9341 if index <= stack[A+1] then
9342 IP = IP + instruction.sBx
9343 stack[A+3] = index
9344 end
9345 else
9346 if index >= stack[A+1] then
9347 IP = IP + instruction.sBx
9348 stack[A+3] = index
9349 end
9350 end
9351 end,
9352 [32] = function(instruction) -- FORPREP
9353 local A = instruction.A
9354 local stack = stack
9355
9356 stack[A] = stack[A] - stack[A+2]
9357 IP = IP + instruction.sBx
9358 end,
9359 [33] = function(instruction) -- TFORLOOP
9360 local A = instruction.A
9361 local B = instruction.B
9362 local C = instruction.C
9363 local stack = stack
9364
9365 local offset = A+2
9366 local result = {stack[A](stack[A+1], stack[A+2])}
9367 for i = 1, C do
9368 stack[offset+i] = result[i]
9369 end
9370
9371 if stack[A+3] ~= nil then
9372 stack[A+2] = stack[A+3]
9373 else
9374 IP = IP + 1
9375 end
9376 end,
9377 [34] = function(instruction) -- SETLIST
9378 local A = instruction.A
9379 local B = instruction.B
9380 local C = instruction.C
9381 local stack = stack
9382
9383 if C == 0 then
9384 error("NYI: extended SETLIST")
9385 else
9386 local offset = (C - 1) * 50
9387 local t = stack[A]
9388
9389 if B == 0 then
9390 B = top
9391 end
9392 for i = 1, B do
9393 t[offset+i] = stack[A+i]
9394 end
9395 end
9396 end,
9397 [35] = function(instruction) -- CLOSE
9398 --io.stderr:write("NYI: CLOSE")
9399 --io.stderr:flush()
9400 end,
9401 [36] = function(instruction) -- CLOSURE
9402 local proto = prototypes[instruction.Bx]
9403 local instructions = instructions
9404 local stack = stack
9405
9406 local indices = {}
9407 local new_upvals = setmetatable({},
9408 {
9409 __index = function(t, k)
9410 local upval = indices[k]
9411 return upval.segment[upval.offset]
9412 end,
9413 __newindex = function(t, k, v)
9414 local upval = indices[k]
9415 upval.segment[upval.offset] = v
9416 end
9417 }
9418 )
9419 for i = 1, proto.upvalues do
9420 local movement = instructions[IP]
9421 if movement.opcode == 0 then -- MOVE
9422 indices[i-1] = {segment = stack, offset = movement.B}
9423 elseif instructions[IP].opcode == 4 then -- GETUPVAL
9424 indices[i-1] = {segment = upvalues, offset = movement.B}
9425 end
9426 IP = IP + 1
9427 end
9428
9429 local _, func = create_wrapper(proto, new_upvals)
9430 stack[instruction.A] = func
9431 end,
9432 [37] = function(instruction) -- VARARG
9433 local A = instruction.A
9434 local B = instruction.B
9435 local stack, vararg = stack, vararg
9436
9437 for i = A, A + (B > 0 and B - 1 or vararg_size) do
9438 stack[i] = vararg[i - A]
9439 end
9440 end,
9441 }
9442
9443 local function handle_error(b)
9444 local name = cache.name;
9445 local line = cache.debug.lines[IP];
9446 local err = (b:match("^.+:(.+)") or b)
9447 local output = "Error: ";
9448
9449 if name then
9450 output = name
9451 end
9452
9453 if line then
9454 output = output.." - Line: "..line
9455 end
9456
9457 if b and type(b) == "string" then
9458 output = output.." - Error: ".. err
9459 end
9460
9461 if customErrorHandler then
9462 --coroutine.resume(customErrorHandler,tostring(line)..":"..tostring(err))
9463 customErrorHandler(tostring(line)..":"..tostring(err))
9464 else
9465 error(tostring(line)..":"..tostring(err),3)
9466 end
9467 end
9468
9469 local function loop()
9470 local instructions = instructions
9471 local instruction, a, b, ran
9472
9473 while true do
9474 instruction = instructions[IP];
9475 --//print("IP: "..tostring(IP))
9476 --//print("INSTUCT: "..tostring(instruction))
9477 --//print("OPCODE: "..instruction.opcode)
9478 IP = IP + 1
9479 ran, a, b = pcall(function() return opcode_funcs[instruction.opcode](instruction); end);
9480 if not ran then
9481 handle_error(a);
9482 break;
9483 elseif a then
9484 return b;
9485 end
9486 end
9487 end
9488
9489 local debugging = {
9490 get_stack = function()
9491 return stack;
9492 end;
9493 get_IP = function()
9494 return IP;
9495 end
9496 };
9497
9498 local function func(...)
9499 local local_stack = {};
9500 local ghost_stack = {};
9501
9502 top = -1
9503 stack = setmetatable(local_stack, {
9504 __index = ghost_stack;
9505 __newindex = function(t, k, v)
9506 if k > top and v then
9507 top = k
9508 end
9509 ghost_stack[k] = v
9510 end;
9511 })
9512 local args = {...};
9513 vararg = {}
9514 vararg_size = select("#", ...) - 1
9515 for i = 0, vararg_size do
9516 local_stack[i] = args[i+1];
9517 vararg[i] = args[i+1]
9518 end
9519
9520 environment = newEnv or getfenv();
9521 IP = 1;
9522 local thread = coroutine.create(loop)
9523 local a, b = coroutine.resume(thread)
9524
9525 if a then
9526 if b then
9527 return unpack(b);
9528 end
9529 return;
9530 else
9531 if advanced_debug then
9532 --TODO advanced debugging
9533 else
9534 handle_error(b)
9535 end
9536 end
9537 end
9538
9539 return debugging, func;
9540end
9541
9542return {
9543 load_bytecode = function(bytecode, env, customHandler)
9544 newEnv = env or getfenv(2)
9545 customErrorHandler = customHandler
9546 local cache = decode_bytecode(bytecode);
9547 local _, func = create_wrapper(cache);
9548 return func;
9549 end;
9550
9551 -- Utilities (Debug, Introspection, Testing, etc)
9552 utils = {
9553 decode_bytecode = decode_bytecode;
9554 create_wrapper = create_wrapper;
9555 debug_bytecode = function(bytecode)
9556 local cache = decode_bytecode(bytecode)
9557 return create_wrapper(cache);
9558 end;
9559 };
9560}]]></ProtectedString>
9561 <BinaryString name="Tags"></BinaryString>
9562 </Properties>
9563 </Item>
9564 </Item>
9565 </Item>
9566 <Item class="Folder" referent="RBXA0A40055C7014ED99A518F2612ADA96F">
9567 <Properties>
9568 <string name="Name">3D</string>
9569 <BinaryString name="Tags"></BinaryString>
9570 </Properties>
9571 <Item class="MeshPart" referent="RBXC5D8ED5903BE407B942C4C69E370E44C">
9572 <Properties>
9573 <bool name="Anchored">true</bool>
9574 <float name="BackParamA">-0.5</float>
9575 <float name="BackParamB">0.5</float>
9576 <token name="BackSurface">0</token>
9577 <token name="BackSurfaceInput">0</token>
9578 <float name="BottomParamA">-0.5</float>
9579 <float name="BottomParamB">0.5</float>
9580 <token name="BottomSurface">0</token>
9581 <token name="BottomSurfaceInput">0</token>
9582 <CoordinateFrame name="CFrame">
9583 <X>-5.74000788</X>
9584 <Y>2.02003598</Y>
9585 <Z>-13.9899979</Z>
9586 <R00>1</R00>
9587 <R01>0</R01>
9588 <R02>0</R02>
9589 <R10>0</R10>
9590 <R11>1</R11>
9591 <R12>0</R12>
9592 <R20>0</R20>
9593 <R21>0</R21>
9594 <R22>1</R22>
9595 </CoordinateFrame>
9596 <bool name="CanCollide">false</bool>
9597 <token name="CollisionFidelity">0</token>
9598 <int name="CollisionGroupId">0</int>
9599 <Color3uint8 name="Color3uint8">4279308561</Color3uint8>
9600 <PhysicalProperties name="CustomPhysicalProperties">
9601 <CustomPhysics>false</CustomPhysics>
9602 </PhysicalProperties>
9603 <float name="Elasticity">0.5</float>
9604 <float name="Friction">0.300000012</float>
9605 <float name="FrontParamA">-0.5</float>
9606 <float name="FrontParamB">0.5</float>
9607 <token name="FrontSurface">0</token>
9608 <token name="FrontSurfaceInput">0</token>
9609 <Vector3 name="InitialSize">
9610 <X>50.0000191</X>
9611 <Y>166.666626</Y>
9612 <Z>50</Z>
9613 </Vector3>
9614 <float name="LeftParamA">-0.5</float>
9615 <float name="LeftParamB">0.5</float>
9616 <token name="LeftSurface">0</token>
9617 <token name="LeftSurfaceInput">0</token>
9618 <bool name="Locked">true</bool>
9619 <token name="Material">288</token>
9620 <Content name="MeshID"><url>rbxassetid://585532343</url></Content>
9621 <Content name="MeshId"><url>rbxassetid://585532343</url></Content>
9622 <string name="Name">LowPoly</string>
9623 <BinaryString name="PhysicsData"><![CDATA[Q1NHUEhTAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAgD9dAAAA
9624BAAAAE0RQkEDAHtC9f/HwQAAKDkAAAAAAECVt00RQsEDAHtC9f/HwU0RQsECAHtCAADIQU0R
9625QkECAHtCAADIQTEzS8Fn5n1CU9XAwfDdxMFn5n1C1GYGvwe3S7+oqqZCn2YGvzEzS0Fk5n1C
9626XtXAQfDdxEFn5n1CpmUGP3LBSz+oqqZC3WUGP6iqpjioqqZCW2eGP6iqpjioqqZCbmaGvwUA
9627yEEDAHtCtb77PgUAyEEDAHtC5Lv7vgUAyMEDAHtC5Lv7vgUAyMEDAHtCtb77PhDvTUEDAHtC
9628CxHEwTEzS0Fn5n1CU9XAwRDvTcEDAHtCCxHEwRDvTcECAHtCFBHEQTEzS8Fk5n1CXtXAQRDv
9629TUECAHtCFBHEQXLBSz+oqqZCn2YGvwe3S7+oqqZC3WUGP253PsFn5n1ChQjFwW53PkFn5n1C
9630hQjFwW53PsFk5n1CkAjFQW53PkFk5n1CkAjFQfDdxEFn5n1C1GYGv/DdxMFn5n1CpmUGP64A
9631AAAAAAAAAQAAAAIAAAADAAAAAQAAAAQAAAAFAAAABgAAAAcAAAAIAAAACQAAAAoAAAALAAAA
9632CAAAAAoAAAALAAAACgAAAAcAAAAMAAAABQAAAAcAAAAMAAAABwAAAAoAAAANAAAACQAAAAgA
9633AAANAAAADgAAAAkAAAANAAAAAQAAAA4AAAAPAAAABgAAAAUAAAAPAAAAEAAAAAYAAAAPAAAA
9634AQAAABAAAAARAAAAAAAAABIAAAARAAAAEgAAAA4AAAARAAAADgAAAAEAAAARAAAAAQAAAAAA
9635AAATAAAAAgAAAAEAAAATAAAAAQAAAA8AAAATAAAABQAAAAIAAAATAAAADwAAAAUAAAAUAAAA
9636AwAAABUAAAAUAAAAFQAAABAAAAAUAAAAEAAAAAEAAAAUAAAAAQAAAAMAAAAWAAAABAAAAAEA
9637AAAWAAAAAQAAAA0AAAAWAAAACAAAAAQAAAAWAAAADQAAAAgAAAAXAAAAEgAAAAwAAAAXAAAA
9638DAAAAAoAAAAXAAAACgAAAAkAAAAYAAAAFQAAAAsAAAAYAAAACwAAAAcAAAAYAAAABwAAAAYA
9639AAAZAAAAAAAAAAIAAAAZAAAAAgAAAAUAAAAZAAAABQAAAAwAAAAaAAAAAAAAABkAAAAaAAAA
9640GQAAAAwAAAAaAAAAEgAAAAAAAAAaAAAADAAAABIAAAAbAAAAAwAAAAQAAAAbAAAAFQAAAAMA
9641AAAbAAAACwAAABUAAAAcAAAACwAAABsAAAAcAAAAGwAAAAQAAAAcAAAABAAAAAgAAAAcAAAA
9642CAAAAAsAAAAdAAAACQAAAA4AAAAdAAAAFwAAAAkAAAAdAAAADgAAABIAAAAdAAAAEgAAABcA
9643AAAeAAAABgAAABAAAAAeAAAAGAAAAAYAAAAeAAAAEAAAABUAAAAeAAAAFQAAABgAAAAQAAAA
9644AAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAIA/XQAAAAQAAABNEUJBjP96wgAA
9645yMFNEULBjP96wgAAyMEAACg5AAAAAABAlbdNEULBj/96wvX/x0FNEUJBj/96wvX/x0ExM0vB
9646Duh9wl7VwMEHt0u/qKqmwmdoBr/w3cTBD+h9wi9oBr8xM0tBD+h9wlPVwEFywUs/qKqmwhZk
9647Bj/w3cRBD+h9wkxkBj+oqqY4qKqmwndmhj+oqqY4qKqmwlNnhr8FAMhBj/96wgW8+z4FAMhB
9648j/96wpK++74FAMjBj/96wpK++74FAMjBj/96wgW8+z4Q703Bj/96wgsRxEExM0vBD+h9wlPV
9649wEEQ701Bj/96wgsRxEEQ701BjP96whQRxMExM0tBDuh9wl7VwMEQ703BjP96whQRxMFywUs/
9650qKqmwmdoBr8Ht0u/qKqmwhZkBj9udz7BDuh9wpAIxcFudz5BDuh9wpAIxcFudz5BD+h9woUI
9651xUFudz7BD+h9woUIxUHw3cRBD+h9wi9oBr/w3cTBD+h9wkxkBj+uAAAAAAAAAAEAAAACAAAA
9652AwAAAAQAAAACAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAkAAAAIAAAACwAAAAYA
9653AAAJAAAADAAAAAYAAAAFAAAADAAAAAkAAAAGAAAADQAAAAgAAAAKAAAADQAAAAoAAAAOAAAA
9654DQAAAA4AAAACAAAADwAAAAUAAAAHAAAADwAAAAcAAAAQAAAADwAAABAAAAACAAAAEQAAABAA
9655AAASAAAAEQAAABIAAAADAAAAEQAAAAIAAAAQAAAAEQAAAAMAAAACAAAAEwAAAAIAAAAEAAAA
9656EwAAAA0AAAACAAAAEwAAAAQAAAAIAAAAEwAAAAgAAAANAAAAFAAAAA4AAAAVAAAAFAAAABUA
9657AAAAAAAAFAAAAAIAAAAOAAAAFAAAAAAAAAACAAAAFgAAAAIAAAABAAAAFgAAAA8AAAACAAAA
9658FgAAAAEAAAAFAAAAFgAAAAUAAAAPAAAAFwAAAAkAAAAMAAAAFwAAAAwAAAAVAAAAFwAAAAoA
9659AAAJAAAAGAAAAAYAAAALAAAAGAAAAAsAAAASAAAAGAAAAAcAAAAGAAAAGQAAAAEAAAAAAAAA
9660GQAAAAUAAAABAAAAGQAAAAwAAAAFAAAAGgAAAAwAAAAZAAAAGgAAABkAAAAAAAAAGgAAAAAA
9661AAAVAAAAGgAAABUAAAAMAAAAGwAAAAQAAAADAAAAGwAAAAgAAAAEAAAAGwAAAAsAAAAIAAAA
9662HAAAAAsAAAAbAAAAHAAAABsAAAADAAAAHAAAAAMAAAASAAAAHAAAABIAAAALAAAAHQAAAA4A
9663AAAKAAAAHQAAAAoAAAAXAAAAHQAAABUAAAAOAAAAHQAAABcAAAAVAAAAHgAAABAAAAAHAAAA
9664HgAAAAcAAAAYAAAAHgAAABIAAAAQAAAAHgAAABgAAAASAAAA]]></BinaryString>
9665 <float name="Reflectance">0</float>
9666 <float name="RightParamA">-0.5</float>
9667 <float name="RightParamB">0.5</float>
9668 <token name="RightSurface">0</token>
9669 <token name="RightSurfaceInput">0</token>
9670 <Vector3 name="RotVelocity">
9671 <X>0</X>
9672 <Y>0</Y>
9673 <Z>0</Z>
9674 </Vector3>
9675 <BinaryString name="Tags"></BinaryString>
9676 <Content name="TextureID"><null></null></Content>
9677 <float name="TopParamA">-0.5</float>
9678 <float name="TopParamB">0.5</float>
9679 <token name="TopSurface">0</token>
9680 <token name="TopSurfaceInput">0</token>
9681 <float name="Transparency">0</float>
9682 <Vector3 name="Velocity">
9683 <X>0</X>
9684 <Y>0</Y>
9685 <Z>0</Z>
9686 </Vector3>
9687 <Vector3 name="size">
9688 <X>1.20000005</X>
9689 <Y>4</Y>
9690 <Z>1.20000005</Z>
9691 </Vector3>
9692 </Properties>
9693 </Item>
9694 <Item class="MeshPart" referent="RBX65152941B9D04BC4960040137D86544F">
9695 <Properties>
9696 <bool name="Anchored">true</bool>
9697 <float name="BackParamA">-0.5</float>
9698 <float name="BackParamB">0.5</float>
9699 <token name="BackSurface">0</token>
9700 <token name="BackSurfaceInput">0</token>
9701 <float name="BottomParamA">-0.5</float>
9702 <float name="BottomParamB">0.5</float>
9703 <token name="BottomSurface">0</token>
9704 <token name="BottomSurfaceInput">0</token>
9705 <CoordinateFrame name="CFrame">
9706 <X>-5.74000788</X>
9707 <Y>2.02003598</Y>
9708 <Z>-11.9899979</Z>
9709 <R00>1</R00>
9710 <R01>0</R01>
9711 <R02>0</R02>
9712 <R10>0</R10>
9713 <R11>1</R11>
9714 <R12>0</R12>
9715 <R20>0</R20>
9716 <R21>0</R21>
9717 <R22>1</R22>
9718 </CoordinateFrame>
9719 <bool name="CanCollide">false</bool>
9720 <token name="CollisionFidelity">0</token>
9721 <int name="CollisionGroupId">0</int>
9722 <Color3uint8 name="Color3uint8">4279308561</Color3uint8>
9723 <PhysicalProperties name="CustomPhysicalProperties">
9724 <CustomPhysics>false</CustomPhysics>
9725 </PhysicalProperties>
9726 <float name="Elasticity">0.5</float>
9727 <float name="Friction">0.300000012</float>
9728 <float name="FrontParamA">-0.5</float>
9729 <float name="FrontParamB">0.5</float>
9730 <token name="FrontSurface">0</token>
9731 <token name="FrontSurfaceInput">0</token>
9732 <Vector3 name="InitialSize">
9733 <X>200</X>
9734 <Y>799.451721</Y>
9735 <Z>174.924408</Z>
9736 </Vector3>
9737 <float name="LeftParamA">-0.5</float>
9738 <float name="LeftParamB">0.5</float>
9739 <token name="LeftSurface">0</token>
9740 <token name="LeftSurfaceInput">0</token>
9741 <bool name="Locked">true</bool>
9742 <token name="Material">288</token>
9743 <Content name="MeshID"><url>rbxassetid://494629790</url></Content>
9744 <Content name="MeshId"><url>rbxassetid://494629790</url></Content>
9745 <string name="Name">MidPoly</string>
9746 <BinaryString name="PhysicsData"><![CDATA[Q1NHUEhTAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAgD9gAAAA
9747BAAAAKL0TUINf5bDZ3yrwqL0TUIOf5ZDWnyrwgAAyEIOf5bDdBHcv6L0TcINf5ZDZ3yrQgAA
9748yMIOf5ZDdBHcP6L0TcIOf5bDWnyrQty8S8Dp3MdDsEPrP9y8S0Dp3MfDsEPrv3k6S0I/PZjD
9749K6aoQl4LQkINf5ZDpuyuQl4LQkIOf5bDmeyuQqp+PkI/PZhDMlOswty8S0Dp3MdDbD/rv3k6
9750S0I+PZhDOKaoQgAAyEIOf5ZDdBHcP3k6S8I+PZjDOKaowty8S8Dp3MfDbD/rPwAAyMIOf5bD
9751dBHcv6L0TcIOf5ZDWnyrwl4LQsINf5bDpuyuwqp+PkI+PZjDP1Oswqp+PsI/PZjDMlOsQpHc
9752xMI/PZhD7j/rv6p+PsI+PZhDP1OsQpHcxEI/PZhD7j/rv5HcxMI/PZjD7j/rP6p+PsI/PZhD
9753MlOswpHcxEI/PZjD7j/rP9y8S0Dp3MdDsEPrPzmFvSXp3MfDfEBrQF9qZqfp3MfDn0JrwNy8
9754S8Dp3MdDbD/rv7QAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAADAAAABgAAAAQAAAAHAAAA
9755AAAAAAIAAAAIAAAACQAAAAoAAAALAAAADAAAAAEAAAALAAAAAQAAAAAAAAANAAAACQAAAAgA
9756AAANAAAACAAAAA4AAAAPAAAAEAAAABEAAAAPAAAAEgAAABMAAAAPAAAAEQAAABIAAAAUAAAA
9757EwAAAAsAAAAUAAAACwAAAAAAAAAUAAAAAAAAAAcAAAAVAAAAAwAAAAUAAAAVAAAACgAAAAkA
9758AAAVAAAABQAAABAAAAAWAAAAEgAAABEAAAAWAAAAEQAAAAQAAAAWAAAABAAAAAYAAAAXAAAA
9759AwAAABUAAAAXAAAAFQAAAAkAAAAXAAAABgAAAAMAAAAYAAAAAQAAAAwAAAAYAAAAAgAAAAEA
9760AAAYAAAADgAAAAIAAAAZAAAABQAAAAQAAAAZAAAABAAAABEAAAAZAAAAEAAAAAUAAAAZAAAA
9761EQAAABAAAAAaAAAAEwAAABIAAAAaAAAACwAAABMAAAAaAAAADAAAAAsAAAAbAAAAAgAAAA4A
9762AAAbAAAADgAAAAgAAAAbAAAABwAAAAIAAAAbAAAACAAAAAcAAAAcAAAADgAAABgAAAAcAAAA
9763GAAAAAwAAAAcAAAABgAAABcAAAAcAAAAFwAAAAkAAAAcAAAADAAAAAYAAAAcAAAACQAAAA0A
9764AAAcAAAADQAAAA4AAAAdAAAACgAAABUAAAAdAAAAFQAAABAAAAAdAAAAEAAAAAcAAAAdAAAA
9765BwAAAAgAAAAdAAAACAAAAAoAAAAeAAAAEwAAABQAAAAeAAAAFAAAAAcAAAAeAAAABwAAABAA
9766AAAeAAAAEAAAAA8AAAAeAAAADwAAABMAAAAfAAAABgAAAAwAAAAfAAAADAAAABoAAAAfAAAA
9767GgAAABIAAAAfAAAAEgAAABYAAAAfAAAAFgAAAAYAAAA=]]></BinaryString>
9768 <float name="Reflectance">0</float>
9769 <float name="RightParamA">-0.5</float>
9770 <float name="RightParamB">0.5</float>
9771 <token name="RightSurface">0</token>
9772 <token name="RightSurfaceInput">0</token>
9773 <Vector3 name="RotVelocity">
9774 <X>0</X>
9775 <Y>0</Y>
9776 <Z>0</Z>
9777 </Vector3>
9778 <BinaryString name="Tags"></BinaryString>
9779 <Content name="TextureID"><null></null></Content>
9780 <float name="TopParamA">-0.5</float>
9781 <float name="TopParamB">0.5</float>
9782 <token name="TopSurface">0</token>
9783 <token name="TopSurfaceInput">0</token>
9784 <float name="Transparency">0</float>
9785 <Vector3 name="Velocity">
9786 <X>0</X>
9787 <Y>0</Y>
9788 <Z>0</Z>
9789 </Vector3>
9790 <Vector3 name="size">
9791 <X>1.20000005</X>
9792 <Y>4</Y>
9793 <Z>1.20000005</Z>
9794 </Vector3>
9795 </Properties>
9796 </Item>
9797 <Item class="MeshPart" referent="RBX4DD798A5ABF84DE4A4A1F013338850C4">
9798 <Properties>
9799 <bool name="Anchored">true</bool>
9800 <float name="BackParamA">-0.5</float>
9801 <float name="BackParamB">0.5</float>
9802 <token name="BackSurface">0</token>
9803 <token name="BackSurfaceInput">0</token>
9804 <float name="BottomParamA">-0.5</float>
9805 <float name="BottomParamB">0.5</float>
9806 <token name="BottomSurface">0</token>
9807 <token name="BottomSurfaceInput">0</token>
9808 <CoordinateFrame name="CFrame">
9809 <X>-6.33999777</X>
9810 <Y>2.01003408</Y>
9811 <Z>-9.59000397</Z>
9812 <R00>1</R00>
9813 <R01>0</R01>
9814 <R02>0</R02>
9815 <R10>0</R10>
9816 <R11>1</R11>
9817 <R12>0</R12>
9818 <R20>0</R20>
9819 <R21>0</R21>
9820 <R22>1</R22>
9821 </CoordinateFrame>
9822 <bool name="CanCollide">false</bool>
9823 <token name="CollisionFidelity">0</token>
9824 <int name="CollisionGroupId">0</int>
9825 <Color3uint8 name="Color3uint8">4279308561</Color3uint8>
9826 <PhysicalProperties name="CustomPhysicalProperties">
9827 <CustomPhysics>false</CustomPhysics>
9828 </PhysicalProperties>
9829 <float name="Elasticity">0.5</float>
9830 <float name="Friction">0.300000012</float>
9831 <float name="FrontParamA">-0.5</float>
9832 <float name="FrontParamB">0.5</float>
9833 <token name="FrontSurface">0</token>
9834 <token name="FrontSurfaceInput">0</token>
9835 <Vector3 name="InitialSize">
9836 <X>50</X>
9837 <Y>99.167099</Y>
9838 <Z>52.5730324</Z>
9839 </Vector3>
9840 <float name="LeftParamA">-0.5</float>
9841 <float name="LeftParamB">0.5</float>
9842 <token name="LeftSurface">0</token>
9843 <token name="LeftSurfaceInput">0</token>
9844 <bool name="Locked">true</bool>
9845 <token name="Material">288</token>
9846 <Content name="MeshID"><url>rbxassetid://667330318</url></Content>
9847 <Content name="MeshId"><url>rbxassetid://667330318</url></Content>
9848 <string name="Name">HighPoly</string>
9849 <BinaryString name="PhysicsData"><![CDATA[Q1NHUEhTAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAgD9gAAAA
9850BAAAABodXUH53SVCZuHJtgAAAACNVUZCwFn8tguniEAL3iVCQkpSQQAAyEGxRsZAQvcBQQun
9851iEAK3iVCTkpSwYe4kEGQIKBBeEpSwQAAAAClRsZAyUrSwVHiMsEJ3iVCKPcBwVHiMsEK3iVC
9852GvcBQQAAAAC1RsZAyUrSQQAAyMGoRsZAQ/cBwQuniMDetwLCTkpSQYe4kME+yUjBeEpSQRod
9853XcHMtwLCZuHJNgAAAACNVUbCqP8ON6E2d8GlRsZAPyGqwSp96MBxwyfBheKywaE2d0G1RsZA
9854PiGqQUArmEFiwyfBoRxdQaE2d0GlRsZAPyGqwQAAyEGoRsZAQ/cBwUArmEFmwyfBnBxdwaE2
9855d8G1RsZAPiGqQUArmMGknY9BnhxdQQAAyMGxRsZAQvcBQfMd3UBryUjB9yCqwXPiskE4yUjB
98561TsoNvMd3UBlyUjB+iCqQYe4kMFDyUjBc0pSwSp96MBqwyfBh+KyQUAXvMH5wifBRJYGNlHi
9857MkHetwLCGvcBwbQAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAQAAAAAAAAAEAAAA
9858AAAAAAUAAAAEAAAABgAAAAcAAAAEAAAABwAAAAEAAAAIAAAACQAAAAIAAAAIAAAAAgAAAAEA
9859AAAIAAAAAQAAAAcAAAAIAAAABwAAAAoAAAALAAAADAAAAA0AAAALAAAADQAAAA4AAAAPAAAA
9860BgAAABAAAAAPAAAACgAAAAcAAAAPAAAABwAAAAYAAAARAAAAEgAAAAMAAAARAAAAAwAAAAIA
9861AAARAAAAAgAAAAkAAAATAAAABgAAAAQAAAATAAAABAAAAAUAAAAUAAAAFQAAABMAAAAUAAAA
9862EwAAAAUAAAAUAAAABQAAAAAAAAAUAAAAAAAAAAMAAAAWAAAACQAAAAgAAAAWAAAACAAAABcA
9863AAAYAAAADAAAABYAAAAYAAAAFgAAABcAAAAYAAAAFwAAAAgAAAAYAAAACAAAAAoAAAAZAAAA
9864BgAAABMAAAAZAAAAEwAAABUAAAAZAAAADgAAABAAAAAZAAAAEAAAAAYAAAAaAAAAFQAAABQA
9865AAAaAAAAFAAAAAMAAAAaAAAAAwAAABIAAAAaAAAAEgAAAA4AAAAbAAAAEgAAABEAAAAbAAAA
9866EQAAAAkAAAAbAAAADgAAABIAAAAbAAAACwAAAA4AAAAcAAAACgAAAA8AAAAcAAAADwAAABAA
9867AAAcAAAAEAAAAA4AAAAcAAAADgAAAA0AAAAdAAAACwAAABsAAAAdAAAAGwAAAAkAAAAdAAAA
9868CQAAABYAAAAdAAAADAAAAAsAAAAdAAAAFgAAAAwAAAAeAAAACgAAABwAAAAeAAAAHAAAAA0A
9869AAAeAAAADQAAAAwAAAAeAAAADAAAABgAAAAeAAAAGAAAAAoAAAAfAAAAFQAAABoAAAAfAAAA
9870GgAAAA4AAAAfAAAADgAAABkAAAAfAAAAGQAAABUAAAA=]]></BinaryString>
9871 <float name="Reflectance">0</float>
9872 <float name="RightParamA">-0.5</float>
9873 <float name="RightParamB">0.5</float>
9874 <token name="RightSurface">0</token>
9875 <token name="RightSurfaceInput">0</token>
9876 <Vector3 name="RotVelocity">
9877 <X>0</X>
9878 <Y>0</Y>
9879 <Z>0</Z>
9880 </Vector3>
9881 <BinaryString name="Tags"></BinaryString>
9882 <Content name="TextureID"><null></null></Content>
9883 <float name="TopParamA">-0.5</float>
9884 <float name="TopParamB">0.5</float>
9885 <token name="TopSurface">0</token>
9886 <token name="TopSurfaceInput">0</token>
9887 <float name="Transparency">0</float>
9888 <Vector3 name="Velocity">
9889 <X>0</X>
9890 <Y>0</Y>
9891 <Z>0</Z>
9892 </Vector3>
9893 <Vector3 name="size">
9894 <X>2</X>
9895 <Y>4</Y>
9896 <Z>2</Z>
9897 </Vector3>
9898 </Properties>
9899 </Item>
9900 </Item>
9901 <Item class="Folder" referent="RBXB593B0A35E51490694F6889B5D36881A">
9902 <Properties>
9903 <string name="Name">2D</string>
9904 <BinaryString name="Tags"></BinaryString>
9905 </Properties>
9906 <Item class="ScreenGui" referent="RBXD3F45BAB5AEB48599E786A8578AE5671">
9907 <Properties>
9908 <int name="DisplayOrder">0</int>
9909 <bool name="Enabled">true</bool>
9910 <string name="Name">Profile</string>
9911 <bool name="ResetOnSpawn">true</bool>
9912 <BinaryString name="Tags"></BinaryString>
9913 </Properties>
9914 <Item class="ModuleScript" referent="RBX95E451CED7F44182B68AF1E5AC06A33D">
9915 <Properties>
9916 <Content name="LinkedSource"><null></null></Content>
9917 <string name="Name">Code</string>
9918 <string name="ScriptGuid">{B252AF98-3FEA-4131-8A88-1BB84B38FE98}</string>
9919 <ProtectedString name="Source"><![CDATA[return function(Remote, Data)
9920 local Alias, Bio, Color, Image = Data.Alias, Data.Bio, Data.Color, Data.Image;
9921 local Gui = script.Parent;
9922 local Frame = Gui:WaitForChild'Frame';
9923 local Update = Remote.Construct'Send'.String'PUpdate'.Limit(1).Mute();
9924
9925 local A, B, C, I, D = Frame:WaitForChild'Alias', Frame:WaitForChild'Bio', Frame:WaitForChild'Color', Frame:WaitForChild'Image', Frame:WaitForChild'Display';
9926 local Done = Frame:WaitForChild'Done';
9927
9928 script:Destroy();
9929
9930 local Child = Frame:GetChildren();
9931 local CColor = BrickColor.new(Color);
9932
9933 A.Text = Alias;
9934 B.Text = Bio;
9935 C.Text = tostring(CColor);
9936 I.Text = Image;
9937 D.Image = 'rbxassetid://' .. Image;
9938
9939 local function SetUiColor(Col)
9940 for Idx = 1, #Child do
9941 local K = Child[Idx];
9942
9943 if K:IsA'GuiObject' and (K.Name ~= 'Outside') then
9944 K.BackgroundColor3 = Col;
9945 end;
9946 end;
9947 end;
9948
9949 SetUiColor(CColor.Color);
9950
9951 I.Changed:Connect(function(Why)
9952 if (Why == 'Text') then
9953 local Tx = I.Text;
9954
9955 if tonumber(Tx) then
9956 D.Image = 'rbxassetid://' .. I.Text;
9957 end;
9958 end;
9959 end);
9960
9961 A.Changed:Connect(function(Why)
9962 if (Why == 'Text') then
9963 A.Text = A.Text:sub(1, 16);
9964 end;
9965 end);
9966
9967 B.Changed:Connect(function(Why)
9968 if (Why == 'Text') then
9969 A.Text = A.Text:sub(1, 200);
9970 end;
9971 end);
9972
9973 C.Changed:Connect(function(Why)
9974 if (Why == 'Text') then
9975 CColor = BrickColor.new(C.Text);
9976
9977 SetUiColor(CColor.Color);
9978 end;
9979 end);
9980
9981 Done.MouseButton1Click:Connect(function()
9982 Update.JSON{
9983 Alias = A.Text;
9984 Bio = B.Text;
9985 Color = CColor.Number;
9986 Image = I.Text;
9987 }.End();
9988
9989 Remote.Send('RemoveGui', Gui);
9990 end);
9991
9992 Frame.Visible = true;
9993end;]]></ProtectedString>
9994 <BinaryString name="Tags"></BinaryString>
9995 </Properties>
9996 </Item>
9997 <Item class="Frame" referent="RBXEF9906F9F233417CB3E476E95A289BAA">
9998 <Properties>
9999 <bool name="Active">true</bool>
10000 <Vector2 name="AnchorPoint">
10001 <X>0</X>
10002 <Y>0</Y>
10003 </Vector2>
10004 <Color3 name="BackgroundColor3">4294967295</Color3>
10005 <float name="BackgroundTransparency">1</float>
10006 <Color3 name="BorderColor3">4279970357</Color3>
10007 <int name="BorderSizePixel">0</int>
10008 <bool name="ClipsDescendants">false</bool>
10009 <bool name="Draggable">true</bool>
10010 <int name="LayoutOrder">0</int>
10011 <string name="Name">Frame</string>
10012 <Ref name="NextSelectionDown">null</Ref>
10013 <Ref name="NextSelectionLeft">null</Ref>
10014 <Ref name="NextSelectionRight">null</Ref>
10015 <Ref name="NextSelectionUp">null</Ref>
10016 <UDim2 name="Position">
10017 <XS>0.200000003</XS>
10018 <XO>0</XO>
10019 <YS>0.200000003</YS>
10020 <YO>0</YO>
10021 </UDim2>
10022 <float name="Rotation">0</float>
10023 <bool name="Selectable">false</bool>
10024 <Ref name="SelectionImageObject">null</Ref>
10025 <UDim2 name="Size">
10026 <XS>0.200000003</XS>
10027 <XO>0</XO>
10028 <YS>0.200000003</YS>
10029 <YO>0</YO>
10030 </UDim2>
10031 <token name="SizeConstraint">0</token>
10032 <bool name="SizeFromContents">false</bool>
10033 <token name="Style">0</token>
10034 <BinaryString name="Tags"></BinaryString>
10035 <bool name="Visible">true</bool>
10036 <int name="ZIndex">1</int>
10037 </Properties>
10038 <Item class="UIAspectRatioConstraint" referent="RBX20EC1DD5557741A0A849FC0485D9B573">
10039 <Properties>
10040 <float name="AspectRatio">1</float>
10041 <token name="AspectType">1</token>
10042 <token name="DominantAxis">0</token>
10043 <string name="Name">Aspect</string>
10044 <BinaryString name="Tags"></BinaryString>
10045 </Properties>
10046 </Item>
10047 <Item class="TextLabel" referent="RBX11FB467ED7344DFB8999A0BAAF57DD5C">
10048 <Properties>
10049 <bool name="Active">false</bool>
10050 <Vector2 name="AnchorPoint">
10051 <X>0</X>
10052 <Y>0</Y>
10053 </Vector2>
10054 <Color3 name="BackgroundColor3">4294967295</Color3>
10055 <float name="BackgroundTransparency">0.699999988</float>
10056 <Color3 name="BorderColor3">4279970357</Color3>
10057 <int name="BorderSizePixel">0</int>
10058 <bool name="ClipsDescendants">false</bool>
10059 <bool name="Draggable">false</bool>
10060 <token name="Font">8</token>
10061 <int name="LayoutOrder">0</int>
10062 <bool name="Localize">true</bool>
10063 <string name="Name">Top</string>
10064 <Ref name="NextSelectionDown">null</Ref>
10065 <Ref name="NextSelectionLeft">null</Ref>
10066 <Ref name="NextSelectionRight">null</Ref>
10067 <Ref name="NextSelectionUp">null</Ref>
10068 <UDim2 name="Position">
10069 <XS>0</XS>
10070 <XO>0</XO>
10071 <YS>0</YS>
10072 <YO>0</YO>
10073 </UDim2>
10074 <float name="Rotation">0</float>
10075 <bool name="Selectable">false</bool>
10076 <Ref name="SelectionImageObject">null</Ref>
10077 <UDim2 name="Size">
10078 <XS>1</XS>
10079 <XO>0</XO>
10080 <YS>0.100000001</YS>
10081 <YO>0</YO>
10082 </UDim2>
10083 <token name="SizeConstraint">0</token>
10084 <bool name="SizeFromContents">false</bool>
10085 <BinaryString name="Tags"></BinaryString>
10086 <string name="Text">Profile</string>
10087 <Color3 name="TextColor3">4294967295</Color3>
10088 <bool name="TextScaled">true</bool>
10089 <float name="TextSize">14</float>
10090 <Color3 name="TextStrokeColor3">4278190080</Color3>
10091 <float name="TextStrokeTransparency">0</float>
10092 <float name="TextTransparency">0</float>
10093 <bool name="TextWrapped">true</bool>
10094 <token name="TextXAlignment">2</token>
10095 <token name="TextYAlignment">1</token>
10096 <bool name="Visible">true</bool>
10097 <int name="ZIndex">2</int>
10098 </Properties>
10099 </Item>
10100 <Item class="TextBox" referent="RBXB722548705FB4A51901FD5FFF53DA6B0">
10101 <Properties>
10102 <bool name="Active">true</bool>
10103 <Vector2 name="AnchorPoint">
10104 <X>0</X>
10105 <Y>0</Y>
10106 </Vector2>
10107 <Color3 name="BackgroundColor3">4294967295</Color3>
10108 <float name="BackgroundTransparency">0.699999988</float>
10109 <Color3 name="BorderColor3">4279970357</Color3>
10110 <int name="BorderSizePixel">0</int>
10111 <bool name="ClearTextOnFocus">false</bool>
10112 <bool name="ClipsDescendants">false</bool>
10113 <bool name="Draggable">false</bool>
10114 <token name="Font">7</token>
10115 <int name="LayoutOrder">0</int>
10116 <bool name="MultiLine">false</bool>
10117 <string name="Name">Alias</string>
10118 <Ref name="NextSelectionDown">null</Ref>
10119 <Ref name="NextSelectionLeft">null</Ref>
10120 <Ref name="NextSelectionRight">null</Ref>
10121 <Ref name="NextSelectionUp">null</Ref>
10122 <UDim2 name="Position">
10123 <XS>0</XS>
10124 <XO>0</XO>
10125 <YS>0.200000003</YS>
10126 <YO>0</YO>
10127 </UDim2>
10128 <float name="Rotation">0</float>
10129 <bool name="Selectable">true</bool>
10130 <Ref name="SelectionImageObject">null</Ref>
10131 <bool name="ShowNativeInput">true</bool>
10132 <UDim2 name="Size">
10133 <XS>1</XS>
10134 <XO>0</XO>
10135 <YS>0.100000001</YS>
10136 <YO>0</YO>
10137 </UDim2>
10138 <token name="SizeConstraint">0</token>
10139 <bool name="SizeFromContents">false</bool>
10140 <BinaryString name="Tags"></BinaryString>
10141 <string name="Text">Alias</string>
10142 <Color3 name="TextColor3">4294967295</Color3>
10143 <bool name="TextScaled">true</bool>
10144 <float name="TextSize">14</float>
10145 <Color3 name="TextStrokeColor3">4278190080</Color3>
10146 <float name="TextStrokeTransparency">0.400000006</float>
10147 <float name="TextTransparency">0</float>
10148 <bool name="TextWrapped">true</bool>
10149 <token name="TextXAlignment">2</token>
10150 <token name="TextYAlignment">1</token>
10151 <bool name="Visible">true</bool>
10152 <int name="ZIndex">2</int>
10153 </Properties>
10154 </Item>
10155 <Item class="TextBox" referent="RBX68C7929071124663AE21F42A42966633">
10156 <Properties>
10157 <bool name="Active">true</bool>
10158 <Vector2 name="AnchorPoint">
10159 <X>0</X>
10160 <Y>0</Y>
10161 </Vector2>
10162 <Color3 name="BackgroundColor3">4294967295</Color3>
10163 <float name="BackgroundTransparency">0.699999988</float>
10164 <Color3 name="BorderColor3">4279970357</Color3>
10165 <int name="BorderSizePixel">0</int>
10166 <bool name="ClearTextOnFocus">false</bool>
10167 <bool name="ClipsDescendants">false</bool>
10168 <bool name="Draggable">false</bool>
10169 <token name="Font">7</token>
10170 <int name="LayoutOrder">0</int>
10171 <bool name="MultiLine">false</bool>
10172 <string name="Name">Bio</string>
10173 <Ref name="NextSelectionDown">null</Ref>
10174 <Ref name="NextSelectionLeft">null</Ref>
10175 <Ref name="NextSelectionRight">null</Ref>
10176 <Ref name="NextSelectionUp">null</Ref>
10177 <UDim2 name="Position">
10178 <XS>0</XS>
10179 <XO>0</XO>
10180 <YS>0.300000012</YS>
10181 <YO>0</YO>
10182 </UDim2>
10183 <float name="Rotation">0</float>
10184 <bool name="Selectable">true</bool>
10185 <Ref name="SelectionImageObject">null</Ref>
10186 <bool name="ShowNativeInput">true</bool>
10187 <UDim2 name="Size">
10188 <XS>1</XS>
10189 <XO>0</XO>
10190 <YS>0.699999988</YS>
10191 <YO>0</YO>
10192 </UDim2>
10193 <token name="SizeConstraint">0</token>
10194 <bool name="SizeFromContents">false</bool>
10195 <BinaryString name="Tags"></BinaryString>
10196 <string name="Text">No Bio.</string>
10197 <Color3 name="TextColor3">4294967295</Color3>
10198 <bool name="TextScaled">true</bool>
10199 <float name="TextSize">14</float>
10200 <Color3 name="TextStrokeColor3">4278190080</Color3>
10201 <float name="TextStrokeTransparency">0.400000006</float>
10202 <float name="TextTransparency">0</float>
10203 <bool name="TextWrapped">true</bool>
10204 <token name="TextXAlignment">0</token>
10205 <token name="TextYAlignment">0</token>
10206 <bool name="Visible">true</bool>
10207 <int name="ZIndex">2</int>
10208 </Properties>
10209 </Item>
10210 <Item class="ImageLabel" referent="RBX3EAB193DB28F4775BEEC112CA48ECA08">
10211 <Properties>
10212 <bool name="Active">false</bool>
10213 <Vector2 name="AnchorPoint">
10214 <X>0</X>
10215 <Y>0</Y>
10216 </Vector2>
10217 <Color3 name="BackgroundColor3">4294967295</Color3>
10218 <float name="BackgroundTransparency">0.699999988</float>
10219 <Color3 name="BorderColor3">4279970357</Color3>
10220 <int name="BorderSizePixel">0</int>
10221 <bool name="ClipsDescendants">false</bool>
10222 <bool name="Draggable">false</bool>
10223 <Content name="Image"><url>rbxassetid://133293265</url></Content>
10224 <Color3 name="ImageColor3">4294967295</Color3>
10225 <Vector2 name="ImageRectOffset">
10226 <X>0</X>
10227 <Y>0</Y>
10228 </Vector2>
10229 <Vector2 name="ImageRectSize">
10230 <X>0</X>
10231 <Y>0</Y>
10232 </Vector2>
10233 <float name="ImageTransparency">0</float>
10234 <int name="LayoutOrder">0</int>
10235 <string name="Name">Display</string>
10236 <Ref name="NextSelectionDown">null</Ref>
10237 <Ref name="NextSelectionLeft">null</Ref>
10238 <Ref name="NextSelectionRight">null</Ref>
10239 <Ref name="NextSelectionUp">null</Ref>
10240 <UDim2 name="Position">
10241 <XS>1</XS>
10242 <XO>0</XO>
10243 <YS>0.300000012</YS>
10244 <YO>0</YO>
10245 </UDim2>
10246 <float name="Rotation">0</float>
10247 <token name="ScaleType">0</token>
10248 <bool name="Selectable">false</bool>
10249 <Ref name="SelectionImageObject">null</Ref>
10250 <UDim2 name="Size">
10251 <XS>0.699999988</XS>
10252 <XO>0</XO>
10253 <YS>0.699999988</YS>
10254 <YO>0</YO>
10255 </UDim2>
10256 <token name="SizeConstraint">0</token>
10257 <bool name="SizeFromContents">false</bool>
10258 <Rect2D name="SliceCenter">
10259 <min>
10260 <X>0</X>
10261 <Y>0</Y>
10262 </min>
10263 <max>
10264 <X>0</X>
10265 <Y>0</Y>
10266 </max>
10267 </Rect2D>
10268 <BinaryString name="Tags"></BinaryString>
10269 <UDim2 name="TileSize">
10270 <XS>1</XS>
10271 <XO>0</XO>
10272 <YS>1</YS>
10273 <YO>0</YO>
10274 </UDim2>
10275 <bool name="Visible">true</bool>
10276 <int name="ZIndex">1</int>
10277 </Properties>
10278 </Item>
10279 <Item class="TextBox" referent="RBX36D30CAC59164D0CA4911CB759407A90">
10280 <Properties>
10281 <bool name="Active">true</bool>
10282 <Vector2 name="AnchorPoint">
10283 <X>0</X>
10284 <Y>0</Y>
10285 </Vector2>
10286 <Color3 name="BackgroundColor3">4294967295</Color3>
10287 <float name="BackgroundTransparency">0.699999988</float>
10288 <Color3 name="BorderColor3">4279970357</Color3>
10289 <int name="BorderSizePixel">0</int>
10290 <bool name="ClearTextOnFocus">false</bool>
10291 <bool name="ClipsDescendants">false</bool>
10292 <bool name="Draggable">false</bool>
10293 <token name="Font">7</token>
10294 <int name="LayoutOrder">0</int>
10295 <bool name="MultiLine">false</bool>
10296 <string name="Name">Image</string>
10297 <Ref name="NextSelectionDown">null</Ref>
10298 <Ref name="NextSelectionLeft">null</Ref>
10299 <Ref name="NextSelectionRight">null</Ref>
10300 <Ref name="NextSelectionUp">null</Ref>
10301 <UDim2 name="Position">
10302 <XS>1</XS>
10303 <XO>0</XO>
10304 <YS>0.200000003</YS>
10305 <YO>0</YO>
10306 </UDim2>
10307 <float name="Rotation">0</float>
10308 <bool name="Selectable">true</bool>
10309 <Ref name="SelectionImageObject">null</Ref>
10310 <bool name="ShowNativeInput">true</bool>
10311 <UDim2 name="Size">
10312 <XS>0.699999988</XS>
10313 <XO>0</XO>
10314 <YS>0.100000001</YS>
10315 <YO>0</YO>
10316 </UDim2>
10317 <token name="SizeConstraint">0</token>
10318 <bool name="SizeFromContents">false</bool>
10319 <BinaryString name="Tags"></BinaryString>
10320 <string name="Text">Image</string>
10321 <Color3 name="TextColor3">4294967295</Color3>
10322 <bool name="TextScaled">true</bool>
10323 <float name="TextSize">14</float>
10324 <Color3 name="TextStrokeColor3">4278190080</Color3>
10325 <float name="TextStrokeTransparency">0.400000006</float>
10326 <float name="TextTransparency">0</float>
10327 <bool name="TextWrapped">true</bool>
10328 <token name="TextXAlignment">2</token>
10329 <token name="TextYAlignment">1</token>
10330 <bool name="Visible">true</bool>
10331 <int name="ZIndex">2</int>
10332 </Properties>
10333 </Item>
10334 <Item class="Frame" referent="RBX120CF02FB2EE4A80B51375BE82B94DC5">
10335 <Properties>
10336 <bool name="Active">false</bool>
10337 <Vector2 name="AnchorPoint">
10338 <X>0</X>
10339 <Y>0</Y>
10340 </Vector2>
10341 <Color3 name="BackgroundColor3">4294967295</Color3>
10342 <float name="BackgroundTransparency">0.699999988</float>
10343 <Color3 name="BorderColor3">4279970357</Color3>
10344 <int name="BorderSizePixel">0</int>
10345 <bool name="ClipsDescendants">false</bool>
10346 <bool name="Draggable">false</bool>
10347 <int name="LayoutOrder">0</int>
10348 <string name="Name">Frame</string>
10349 <Ref name="NextSelectionDown">null</Ref>
10350 <Ref name="NextSelectionLeft">null</Ref>
10351 <Ref name="NextSelectionRight">null</Ref>
10352 <Ref name="NextSelectionUp">null</Ref>
10353 <UDim2 name="Position">
10354 <XS>0</XS>
10355 <XO>0</XO>
10356 <YS>0.100000001</YS>
10357 <YO>0</YO>
10358 </UDim2>
10359 <float name="Rotation">0</float>
10360 <bool name="Selectable">false</bool>
10361 <Ref name="SelectionImageObject">null</Ref>
10362 <UDim2 name="Size">
10363 <XS>1</XS>
10364 <XO>0</XO>
10365 <YS>0.100000001</YS>
10366 <YO>0</YO>
10367 </UDim2>
10368 <token name="SizeConstraint">0</token>
10369 <bool name="SizeFromContents">false</bool>
10370 <token name="Style">0</token>
10371 <BinaryString name="Tags"></BinaryString>
10372 <bool name="Visible">true</bool>
10373 <int name="ZIndex">1</int>
10374 </Properties>
10375 </Item>
10376 <Item class="TextButton" referent="RBX879B9FF576F14C6598B3AE8B39A4B949">
10377 <Properties>
10378 <bool name="Active">false</bool>
10379 <Vector2 name="AnchorPoint">
10380 <X>0</X>
10381 <Y>0</Y>
10382 </Vector2>
10383 <bool name="AutoButtonColor">true</bool>
10384 <Color3 name="BackgroundColor3">4294967295</Color3>
10385 <float name="BackgroundTransparency">0.699999988</float>
10386 <Color3 name="BorderColor3">4279970357</Color3>
10387 <int name="BorderSizePixel">0</int>
10388 <bool name="ClipsDescendants">false</bool>
10389 <bool name="Draggable">false</bool>
10390 <token name="Font">8</token>
10391 <int name="LayoutOrder">0</int>
10392 <bool name="Modal">false</bool>
10393 <string name="Name">Done</string>
10394 <Ref name="NextSelectionDown">null</Ref>
10395 <Ref name="NextSelectionLeft">null</Ref>
10396 <Ref name="NextSelectionRight">null</Ref>
10397 <Ref name="NextSelectionUp">null</Ref>
10398 <UDim2 name="Position">
10399 <XS>1</XS>
10400 <XO>0</XO>
10401 <YS>0</YS>
10402 <YO>0</YO>
10403 </UDim2>
10404 <float name="Rotation">0</float>
10405 <bool name="Selectable">true</bool>
10406 <bool name="Selected">false</bool>
10407 <Ref name="SelectionImageObject">null</Ref>
10408 <UDim2 name="Size">
10409 <XS>0.699999988</XS>
10410 <XO>0</XO>
10411 <YS>0.200000003</YS>
10412 <YO>0</YO>
10413 </UDim2>
10414 <token name="SizeConstraint">0</token>
10415 <bool name="SizeFromContents">false</bool>
10416 <token name="Style">0</token>
10417 <BinaryString name="Tags"></BinaryString>
10418 <string name="Text">Done</string>
10419 <Color3 name="TextColor3">4278233600</Color3>
10420 <bool name="TextScaled">true</bool>
10421 <float name="TextSize">14</float>
10422 <Color3 name="TextStrokeColor3">4294967295</Color3>
10423 <float name="TextStrokeTransparency">0.800000012</float>
10424 <float name="TextTransparency">0</float>
10425 <bool name="TextWrapped">true</bool>
10426 <token name="TextXAlignment">2</token>
10427 <token name="TextYAlignment">1</token>
10428 <bool name="Visible">true</bool>
10429 <int name="ZIndex">2</int>
10430 </Properties>
10431 </Item>
10432 <Item class="TextBox" referent="RBX14312DFF38D84BC28E3864D2DFCE9F4E">
10433 <Properties>
10434 <bool name="Active">true</bool>
10435 <Vector2 name="AnchorPoint">
10436 <X>0</X>
10437 <Y>0</Y>
10438 </Vector2>
10439 <Color3 name="BackgroundColor3">4294967295</Color3>
10440 <float name="BackgroundTransparency">0.699999988</float>
10441 <Color3 name="BorderColor3">4279970357</Color3>
10442 <int name="BorderSizePixel">0</int>
10443 <bool name="ClearTextOnFocus">false</bool>
10444 <bool name="ClipsDescendants">false</bool>
10445 <bool name="Draggable">false</bool>
10446 <token name="Font">7</token>
10447 <int name="LayoutOrder">0</int>
10448 <bool name="MultiLine">false</bool>
10449 <string name="Name">Color</string>
10450 <Ref name="NextSelectionDown">null</Ref>
10451 <Ref name="NextSelectionLeft">null</Ref>
10452 <Ref name="NextSelectionRight">null</Ref>
10453 <Ref name="NextSelectionUp">null</Ref>
10454 <UDim2 name="Position">
10455 <XS>0</XS>
10456 <XO>0</XO>
10457 <YS>1</YS>
10458 <YO>0</YO>
10459 </UDim2>
10460 <float name="Rotation">0</float>
10461 <bool name="Selectable">true</bool>
10462 <Ref name="SelectionImageObject">null</Ref>
10463 <bool name="ShowNativeInput">true</bool>
10464 <UDim2 name="Size">
10465 <XS>1.70000005</XS>
10466 <XO>0</XO>
10467 <YS>0.100000001</YS>
10468 <YO>0</YO>
10469 </UDim2>
10470 <token name="SizeConstraint">0</token>
10471 <bool name="SizeFromContents">false</bool>
10472 <BinaryString name="Tags"></BinaryString>
10473 <string name="Text">Color</string>
10474 <Color3 name="TextColor3">4294967295</Color3>
10475 <bool name="TextScaled">true</bool>
10476 <float name="TextSize">14</float>
10477 <Color3 name="TextStrokeColor3">4278190080</Color3>
10478 <float name="TextStrokeTransparency">0.400000006</float>
10479 <float name="TextTransparency">0</float>
10480 <bool name="TextWrapped">true</bool>
10481 <token name="TextXAlignment">2</token>
10482 <token name="TextYAlignment">1</token>
10483 <bool name="Visible">true</bool>
10484 <int name="ZIndex">2</int>
10485 </Properties>
10486 </Item>
10487 <Item class="Frame" referent="RBX5ACA86055743494CA5E6A0331E2A2A91">
10488 <Properties>
10489 <bool name="Active">false</bool>
10490 <Vector2 name="AnchorPoint">
10491 <X>0</X>
10492 <Y>0</Y>
10493 </Vector2>
10494 <Color3 name="BackgroundColor3">4278190080</Color3>
10495 <float name="BackgroundTransparency">0.5</float>
10496 <Color3 name="BorderColor3">4279970357</Color3>
10497 <int name="BorderSizePixel">0</int>
10498 <bool name="ClipsDescendants">false</bool>
10499 <bool name="Draggable">false</bool>
10500 <int name="LayoutOrder">0</int>
10501 <string name="Name">Outside</string>
10502 <Ref name="NextSelectionDown">null</Ref>
10503 <Ref name="NextSelectionLeft">null</Ref>
10504 <Ref name="NextSelectionRight">null</Ref>
10505 <Ref name="NextSelectionUp">null</Ref>
10506 <UDim2 name="Position">
10507 <XS>0</XS>
10508 <XO>0</XO>
10509 <YS>-0.0500000007</YS>
10510 <YO>0</YO>
10511 </UDim2>
10512 <float name="Rotation">0</float>
10513 <bool name="Selectable">false</bool>
10514 <Ref name="SelectionImageObject">null</Ref>
10515 <UDim2 name="Size">
10516 <XS>1.70000005</XS>
10517 <XO>0</XO>
10518 <YS>0.0500000007</YS>
10519 <YO>0</YO>
10520 </UDim2>
10521 <token name="SizeConstraint">0</token>
10522 <bool name="SizeFromContents">false</bool>
10523 <token name="Style">0</token>
10524 <BinaryString name="Tags"></BinaryString>
10525 <bool name="Visible">true</bool>
10526 <int name="ZIndex">1</int>
10527 </Properties>
10528 </Item>
10529 <Item class="Frame" referent="RBX31F34365C0E2474E8A687B9B811ED7FF">
10530 <Properties>
10531 <bool name="Active">false</bool>
10532 <Vector2 name="AnchorPoint">
10533 <X>0</X>
10534 <Y>0</Y>
10535 </Vector2>
10536 <Color3 name="BackgroundColor3">4278190080</Color3>
10537 <float name="BackgroundTransparency">0.5</float>
10538 <Color3 name="BorderColor3">4279970357</Color3>
10539 <int name="BorderSizePixel">0</int>
10540 <bool name="ClipsDescendants">false</bool>
10541 <bool name="Draggable">false</bool>
10542 <int name="LayoutOrder">0</int>
10543 <string name="Name">Outside</string>
10544 <Ref name="NextSelectionDown">null</Ref>
10545 <Ref name="NextSelectionLeft">null</Ref>
10546 <Ref name="NextSelectionRight">null</Ref>
10547 <Ref name="NextSelectionUp">null</Ref>
10548 <UDim2 name="Position">
10549 <XS>-0.0500000007</XS>
10550 <XO>0</XO>
10551 <YS>-0.0500000007</YS>
10552 <YO>0</YO>
10553 </UDim2>
10554 <float name="Rotation">0</float>
10555 <bool name="Selectable">false</bool>
10556 <Ref name="SelectionImageObject">null</Ref>
10557 <UDim2 name="Size">
10558 <XS>0.0500000007</XS>
10559 <XO>0</XO>
10560 <YS>1.20000005</YS>
10561 <YO>0</YO>
10562 </UDim2>
10563 <token name="SizeConstraint">0</token>
10564 <bool name="SizeFromContents">false</bool>
10565 <token name="Style">0</token>
10566 <BinaryString name="Tags"></BinaryString>
10567 <bool name="Visible">true</bool>
10568 <int name="ZIndex">1</int>
10569 </Properties>
10570 </Item>
10571 <Item class="Frame" referent="RBX714A2BE0815143ACAD6E88EBCA033AB3">
10572 <Properties>
10573 <bool name="Active">false</bool>
10574 <Vector2 name="AnchorPoint">
10575 <X>0</X>
10576 <Y>0</Y>
10577 </Vector2>
10578 <Color3 name="BackgroundColor3">4278190080</Color3>
10579 <float name="BackgroundTransparency">0.5</float>
10580 <Color3 name="BorderColor3">4279970357</Color3>
10581 <int name="BorderSizePixel">0</int>
10582 <bool name="ClipsDescendants">false</bool>
10583 <bool name="Draggable">false</bool>
10584 <int name="LayoutOrder">0</int>
10585 <string name="Name">Outside</string>
10586 <Ref name="NextSelectionDown">null</Ref>
10587 <Ref name="NextSelectionLeft">null</Ref>
10588 <Ref name="NextSelectionRight">null</Ref>
10589 <Ref name="NextSelectionUp">null</Ref>
10590 <UDim2 name="Position">
10591 <XS>1.70000005</XS>
10592 <XO>0</XO>
10593 <YS>-0.0500000007</YS>
10594 <YO>0</YO>
10595 </UDim2>
10596 <float name="Rotation">0</float>
10597 <bool name="Selectable">false</bool>
10598 <Ref name="SelectionImageObject">null</Ref>
10599 <UDim2 name="Size">
10600 <XS>0.0500000007</XS>
10601 <XO>0</XO>
10602 <YS>1.20000005</YS>
10603 <YO>0</YO>
10604 </UDim2>
10605 <token name="SizeConstraint">0</token>
10606 <bool name="SizeFromContents">false</bool>
10607 <token name="Style">0</token>
10608 <BinaryString name="Tags"></BinaryString>
10609 <bool name="Visible">true</bool>
10610 <int name="ZIndex">1</int>
10611 </Properties>
10612 </Item>
10613 <Item class="Frame" referent="RBXCBC1EE49BD924654921BCA1731475E47">
10614 <Properties>
10615 <bool name="Active">false</bool>
10616 <Vector2 name="AnchorPoint">
10617 <X>0</X>
10618 <Y>0</Y>
10619 </Vector2>
10620 <Color3 name="BackgroundColor3">4278190080</Color3>
10621 <float name="BackgroundTransparency">0.5</float>
10622 <Color3 name="BorderColor3">4279970357</Color3>
10623 <int name="BorderSizePixel">0</int>
10624 <bool name="ClipsDescendants">false</bool>
10625 <bool name="Draggable">false</bool>
10626 <int name="LayoutOrder">0</int>
10627 <string name="Name">Outside</string>
10628 <Ref name="NextSelectionDown">null</Ref>
10629 <Ref name="NextSelectionLeft">null</Ref>
10630 <Ref name="NextSelectionRight">null</Ref>
10631 <Ref name="NextSelectionUp">null</Ref>
10632 <UDim2 name="Position">
10633 <XS>0</XS>
10634 <XO>0</XO>
10635 <YS>1.10000002</YS>
10636 <YO>0</YO>
10637 </UDim2>
10638 <float name="Rotation">0</float>
10639 <bool name="Selectable">false</bool>
10640 <Ref name="SelectionImageObject">null</Ref>
10641 <UDim2 name="Size">
10642 <XS>1.70000005</XS>
10643 <XO>0</XO>
10644 <YS>0.0500000007</YS>
10645 <YO>0</YO>
10646 </UDim2>
10647 <token name="SizeConstraint">0</token>
10648 <bool name="SizeFromContents">false</bool>
10649 <token name="Style">0</token>
10650 <BinaryString name="Tags"></BinaryString>
10651 <bool name="Visible">true</bool>
10652 <int name="ZIndex">1</int>
10653 </Properties>
10654 </Item>
10655 </Item>
10656 </Item>
10657 <Item class="ScreenGui" referent="RBXFC6B1E592BE24DC0BF35F81089E1AB16">
10658 <Properties>
10659 <int name="DisplayOrder">0</int>
10660 <bool name="Enabled">true</bool>
10661 <string name="Name">Commands</string>
10662 <bool name="ResetOnSpawn">true</bool>
10663 <BinaryString name="Tags"></BinaryString>
10664 </Properties>
10665 <Item class="ModuleScript" referent="RBX984F62C79FC84133A6056626DBC9D4D2">
10666 <Properties>
10667 <Content name="LinkedSource"><null></null></Content>
10668 <string name="Name">Code</string>
10669 <string name="ScriptGuid">{36788681-A20B-4D16-A27C-6A039CA12A26}</string>
10670 <ProtectedString name="Source"><![CDATA[return function(Remote, Data)
10671 local Gui = script.Parent;
10672
10673 script:Destroy();
10674
10675 local Main = {};
10676 local pcall = pcall;
10677 local UDim2 = UDim2.new;
10678 local Box = Instance.new'TextBox';
10679 local Step = Remote.RunService.Heartbeat;
10680 local Rand = BrickColor.Random().Color;
10681
10682 local Cons = Data.Bind;
10683
10684 local function Focus()
10685 pcall(Box.TweenPosition, Box, UDim2(0, 0, 0, 0), 'In', 'Back', 0.3, true);
10686
10687 for Idx = 1, #Main do
10688 local I = Main[Idx];
10689
10690 pcall(I.TweenPosition, I, UDim2((Idx - 1) / 25, 0, 0, 0), 'In', 'Back', 0.3, true);
10691
10692 Step:wait();
10693 end;
10694 end;
10695
10696 local function Retreat()
10697 pcall(Box.TweenPosition, Box, UDim2(0, 0, 0, -38), 'Out', 'Sine', 0.3, true);
10698
10699 for Idx = 1, #Main do
10700 local I = Main[Idx];
10701
10702 pcall(I.TweenPosition, I, UDim2((Idx - 1) / 25, 0, 0, -38), 'Out', 'Sine', 0.3, true);
10703
10704 Step:wait();
10705 end;
10706 end;
10707
10708 Box.Size = UDim2(1, 0, 0, 38);
10709 Box.Position = UDim2(0, 0, 0, -38);
10710 Box.BackgroundTransparency = 1;
10711
10712 Box.Font = 'SciFi';
10713 Box.TextColor3 = Color3.new(1, 1, 1);
10714 Box.TextStrokeColor3 = Color3.new(0, 0, 0);
10715 Box.TextStrokeTransparency = 0.3;
10716
10717 Box.TextScaled = true;
10718 Box.TextWrapped = true;
10719
10720 Box.TextYAlignment = 'Top';
10721-- Box.TextXAlignment = 'Left';
10722
10723 for Idx = 1, 25 do
10724 local Frame = Instance.new'Frame';
10725 local R, G, B = Rand.r / (Idx / 25), Rand.g / (Idx / 25), Rand.b / (Idx / 25);
10726
10727 Main[#Main + 1] = Frame;
10728
10729 Frame.Transparency = 1 - (1 / Idx);
10730 Frame.Position = UDim2((Idx - 1) / 25, 0, 0, -38);
10731 Frame.Size = UDim2(0.04, 0, 0, 38);
10732 Frame.BackgroundColor3 = Color3.new(R, G, B);
10733 Frame.BorderSizePixel = 0;
10734 Frame.Name = 'KType' .. Idx;
10735
10736 Frame.Parent = Gui;
10737 end;
10738
10739 if Data.Enabled then
10740 Remote.UserInputService.InputBegan:Connect(function(Key, Process)
10741 if (not Process) and (Key.KeyCode.Name == Cons) then
10742 Box:CaptureFocus();
10743 end;
10744 end);
10745
10746 Box.Focused:Connect(Focus);
10747
10748 Box.FocusLost:Connect(function() -- Got bored and decided best solution.
10749 Box.Text = '';
10750
10751 Retreat();
10752 end);
10753 end;
10754
10755 Box.Name = 'CeleryBox';
10756 Box.Text = '';
10757 Box.Parent = Gui;
10758end;]]></ProtectedString>
10759 <BinaryString name="Tags"></BinaryString>
10760 </Properties>
10761 </Item>
10762 </Item>
10763 <Item class="ScreenGui" referent="RBX9DD9962F1BD54889A528D129288FDA83">
10764 <Properties>
10765 <int name="DisplayOrder">0</int>
10766 <bool name="Enabled">true</bool>
10767 <string name="Name">Message</string>
10768 <bool name="ResetOnSpawn">true</bool>
10769 <BinaryString name="Tags"></BinaryString>
10770 </Properties>
10771 <Item class="TextLabel" referent="RBXA701F1B502C94AA4B363C3BFE850B13B">
10772 <Properties>
10773 <bool name="Active">false</bool>
10774 <Vector2 name="AnchorPoint">
10775 <X>0</X>
10776 <Y>0</Y>
10777 </Vector2>
10778 <Color3 name="BackgroundColor3">4294967295</Color3>
10779 <float name="BackgroundTransparency">1</float>
10780 <Color3 name="BorderColor3">4279970357</Color3>
10781 <int name="BorderSizePixel">1</int>
10782 <bool name="ClipsDescendants">false</bool>
10783 <bool name="Draggable">false</bool>
10784 <token name="Font">8</token>
10785 <int name="LayoutOrder">0</int>
10786 <bool name="Localize">true</bool>
10787 <string name="Name">Main</string>
10788 <Ref name="NextSelectionDown">null</Ref>
10789 <Ref name="NextSelectionLeft">null</Ref>
10790 <Ref name="NextSelectionRight">null</Ref>
10791 <Ref name="NextSelectionUp">null</Ref>
10792 <UDim2 name="Position">
10793 <XS>0.200000003</XS>
10794 <XO>0</XO>
10795 <YS>-0.349999994</YS>
10796 <YO>0</YO>
10797 </UDim2>
10798 <float name="Rotation">0</float>
10799 <bool name="Selectable">false</bool>
10800 <Ref name="SelectionImageObject">null</Ref>
10801 <UDim2 name="Size">
10802 <XS>0.600000024</XS>
10803 <XO>0</XO>
10804 <YS>0.300000012</YS>
10805 <YO>0</YO>
10806 </UDim2>
10807 <token name="SizeConstraint">0</token>
10808 <bool name="SizeFromContents">false</bool>
10809 <BinaryString name="Tags"></BinaryString>
10810 <string name="Text">What, seen a ghost? No wonder no one heard your screams.</string>
10811 <Color3 name="TextColor3">4294967295</Color3>
10812 <bool name="TextScaled">true</bool>
10813 <float name="TextSize">14</float>
10814 <Color3 name="TextStrokeColor3">4278190080</Color3>
10815 <float name="TextStrokeTransparency">1</float>
10816 <float name="TextTransparency">0</float>
10817 <bool name="TextWrapped">true</bool>
10818 <token name="TextXAlignment">2</token>
10819 <token name="TextYAlignment">1</token>
10820 <bool name="Visible">true</bool>
10821 <int name="ZIndex">4</int>
10822 </Properties>
10823 <Item class="TextLabel" referent="RBX8BB5D6F1CAD64401BB3EEACB980DF95A">
10824 <Properties>
10825 <bool name="Active">false</bool>
10826 <Vector2 name="AnchorPoint">
10827 <X>0</X>
10828 <Y>0</Y>
10829 </Vector2>
10830 <Color3 name="BackgroundColor3">4285756275</Color3>
10831 <float name="BackgroundTransparency">1</float>
10832 <Color3 name="BorderColor3">4279970357</Color3>
10833 <int name="BorderSizePixel">0</int>
10834 <bool name="ClipsDescendants">false</bool>
10835 <bool name="Draggable">false</bool>
10836 <token name="Font">8</token>
10837 <int name="LayoutOrder">0</int>
10838 <bool name="Localize">true</bool>
10839 <string name="Name">Shade</string>
10840 <Ref name="NextSelectionDown">null</Ref>
10841 <Ref name="NextSelectionLeft">null</Ref>
10842 <Ref name="NextSelectionRight">null</Ref>
10843 <Ref name="NextSelectionUp">null</Ref>
10844 <UDim2 name="Position">
10845 <XS>0</XS>
10846 <XO>-2</XO>
10847 <YS>0</YS>
10848 <YO>-2</YO>
10849 </UDim2>
10850 <float name="Rotation">0</float>
10851 <bool name="Selectable">false</bool>
10852 <Ref name="SelectionImageObject">null</Ref>
10853 <UDim2 name="Size">
10854 <XS>1</XS>
10855 <XO>0</XO>
10856 <YS>1</YS>
10857 <YO>0</YO>
10858 </UDim2>
10859 <token name="SizeConstraint">0</token>
10860 <bool name="SizeFromContents">false</bool>
10861 <BinaryString name="Tags"></BinaryString>
10862 <string name="Text">What, seen a ghost? No wonder no one heard your screams.</string>
10863 <Color3 name="TextColor3">4278190080</Color3>
10864 <bool name="TextScaled">true</bool>
10865 <float name="TextSize">14</float>
10866 <Color3 name="TextStrokeColor3">4278190080</Color3>
10867 <float name="TextStrokeTransparency">1</float>
10868 <float name="TextTransparency">0</float>
10869 <bool name="TextWrapped">true</bool>
10870 <token name="TextXAlignment">2</token>
10871 <token name="TextYAlignment">1</token>
10872 <bool name="Visible">true</bool>
10873 <int name="ZIndex">3</int>
10874 </Properties>
10875 </Item>
10876 <Item class="Frame" referent="RBX14DB20A42EDF45299E221DFA3EC4A3D9">
10877 <Properties>
10878 <bool name="Active">false</bool>
10879 <Vector2 name="AnchorPoint">
10880 <X>0</X>
10881 <Y>0</Y>
10882 </Vector2>
10883 <Color3 name="BackgroundColor3">4282795590</Color3>
10884 <float name="BackgroundTransparency">0</float>
10885 <Color3 name="BorderColor3">4279970357</Color3>
10886 <int name="BorderSizePixel">0</int>
10887 <bool name="ClipsDescendants">false</bool>
10888 <bool name="Draggable">false</bool>
10889 <int name="LayoutOrder">0</int>
10890 <string name="Name">S2</string>
10891 <Ref name="NextSelectionDown">null</Ref>
10892 <Ref name="NextSelectionLeft">null</Ref>
10893 <Ref name="NextSelectionRight">null</Ref>
10894 <Ref name="NextSelectionUp">null</Ref>
10895 <UDim2 name="Position">
10896 <XS>0</XS>
10897 <XO>-3</XO>
10898 <YS>0</YS>
10899 <YO>-3</YO>
10900 </UDim2>
10901 <float name="Rotation">0</float>
10902 <bool name="Selectable">false</bool>
10903 <Ref name="SelectionImageObject">null</Ref>
10904 <UDim2 name="Size">
10905 <XS>1</XS>
10906 <XO>0</XO>
10907 <YS>1</YS>
10908 <YO>0</YO>
10909 </UDim2>
10910 <token name="SizeConstraint">0</token>
10911 <bool name="SizeFromContents">false</bool>
10912 <token name="Style">0</token>
10913 <BinaryString name="Tags"></BinaryString>
10914 <bool name="Visible">true</bool>
10915 <int name="ZIndex">1</int>
10916 </Properties>
10917 </Item>
10918 <Item class="Frame" referent="RBXDF5E21A85F1445378872FD8E92ABB912">
10919 <Properties>
10920 <bool name="Active">false</bool>
10921 <Vector2 name="AnchorPoint">
10922 <X>0</X>
10923 <Y>0</Y>
10924 </Vector2>
10925 <Color3 name="BackgroundColor3">4287401100</Color3>
10926 <float name="BackgroundTransparency">0</float>
10927 <Color3 name="BorderColor3">4279970357</Color3>
10928 <int name="BorderSizePixel">0</int>
10929 <bool name="ClipsDescendants">false</bool>
10930 <bool name="Draggable">false</bool>
10931 <int name="LayoutOrder">0</int>
10932 <string name="Name">S1</string>
10933 <Ref name="NextSelectionDown">null</Ref>
10934 <Ref name="NextSelectionLeft">null</Ref>
10935 <Ref name="NextSelectionRight">null</Ref>
10936 <Ref name="NextSelectionUp">null</Ref>
10937 <UDim2 name="Position">
10938 <XS>0</XS>
10939 <XO>0</XO>
10940 <YS>0</YS>
10941 <YO>0</YO>
10942 </UDim2>
10943 <float name="Rotation">0</float>
10944 <bool name="Selectable">false</bool>
10945 <Ref name="SelectionImageObject">null</Ref>
10946 <UDim2 name="Size">
10947 <XS>1</XS>
10948 <XO>0</XO>
10949 <YS>1</YS>
10950 <YO>0</YO>
10951 </UDim2>
10952 <token name="SizeConstraint">0</token>
10953 <bool name="SizeFromContents">false</bool>
10954 <token name="Style">0</token>
10955 <BinaryString name="Tags"></BinaryString>
10956 <bool name="Visible">true</bool>
10957 <int name="ZIndex">2</int>
10958 </Properties>
10959 </Item>
10960 <Item class="Frame" referent="RBX80A9E0EC89C440BC96B987CFD6FC30A0">
10961 <Properties>
10962 <bool name="Active">false</bool>
10963 <Vector2 name="AnchorPoint">
10964 <X>0</X>
10965 <Y>0</Y>
10966 </Vector2>
10967 <Color3 name="BackgroundColor3">4282795590</Color3>
10968 <float name="BackgroundTransparency">0</float>
10969 <Color3 name="BorderColor3">4279970357</Color3>
10970 <int name="BorderSizePixel">0</int>
10971 <bool name="ClipsDescendants">false</bool>
10972 <bool name="Draggable">false</bool>
10973 <int name="LayoutOrder">0</int>
10974 <string name="Name">S3</string>
10975 <Ref name="NextSelectionDown">null</Ref>
10976 <Ref name="NextSelectionLeft">null</Ref>
10977 <Ref name="NextSelectionRight">null</Ref>
10978 <Ref name="NextSelectionUp">null</Ref>
10979 <UDim2 name="Position">
10980 <XS>0</XS>
10981 <XO>-3</XO>
10982 <YS>-0.100000001</YS>
10983 <YO>-3</YO>
10984 </UDim2>
10985 <float name="Rotation">0</float>
10986 <bool name="Selectable">false</bool>
10987 <Ref name="SelectionImageObject">null</Ref>
10988 <UDim2 name="Size">
10989 <XS>1</XS>
10990 <XO>0</XO>
10991 <YS>0.100000001</YS>
10992 <YO>0</YO>
10993 </UDim2>
10994 <token name="SizeConstraint">0</token>
10995 <bool name="SizeFromContents">false</bool>
10996 <token name="Style">0</token>
10997 <BinaryString name="Tags"></BinaryString>
10998 <bool name="Visible">true</bool>
10999 <int name="ZIndex">1</int>
11000 </Properties>
11001 </Item>
11002 <Item class="TextLabel" referent="RBX3C73870E8DD34B0DB1F0A804C0D03C5D">
11003 <Properties>
11004 <bool name="Active">false</bool>
11005 <Vector2 name="AnchorPoint">
11006 <X>0</X>
11007 <Y>0</Y>
11008 </Vector2>
11009 <Color3 name="BackgroundColor3">4287401100</Color3>
11010 <float name="BackgroundTransparency">0</float>
11011 <Color3 name="BorderColor3">4279970357</Color3>
11012 <int name="BorderSizePixel">0</int>
11013 <bool name="ClipsDescendants">false</bool>
11014 <bool name="Draggable">false</bool>
11015 <token name="Font">5</token>
11016 <int name="LayoutOrder">0</int>
11017 <bool name="Localize">true</bool>
11018 <string name="Name">User</string>
11019 <Ref name="NextSelectionDown">null</Ref>
11020 <Ref name="NextSelectionLeft">null</Ref>
11021 <Ref name="NextSelectionRight">null</Ref>
11022 <Ref name="NextSelectionUp">null</Ref>
11023 <UDim2 name="Position">
11024 <XS>0</XS>
11025 <XO>0</XO>
11026 <YS>-0.100000001</YS>
11027 <YO>0</YO>
11028 </UDim2>
11029 <float name="Rotation">0</float>
11030 <bool name="Selectable">false</bool>
11031 <Ref name="SelectionImageObject">null</Ref>
11032 <UDim2 name="Size">
11033 <XS>1</XS>
11034 <XO>0</XO>
11035 <YS>0.100000001</YS>
11036 <YO>0</YO>
11037 </UDim2>
11038 <token name="SizeConstraint">0</token>
11039 <bool name="SizeFromContents">false</bool>
11040 <BinaryString name="Tags"></BinaryString>
11041 <string name="Text">Pumpkin Pie</string>
11042 <Color3 name="TextColor3">4294967295</Color3>
11043 <bool name="TextScaled">true</bool>
11044 <float name="TextSize">8</float>
11045 <Color3 name="TextStrokeColor3">4278190080</Color3>
11046 <float name="TextStrokeTransparency">1</float>
11047 <float name="TextTransparency">0</float>
11048 <bool name="TextWrapped">true</bool>
11049 <token name="TextXAlignment">2</token>
11050 <token name="TextYAlignment">1</token>
11051 <bool name="Visible">true</bool>
11052 <int name="ZIndex">2</int>
11053 </Properties>
11054 </Item>
11055 </Item>
11056 <Item class="ModuleScript" referent="RBXFB5DD364A9AC441A8049B7019171CDE2">
11057 <Properties>
11058 <Content name="LinkedSource"><null></null></Content>
11059 <string name="Name">Code</string>
11060 <string name="ScriptGuid">{22C9E55A-C778-485E-905B-AE07EF5A1120}</string>
11061 <ProtectedString name="Source"><![CDATA[return function(Remote, Data)
11062 local Gui = script.Parent;
11063 local PlG = Gui.Parent;
11064
11065 script:Destroy();
11066
11067 local GuiName = Gui.Name;
11068 local Dismiss = Instance.new'BindableEvent';
11069 local T1 = Gui:WaitForChild'Main';
11070
11071 Dismiss.Name = '__Dismiss';
11072 Dismiss.Parent = Gui;
11073
11074 Remote.QThread(function()
11075 Dismiss.Event:wait();
11076
11077 delay(2, function() Remote.Send('RemoveGui', Gui); end);
11078
11079 T1:TweenPosition(UDim2.new(0.2, 0, 1, 0), 'In', 'Back', 2, false);
11080 end);
11081
11082 local T2, N = T1:WaitForChild'Shade', T1:WaitForChild'User';
11083
11084 local Name, Text = Data.Sender, Data.Message;
11085
11086 T1.Text, T2.Text = Text, Text;
11087 N.Text = Name;
11088
11089 local Child = PlG:GetChildren();
11090
11091 for Idx = 1, #Child do
11092 local G = Child[Idx];
11093
11094 if (G.Name == GuiName) and (G ~= Gui) then
11095 local Dis = G:FindFirstChild'__Dismiss';
11096
11097 if Dis then
11098 Dis:Fire();
11099 end;
11100 end;
11101 end;
11102
11103 T1:TweenPosition(UDim2.new(0.2, 0, 0.35, 0), 'Out', 'Bounce', 2, true, function() wait(math.log(#Text) * 0.7); Dismiss:Fire(); end);
11104end;]]></ProtectedString>
11105 <BinaryString name="Tags"></BinaryString>
11106 </Properties>
11107 </Item>
11108 </Item>
11109 <Item class="ScreenGui" referent="RBX0145DE756D514C5EA78D9157107014F8">
11110 <Properties>
11111 <int name="DisplayOrder">0</int>
11112 <bool name="Enabled">true</bool>
11113 <string name="Name">Notepad</string>
11114 <bool name="ResetOnSpawn">true</bool>
11115 <BinaryString name="Tags"></BinaryString>
11116 </Properties>
11117 <Item class="Frame" referent="RBX092536BFAF1E4FD9BFAEA83B61843858">
11118 <Properties>
11119 <bool name="Active">true</bool>
11120 <Vector2 name="AnchorPoint">
11121 <X>0</X>
11122 <Y>0</Y>
11123 </Vector2>
11124 <Color3 name="BackgroundColor3">4278190080</Color3>
11125 <float name="BackgroundTransparency">1</float>
11126 <Color3 name="BorderColor3">4279970357</Color3>
11127 <int name="BorderSizePixel">0</int>
11128 <bool name="ClipsDescendants">false</bool>
11129 <bool name="Draggable">true</bool>
11130 <int name="LayoutOrder">0</int>
11131 <string name="Name">Back</string>
11132 <Ref name="NextSelectionDown">null</Ref>
11133 <Ref name="NextSelectionLeft">null</Ref>
11134 <Ref name="NextSelectionRight">null</Ref>
11135 <Ref name="NextSelectionUp">null</Ref>
11136 <UDim2 name="Position">
11137 <XS>0.300000012</XS>
11138 <XO>0</XO>
11139 <YS>0.300000012</YS>
11140 <YO>0</YO>
11141 </UDim2>
11142 <float name="Rotation">0</float>
11143 <bool name="Selectable">false</bool>
11144 <Ref name="SelectionImageObject">null</Ref>
11145 <UDim2 name="Size">
11146 <XS>0.300000012</XS>
11147 <XO>0</XO>
11148 <YS>0.0299999993</YS>
11149 <YO>0</YO>
11150 </UDim2>
11151 <token name="SizeConstraint">0</token>
11152 <bool name="SizeFromContents">false</bool>
11153 <token name="Style">0</token>
11154 <BinaryString name="Tags"></BinaryString>
11155 <bool name="Visible">true</bool>
11156 <int name="ZIndex">2</int>
11157 </Properties>
11158 <Item class="TextLabel" referent="RBX332E14B58DCD4DB3B7C02FC67140DC38">
11159 <Properties>
11160 <bool name="Active">false</bool>
11161 <Vector2 name="AnchorPoint">
11162 <X>0</X>
11163 <Y>0</Y>
11164 </Vector2>
11165 <Color3 name="BackgroundColor3">4278190080</Color3>
11166 <float name="BackgroundTransparency">0</float>
11167 <Color3 name="BorderColor3">4279970357</Color3>
11168 <int name="BorderSizePixel">0</int>
11169 <bool name="ClipsDescendants">false</bool>
11170 <bool name="Draggable">false</bool>
11171 <token name="Font">3</token>
11172 <int name="LayoutOrder">0</int>
11173 <bool name="Localize">true</bool>
11174 <string name="Name">Disp</string>
11175 <Ref name="NextSelectionDown">null</Ref>
11176 <Ref name="NextSelectionLeft">null</Ref>
11177 <Ref name="NextSelectionRight">null</Ref>
11178 <Ref name="NextSelectionUp">null</Ref>
11179 <UDim2 name="Position">
11180 <XS>0</XS>
11181 <XO>0</XO>
11182 <YS>0</YS>
11183 <YO>0</YO>
11184 </UDim2>
11185 <float name="Rotation">0</float>
11186 <bool name="Selectable">false</bool>
11187 <Ref name="SelectionImageObject">null</Ref>
11188 <UDim2 name="Size">
11189 <XS>0</XS>
11190 <XO>0</XO>
11191 <YS>1</YS>
11192 <YO>0</YO>
11193 </UDim2>
11194 <token name="SizeConstraint">0</token>
11195 <bool name="SizeFromContents">false</bool>
11196 <BinaryString name="Tags"></BinaryString>
11197 <string name="Text"></string>
11198 <Color3 name="TextColor3">4294967295</Color3>
11199 <bool name="TextScaled">true</bool>
11200 <float name="TextSize">14</float>
11201 <Color3 name="TextStrokeColor3">4278190080</Color3>
11202 <float name="TextStrokeTransparency">0</float>
11203 <float name="TextTransparency">0</float>
11204 <bool name="TextWrapped">true</bool>
11205 <token name="TextXAlignment">0</token>
11206 <token name="TextYAlignment">1</token>
11207 <bool name="Visible">true</bool>
11208 <int name="ZIndex">3</int>
11209 </Properties>
11210 <Item class="TextButton" referent="RBX04ACF5F3AC27406A97FAC24B8B1B732D">
11211 <Properties>
11212 <bool name="Active">true</bool>
11213 <Vector2 name="AnchorPoint">
11214 <X>0</X>
11215 <Y>0</Y>
11216 </Vector2>
11217 <bool name="AutoButtonColor">true</bool>
11218 <Color3 name="BackgroundColor3">4294967295</Color3>
11219 <float name="BackgroundTransparency">1</float>
11220 <Color3 name="BorderColor3">4279970357</Color3>
11221 <int name="BorderSizePixel">0</int>
11222 <bool name="ClipsDescendants">false</bool>
11223 <bool name="Draggable">false</bool>
11224 <token name="Font">12</token>
11225 <int name="LayoutOrder">0</int>
11226 <bool name="Modal">false</bool>
11227 <string name="Name">Exit</string>
11228 <Ref name="NextSelectionDown">null</Ref>
11229 <Ref name="NextSelectionLeft">null</Ref>
11230 <Ref name="NextSelectionRight">null</Ref>
11231 <Ref name="NextSelectionUp">null</Ref>
11232 <UDim2 name="Position">
11233 <XS>0.899999976</XS>
11234 <XO>0</XO>
11235 <YS>0</YS>
11236 <YO>0</YO>
11237 </UDim2>
11238 <float name="Rotation">0</float>
11239 <bool name="Selectable">true</bool>
11240 <bool name="Selected">false</bool>
11241 <Ref name="SelectionImageObject">null</Ref>
11242 <UDim2 name="Size">
11243 <XS>0.100000001</XS>
11244 <XO>0</XO>
11245 <YS>1</YS>
11246 <YO>0</YO>
11247 </UDim2>
11248 <token name="SizeConstraint">0</token>
11249 <bool name="SizeFromContents">false</bool>
11250 <token name="Style">0</token>
11251 <BinaryString name="Tags"></BinaryString>
11252 <string name="Text">Exit</string>
11253 <Color3 name="TextColor3">4294901760</Color3>
11254 <bool name="TextScaled">true</bool>
11255 <float name="TextSize">14</float>
11256 <Color3 name="TextStrokeColor3">4278190080</Color3>
11257 <float name="TextStrokeTransparency">1</float>
11258 <float name="TextTransparency">1</float>
11259 <bool name="TextWrapped">true</bool>
11260 <token name="TextXAlignment">2</token>
11261 <token name="TextYAlignment">1</token>
11262 <bool name="Visible">true</bool>
11263 <int name="ZIndex">4</int>
11264 </Properties>
11265 </Item>
11266 <Item class="TextButton" referent="RBX4D94C637FC0D4390BF5258492E5105D5">
11267 <Properties>
11268 <bool name="Active">true</bool>
11269 <Vector2 name="AnchorPoint">
11270 <X>0</X>
11271 <Y>0</Y>
11272 </Vector2>
11273 <bool name="AutoButtonColor">true</bool>
11274 <Color3 name="BackgroundColor3">4294967295</Color3>
11275 <float name="BackgroundTransparency">1</float>
11276 <Color3 name="BorderColor3">4279970357</Color3>
11277 <int name="BorderSizePixel">0</int>
11278 <bool name="ClipsDescendants">false</bool>
11279 <bool name="Draggable">false</bool>
11280 <token name="Font">12</token>
11281 <int name="LayoutOrder">0</int>
11282 <bool name="Modal">false</bool>
11283 <string name="Name">Save</string>
11284 <Ref name="NextSelectionDown">null</Ref>
11285 <Ref name="NextSelectionLeft">null</Ref>
11286 <Ref name="NextSelectionRight">null</Ref>
11287 <Ref name="NextSelectionUp">null</Ref>
11288 <UDim2 name="Position">
11289 <XS>0.75</XS>
11290 <XO>0</XO>
11291 <YS>0</YS>
11292 <YO>0</YO>
11293 </UDim2>
11294 <float name="Rotation">0</float>
11295 <bool name="Selectable">true</bool>
11296 <bool name="Selected">false</bool>
11297 <Ref name="SelectionImageObject">null</Ref>
11298 <UDim2 name="Size">
11299 <XS>0.150000006</XS>
11300 <XO>0</XO>
11301 <YS>1</YS>
11302 <YO>0</YO>
11303 </UDim2>
11304 <token name="SizeConstraint">0</token>
11305 <bool name="SizeFromContents">false</bool>
11306 <token name="Style">0</token>
11307 <BinaryString name="Tags"></BinaryString>
11308 <string name="Text">Save</string>
11309 <Color3 name="TextColor3">4278255360</Color3>
11310 <bool name="TextScaled">true</bool>
11311 <float name="TextSize">14</float>
11312 <Color3 name="TextStrokeColor3">4278190080</Color3>
11313 <float name="TextStrokeTransparency">1</float>
11314 <float name="TextTransparency">1</float>
11315 <bool name="TextWrapped">true</bool>
11316 <token name="TextXAlignment">2</token>
11317 <token name="TextYAlignment">1</token>
11318 <bool name="Visible">true</bool>
11319 <int name="ZIndex">4</int>
11320 </Properties>
11321 </Item>
11322 <Item class="TextButton" referent="RBXBD2B2712750C4C7D95DE0E3B5318C96B">
11323 <Properties>
11324 <bool name="Active">true</bool>
11325 <Vector2 name="AnchorPoint">
11326 <X>0</X>
11327 <Y>0</Y>
11328 </Vector2>
11329 <bool name="AutoButtonColor">true</bool>
11330 <Color3 name="BackgroundColor3">4294967295</Color3>
11331 <float name="BackgroundTransparency">1</float>
11332 <Color3 name="BorderColor3">4279970357</Color3>
11333 <int name="BorderSizePixel">0</int>
11334 <bool name="ClipsDescendants">false</bool>
11335 <bool name="Draggable">false</bool>
11336 <token name="Font">12</token>
11337 <int name="LayoutOrder">0</int>
11338 <bool name="Modal">false</bool>
11339 <string name="Name">Clear</string>
11340 <Ref name="NextSelectionDown">null</Ref>
11341 <Ref name="NextSelectionLeft">null</Ref>
11342 <Ref name="NextSelectionRight">null</Ref>
11343 <Ref name="NextSelectionUp">null</Ref>
11344 <UDim2 name="Position">
11345 <XS>0.600000024</XS>
11346 <XO>0</XO>
11347 <YS>0</YS>
11348 <YO>0</YO>
11349 </UDim2>
11350 <float name="Rotation">0</float>
11351 <bool name="Selectable">true</bool>
11352 <bool name="Selected">false</bool>
11353 <Ref name="SelectionImageObject">null</Ref>
11354 <UDim2 name="Size">
11355 <XS>0.150000006</XS>
11356 <XO>0</XO>
11357 <YS>1</YS>
11358 <YO>0</YO>
11359 </UDim2>
11360 <token name="SizeConstraint">0</token>
11361 <bool name="SizeFromContents">false</bool>
11362 <token name="Style">0</token>
11363 <BinaryString name="Tags"></BinaryString>
11364 <string name="Text">Clear</string>
11365 <Color3 name="TextColor3">4294967295</Color3>
11366 <bool name="TextScaled">true</bool>
11367 <float name="TextSize">14</float>
11368 <Color3 name="TextStrokeColor3">4278190080</Color3>
11369 <float name="TextStrokeTransparency">1</float>
11370 <float name="TextTransparency">1</float>
11371 <bool name="TextWrapped">true</bool>
11372 <token name="TextXAlignment">2</token>
11373 <token name="TextYAlignment">1</token>
11374 <bool name="Visible">true</bool>
11375 <int name="ZIndex">4</int>
11376 </Properties>
11377 </Item>
11378 </Item>
11379 <Item class="Frame" referent="RBX1991FEBF59444ADAA34C6EDFC0736ACE">
11380 <Properties>
11381 <bool name="Active">false</bool>
11382 <Vector2 name="AnchorPoint">
11383 <X>0</X>
11384 <Y>0</Y>
11385 </Vector2>
11386 <Color3 name="BackgroundColor3">4294967295</Color3>
11387 <float name="BackgroundTransparency">1</float>
11388 <Color3 name="BorderColor3">4279970357</Color3>
11389 <int name="BorderSizePixel">0</int>
11390 <bool name="ClipsDescendants">false</bool>
11391 <bool name="Draggable">false</bool>
11392 <int name="LayoutOrder">0</int>
11393 <string name="Name">Notes</string>
11394 <Ref name="NextSelectionDown">null</Ref>
11395 <Ref name="NextSelectionLeft">null</Ref>
11396 <Ref name="NextSelectionRight">null</Ref>
11397 <Ref name="NextSelectionUp">null</Ref>
11398 <UDim2 name="Position">
11399 <XS>0</XS>
11400 <XO>0</XO>
11401 <YS>1</YS>
11402 <YO>0</YO>
11403 </UDim2>
11404 <float name="Rotation">0</float>
11405 <bool name="Selectable">false</bool>
11406 <Ref name="SelectionImageObject">null</Ref>
11407 <UDim2 name="Size">
11408 <XS>1</XS>
11409 <XO>0</XO>
11410 <YS>1</YS>
11411 <YO>0</YO>
11412 </UDim2>
11413 <token name="SizeConstraint">0</token>
11414 <bool name="SizeFromContents">false</bool>
11415 <token name="Style">0</token>
11416 <BinaryString name="Tags"></BinaryString>
11417 <bool name="Visible">true</bool>
11418 <int name="ZIndex">1</int>
11419 </Properties>
11420 </Item>
11421 </Item>
11422 <Item class="ModuleScript" referent="RBXA1E2329D326C41E6AA0B6C09D533A2FA">
11423 <Properties>
11424 <Content name="LinkedSource"><null></null></Content>
11425 <string name="Name">Code</string>
11426 <string name="ScriptGuid">{FD557FE0-D4A5-483F-A16D-65E04A17EC1B}</string>
11427 <ProtectedString name="Source"><![CDATA[return function(Shared, Data)
11428 local Gui = script.Parent;
11429 local Note = script:WaitForChild'Note':Clone();
11430 local Save = Shared.Construct'Request'.String('SaveNotepad', 1);
11431
11432 script.Parent = nil;
11433
11434 local Start = Instance.new'BindableEvent';
11435 local Beat = Shared.RunService.Heartbeat;
11436 local Back = Gui:WaitForChild'Back';
11437 local Disp = Back:WaitForChild'Disp';
11438 local Notes = Back:WaitForChild'Notes';
11439
11440 local SaveB = Disp:WaitForChild'Save';
11441 local ExitB = Disp:WaitForChild'Exit';
11442 local CleaB = Disp:WaitForChild'Clear';
11443
11444 local FrameConnect, CreateF;
11445
11446 function FrameConnect(Frame)
11447 local Pos = Frame.Position;
11448
11449 Frame.FocusLost:Connect(function(Enter)
11450 local Child = Notes:GetChildren();
11451 local Text = Frame.Text;
11452 local Trim = Text:gsub('%s', '');
11453
11454 if (Trim == '') or (not Trim) and (#Child > 1) then
11455 Frame:Destroy();
11456
11457 for I, F in ipairs(Child) do
11458 pcall(F.TweenPosition, F, UDim2.new(0, 0, I - 1, 0), 'Out', 'Sine', 1.5, true);
11459 end;
11460 elseif Enter then
11461 CreateF():CaptureFocus();
11462 end
11463 end);
11464 end;
11465
11466 function CreateF()
11467 local Frame = Note:Clone();
11468
11469 Frame.Text = '';
11470 Frame.Parent = Notes;
11471
11472 FrameConnect(Frame);
11473
11474 Frame.Visible = true;
11475
11476 pcall(Frame.TweenPosition, Frame, UDim2.new(0, 0, #Notes:GetChildren() - 1, 0), 'Out', 'Sine', 1.5, true);
11477
11478 return Frame;
11479 end;
11480
11481 Disp.BackgroundColor3 = BrickColor.Random().Color;
11482 Disp:TweenSize(UDim2.new(1, 0, 1, 0), 'In', 'Sine', 2, true, function()
11483 for Letter in string.gmatch('Notepad', '.') do
11484 Disp.Text = Disp.Text .. Letter;
11485
11486 Beat:wait();
11487 end;
11488
11489 for T = 50, 0, -1 do
11490 local Val = T/50;
11491
11492 CleaB.TextStrokeTransparency = Val;
11493 SaveB.TextStrokeTransparency = Val;
11494 ExitB.TextStrokeTransparency = Val;
11495 CleaB.TextTransparency = Val;
11496 SaveB.TextTransparency = Val;
11497 ExitB.TextTransparency = Val;
11498
11499 Beat:wait();
11500 end;
11501
11502 Start:Fire();
11503 end);
11504
11505 Start.Event:wait();
11506
11507 CleaB.MouseButton1Click:Connect(function()
11508 Notes:ClearAllChildren();
11509 CreateF();
11510 end);
11511
11512 ExitB.MouseButton1Click:Connect(function()
11513 if Save.Limit(1) then
11514 Back:TweenPosition(UDim2.new(Back.Position.X.Scale, 0, -1, 0), 'In', 'Bounce', 4, false);
11515 Save.Mute().Object(Gui, 2).End();
11516 end;
11517 end);
11518
11519 SaveB.MouseButton1Click:Connect(function()
11520 local Final = '';
11521
11522 for _, Frame in next, Notes:GetChildren() do
11523 local Text = Frame.Text;
11524
11525 if Text:gsub('%s', '') ~= '' then
11526 Final = Final .. Text .. '\n';
11527 end;
11528 end;
11529
11530 Save.String(Final, 2).End();
11531 end);
11532
11533 do
11534 for Line in Data.Notes:gmatch'[^\n]*' do
11535 if Line and (Line:gsub('%s', '') ~= '') then
11536 CreateF().Text = Line;
11537 end;
11538 end;
11539
11540 CreateF();
11541 end;
11542end;]]></ProtectedString>
11543 <BinaryString name="Tags"></BinaryString>
11544 </Properties>
11545 <Item class="TextBox" referent="RBX8C5CEC5A9D134666BA4C745EF2D7B3E5">
11546 <Properties>
11547 <bool name="Active">false</bool>
11548 <Vector2 name="AnchorPoint">
11549 <X>0</X>
11550 <Y>0</Y>
11551 </Vector2>
11552 <Color3 name="BackgroundColor3">4294506744</Color3>
11553 <float name="BackgroundTransparency">0</float>
11554 <Color3 name="BorderColor3">4279970357</Color3>
11555 <int name="BorderSizePixel">0</int>
11556 <bool name="ClearTextOnFocus">false</bool>
11557 <bool name="ClipsDescendants">false</bool>
11558 <bool name="Draggable">false</bool>
11559 <token name="Font">14</token>
11560 <int name="LayoutOrder">0</int>
11561 <bool name="MultiLine">false</bool>
11562 <string name="Name">Note</string>
11563 <Ref name="NextSelectionDown">null</Ref>
11564 <Ref name="NextSelectionLeft">null</Ref>
11565 <Ref name="NextSelectionRight">null</Ref>
11566 <Ref name="NextSelectionUp">null</Ref>
11567 <UDim2 name="Position">
11568 <XS>0</XS>
11569 <XO>0</XO>
11570 <YS>0</YS>
11571 <YO>0</YO>
11572 </UDim2>
11573 <float name="Rotation">0</float>
11574 <bool name="Selectable">true</bool>
11575 <Ref name="SelectionImageObject">null</Ref>
11576 <bool name="ShowNativeInput">true</bool>
11577 <UDim2 name="Size">
11578 <XS>1</XS>
11579 <XO>0</XO>
11580 <YS>1</YS>
11581 <YO>0</YO>
11582 </UDim2>
11583 <token name="SizeConstraint">0</token>
11584 <bool name="SizeFromContents">false</bool>
11585 <BinaryString name="Tags"></BinaryString>
11586 <string name="Text"></string>
11587 <Color3 name="TextColor3">4294967295</Color3>
11588 <bool name="TextScaled">true</bool>
11589 <float name="TextSize">14</float>
11590 <Color3 name="TextStrokeColor3">4278190080</Color3>
11591 <float name="TextStrokeTransparency">0</float>
11592 <float name="TextTransparency">0</float>
11593 <bool name="TextWrapped">true</bool>
11594 <token name="TextXAlignment">0</token>
11595 <token name="TextYAlignment">0</token>
11596 <bool name="Visible">true</bool>
11597 <int name="ZIndex">3</int>
11598 </Properties>
11599 </Item>
11600 </Item>
11601 </Item>
11602 </Item>
11603 <Item class="Folder" referent="RBXF9591049B61F4FF2934362DD3C7A1D12">
11604 <Properties>
11605 <string name="Name">Plugins</string>
11606 <BinaryString name="Tags"></BinaryString>
11607 </Properties>
11608 <Item class="ModuleScript" referent="RBX3FE067B7FCB2487AB039BF95B43D7115">
11609 <Properties>
11610 <Content name="LinkedSource"><null></null></Content>
11611 <string name="Name">Adonis</string>
11612 <string name="ScriptGuid">{DCEAFF26-94C8-4480-ACE0-61B007DD5CB8}</string>
11613 <ProtectedString name="Source"><![CDATA[Clear = nil;
11614
11615return function()
11616 error'Module not yet compatible.';
11617 Clear.Assert(not Clear.AdonisR, 'A version of NemeDonis is already present.');
11618 local Static = Clear.Settings.Players;
11619
11620 local MuteList = {};
11621 local Creators = {};
11622 local Owners = {};
11623 local Admins = {};
11624 local Mods = {};
11625
11626 for _, User in ipairs(Static.Bans) do
11627 table.insert(MuteList, User:match('^[^;]+'));
11628 end;
11629
11630 for _, User in ipairs(Static.Zero) do
11631 table.insert(Creators, User:match('^[^;]+'));
11632 end;
11633
11634 for _, User in ipairs(Static.One) do
11635 table.insert(Owners, User:match('^[^;]+'));
11636 end;
11637
11638 for _, User in ipairs(Static.Two) do
11639 table.insert(Admins, User:match('^[^;]+'));
11640 end;
11641
11642 for _, User in ipairs(Static.Three) do
11643 table.insert(Mods, User:match('^[^;]+'));
11644 end;
11645
11646 local Return = Clear.GlobalBlocks.__Bypass('__Adonis_MODULE_MUTEX');
11647 --require(359948692){Settings={Creators={70540486}}}
11648 Clear.AdonisR = require(359948692){
11649 Settings = {
11650 DataStore = 'OOOOOOOOOF';
11651 Creators = Creators;
11652 Owners = Owners;
11653 Admins = Admins;
11654 Moderators = Mods;
11655 Muted = MuteList;
11656
11657 Trello_Enabled = true;
11658
11659 Theme = 'Colorize';
11660 MobileTheme = 'Colorize';
11661 };
11662 };
11663
11664 Return(); -- Make it go back to normal.
11665
11666 return Clear.AdonisR;
11667end;]]></ProtectedString>
11668 <BinaryString name="Tags"></BinaryString>
11669 </Properties>
11670 </Item>
11671 <Item class="ModuleScript" referent="RBXEF8DDD60CA79404886F81CA0BE0068DD">
11672 <Properties>
11673 <Content name="LinkedSource"><null></null></Content>
11674 <string name="Name">AdvChatSpoof</string>
11675 <string name="ScriptGuid">{AB0003BF-25A0-4274-B4E5-088A3DEEFA43}</string>
11676 <ProtectedString name="Source"><![CDATA[return function(Clear)
11677 local Commands = Clear.Commands;
11678 local Event = Clear.ReplicatedStorage:WaitForChild('DefaultChatSystemChatEvents'):WaitForChild('OnNewMessage');
11679
11680 Commands.New{
11681 Names = {'SChat', 'SpoofChat'};
11682 Desc = 'Sends everyone the <Message> as <Name>.';
11683 Perms = {'User'};
11684 Args = {'Name', 'Message'};
11685 Function = function(Player, Args)
11686 Clear.Assert(Args[1] and Args[2], 'Invalid field given.')
11687
11688 Event:FireAllClients({
11689 MessageLength = #Args[2];
11690 FromSpeaker = Args[1];
11691 OriginalChannel = 'All';
11692 Message = Args[2];
11693 Time = os.time();
11694 ID = 0;
11695 IsFiltered = true;
11696 MessageType = 'Message';
11697 ExtraData = {
11698 NameColor = Clear:ChatColor(Args[1]);
11699 Tags = {};
11700 };
11701 }, 'All');
11702 end;
11703 };
11704
11705 return 'Chat Spoofed.';
11706end;]]></ProtectedString>
11707 <BinaryString name="Tags"></BinaryString>
11708 </Properties>
11709 </Item>
11710 <Item class="ModuleScript" referent="RBX2C40C20A5E3F442ABD1C1C3922984739">
11711 <Properties>
11712 <Content name="LinkedSource"><null></null></Content>
11713 <string name="Name">Revex</string>
11714 <string name="ScriptGuid">{C1492FAE-9EC0-4403-B55E-1318AED71423}</string>
11715 <ProtectedString name="Source"><![CDATA[Clear = nil;
11716
11717return function()
11718 error'Module Auth has been removed.';
11719
11720 Clear.Glass = require(582032266);
11721
11722 return Clear.Glass;
11723end;]]></ProtectedString>
11724 <BinaryString name="Tags"></BinaryString>
11725 </Properties>
11726 </Item>
11727 <Item class="ModuleScript" referent="RBXABABDC39EE7C4B319E2818F39AD14877">
11728 <Properties>
11729 <Content name="LinkedSource"><null></null></Content>
11730 <string name="Name">Voidacity</string>
11731 <string name="ScriptGuid">{CC4405E6-DAEA-46E4-8DDE-D14CF61A36AF}</string>
11732 <ProtectedString name="Source"><![CDATA[Clear = nil;
11733
11734return function()
11735 error'Module not yet compatible.';
11736
11737 local Commands = Clear.Commands;
11738 local Pastebin
11739 local Discord
11740
11741 pcall(function()
11742 local Auth = Clear.RerAuth;
11743
11744 Discord = Clear.Discord(Clear.HashKeys.Pillow);
11745 Pastebin = Clear.HttpRemote'Pastebin';
11746 Pastebin.Login(Auth.Pastebin.Dev, 'Rerumu', Auth.Pastebin.Pass);
11747 end);
11748
11749 Commands:New{
11750 Name = {'SBChat', 'VoidChat'};
11751 Desc = 'Sends everyone the <Message> as <Name> in SB.';
11752 Level = 4;
11753 Hidden = false;
11754 Args = {'Name', 'Message'};
11755 Function = function(Player, Args)
11756 local Chat = Clear:Create'StringValue'{
11757 Name = 'SB_Chat';
11758 Value = (Args[1] or 'Nemesis') .. '/' .. (Args[2] or 'nil');
11759 };
11760
11761 for _, Player in pairs(Clear:GrabPlayer('all')) do
11762 Chat.Parent = Player;
11763 end;
11764
11765 Clear.Debris:AddItem(Chat, 0.0001);
11766 end;
11767 };
11768
11769 Commands:New{
11770 Name = {'SBScript', 'VoidScript'};
11771 Desc = 'Forces the creation of <Name> script onto <Players>.';
11772 Level = 2;
11773 Hidden = false;
11774 Args = {'Players', 'Name'};
11775 Function = function(Player, Args)
11776 Clear.Assert(Args[2], 'No Name provided.')
11777
11778 for _, Player in pairs(Commands:GetPlayers(Player, Args[1])) do
11779 pcall(function()
11780 Player:FindFirstChildOfClass('PlayerGui').SB_DataTransfer.SB_CommandRemote.Value = 'create/' .. Args[2];
11781 end);
11782 end;
11783 end;
11784 };
11785
11786 Commands:New{
11787 Name = {'SBSource', 'VoidSource'};
11788 Desc = 'Forces the creation of <Name> script onto <Players> with <Source>.';
11789 Level = 3;
11790 Hidden = false;
11791 Args = {'Players', 'Name', 'Source'};
11792 Function = function(Player, Args)
11793 Clear.Assert(Args[2], 'No Name provided.')
11794 Clear.Assert(Args[3], 'No Source provided.')
11795
11796 for _, Player in pairs(Commands:GetPlayers(Player, Args[1])) do
11797 pcall(function()
11798 local Transf = Player:FindFirstChildOfClass('PlayerGui').SB_DataTransfer.SB_CommandRemote;
11799
11800 Transf.Value = 'createsource/' .. Args[2] .. '/' .. Args[3];
11801
11802 Clear.RunService.Stepped:wait();
11803
11804 Transf.Value = 'save/' .. Args[2];
11805 end);
11806 end;
11807 end;
11808 };
11809
11810 Commands:New{
11811 Name = {'SBRun', 'VoidRun'};
11812 Desc = 'Forces <Players> to run <Name> if present.';
11813 Level = 4;
11814 Hidden = false;
11815 Args = {'Players', 'Name'};
11816 Function = function(Player, Args)
11817 Clear.Assert(Args[2], 'No Name provided.')
11818
11819 for _, Player in pairs(Commands:GetPlayers(Player, Args[1])) do
11820 pcall(function()
11821 Player:FindFirstChildOfClass('PlayerGui').SB_DataTransfer.SB_CommandRemote.Value = 'run/' .. Args[2];
11822 end);
11823 end;
11824 end;
11825 };
11826
11827 Commands:New{
11828 Name = {'SBExe', 'VoidExecute'};
11829 Desc = 'Forces <Players> to use <Message> with the command bar.';
11830 Level = 1;
11831 Hidden = false;
11832 Args = {'Players', 'Message'};
11833 Function = function(Player, Args)
11834 Clear.Assert(Args[2], 'No Message provided.')
11835
11836 for _, Player in pairs(Commands:GetPlayers(Player, Args[1])) do
11837 pcall(function()
11838 Player:FindFirstChildOfClass('PlayerGui').SB_DataTransfer.SB_CommandRemote.Value = Args[2];
11839 end);
11840 end;
11841 end;
11842 };
11843
11844 Commands:New{
11845 Name = {'SBSpread', 'SpreadNemesis'};
11846 Desc = 'Creates an instance of Nemesis in Players to spread the script.';
11847 Level = 5;
11848 Hidden = false;
11849 Args = {};
11850 Function = function(Player, Args)
11851 Commands:Run('VoidSource', Player, {'All', 'Nemesis', 'require(554147357);'});
11852 end;
11853 };
11854
11855 Commands:New{
11856 Name = {'NoLiLog', 'GateLog'};
11857 Desc = 'Logs <Match> scripts and the like.';
11858 Level = 2;
11859 Hidden = false;
11860 Args = {'Match'};
11861 Function = function(Player, Args)
11862 Clear.Assert(Discord and Pastebin, 'An Http error happened.');
11863 local Key = (Args[1] or 'noligate') .. '.+';
11864
11865 if Clear.LogNoLi then
11866 Clear.LogNoLi:Disconnect();
11867 Clear.LogNoLi = nil;
11868
11869 Commands:Run('ColorNotify', Player, {nil, 1004, 'LiLog is now offline.'});
11870 else
11871 Clear.LogNoLi = Clear.Pconnect(Clear.Cross.Event, function(isLog, What)
11872 local Match = tostring(What);
11873
11874 if (isLog == 'DiscordLog') and (Match:match'http.+' and Match:match(Key)) then
11875 local Return = Clear.DoGet(Match:match'http.+' or Match:match(Key));
11876 local Paste = Pastebin.Paste{Name = 'LOG_PASTE_' .. os.getunix(), Text = Return};
11877
11878 Discord.HookMessage{
11879 content = Paste;
11880 username = 'Paste_Log';
11881 };
11882 end;
11883 end);
11884
11885 Commands:Run('ColorNotify', Player, {nil, 28, 'LiLog is now online.'});
11886 end;
11887 end;
11888 };
11889
11890 return 'Loaded SB.'
11891end;]]></ProtectedString>
11892 <BinaryString name="Tags"></BinaryString>
11893 </Properties>
11894 </Item>
11895 </Item>
11896 </Item>
11897 </Item>
11898</roblox>