diff options
Diffstat (limited to '')
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index 75df4b5..d54a63f 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -610,33 +610,44 @@ copy = function (module, name) | |||
610 | end | 610 | end |
611 | 611 | ||
612 | 612 | ||
613 | -- TODO - These deal with te Thing stuff, not the values, so might need to change the names. | ||
614 | -- Or have them do both? | ||
615 | get = function (stuff, key, name) | 613 | get = function (stuff, key, name) |
616 | local result | 614 | local result |
617 | local thing = getmetatable(stuff) | 615 | if name then |
618 | if thing then | 616 | local thing = getmetatable(stuff) |
619 | local this = thing.__stuff[key] | 617 | if thing then |
620 | if this then result = this[name] end | 618 | local this = thing.__stuff[key] |
619 | if this then result = this[name] end | ||
620 | end | ||
621 | else | ||
622 | result = stuff[key] | ||
621 | end | 623 | end |
622 | return result | 624 | return result |
623 | end | 625 | end |
624 | 626 | ||
625 | 627 | ||
626 | reset = function (stuff, key, name) | 628 | reset = function (stuff, key, name) |
627 | local thing = getmetatable(stuff) | 629 | if name then |
628 | if thing then | 630 | local thing = getmetatable(stuff) |
629 | local this = thing.__stuff[key] | 631 | if thing then |
630 | if this then this[name] = nil end | 632 | local this = thing.__stuff[key] |
633 | if this then this[name] = nil end | ||
634 | end | ||
635 | else | ||
636 | stuff[key] = nil | ||
631 | end | 637 | end |
632 | end | 638 | end |
633 | 639 | ||
634 | 640 | ||
635 | set = function (stuff, key, name, value) | 641 | set = function (stuff, key, name, value) |
636 | local thing = getmetatable(stuff) | 642 | if value then |
637 | if thing then | 643 | local thing = getmetatable(stuff) |
638 | local this = thing.__stuff[key] | 644 | if thing then |
639 | if this then this[name] = value end | 645 | local this = thing.__stuff[key] |
646 | if this then this[name] = value end | ||
647 | end | ||
648 | else | ||
649 | -- In this case, value isn't there, so we are reusing the third argument as the value. | ||
650 | stuff[key] = name | ||
640 | end | 651 | end |
641 | end | 652 | end |
642 | 653 | ||
@@ -656,6 +667,12 @@ end | |||
656 | quit = function () | 667 | quit = function () |
657 | end | 668 | end |
658 | 669 | ||
670 | |||
671 | -- Create our Things here. | ||
672 | -- TODO - For some odd reason, these first three fuck up thing() if we create them before the above stubs. | ||
673 | thing('get', 'Get the current value of an existing Thing or metadata.', get, 'thing,key,name') | ||
674 | thing('reset', 'Reset the current value of an existing Thing or metadata.', reset, 'thing,key,name') | ||
675 | thing('set', 'Set the current value of an existing Thing or metadata.', set, 'thing,key,name,data') | ||
659 | thing('nada', 'Do nothing.', nada) | 676 | thing('nada', 'Do nothing.', nada) |
660 | thing('clear', 'The current skin is cleared of all widgets.', clear) | 677 | thing('clear', 'The current skin is cleared of all widgets.', clear) |
661 | thing('window', 'The size and title of the application Frame.', window, 'x,y,name', nil, nil, 'GGG') | 678 | thing('window', 'The size and title of the application Frame.', window, 'x,y,name', nil, nil, 'GGG') |
@@ -704,17 +721,17 @@ end | |||
704 | {"servlet", "doIfServlet", "action", "Only do this if we are a servlet.", "", ""}, | 721 | {"servlet", "doIfServlet", "action", "Only do this if we are a servlet.", "", ""}, |
705 | {"do", "doThing", "action", "Do this action.", "", ""}, | 722 | {"do", "doThing", "action", "Do this action.", "", ""}, |
706 | {"grab", "getFile", "URL", "Grab a file from a URL.", "", ""}, | 723 | {"grab", "getFile", "URL", "Grab a file from a URL.", "", ""}, |
707 | {"get", "getThing", "name", "Get the current value of an existing thing.", "", ""}, | 724 | -- {"get", "getThing", "name", "Get the current value of an existing thing.", "", ""}, |
708 | {"gimmeskin", "gimmeSkin", "", "Returns the modules default skin.", "", ""}, | 725 | {"gimmeskin", "gimmeSkin", "", "Returns the modules default skin.", "", ""}, |
709 | {"help", "helpThing", "file", "Show help page.", "", ""}, | 726 | {"help", "helpThing", "file", "Show help page.", "", ""}, |
710 | {"nada", "nothing", "data", "Does nothing B-).", "", ""}, | 727 | -- {"nada", "nothing", "data", "Does nothing B-).", "", ""}, |
711 | {"postshow", "postShowThings", "URL,name", "POST the values of all Things to the URL, show the returned content.", "", ""}, | 728 | {"postshow", "postShowThings", "URL,name", "POST the values of all Things to the URL, show the returned content.", "", ""}, |
712 | {"post", "postThings", "URL", "POST the values of all Things to the URL, return the content.", "", ""}, | 729 | {"post", "postThings", "URL", "POST the values of all Things to the URL, return the content.", "", ""}, |
713 | {"postparse", "postParseThings", "URL", "POST the values of all Things to the URL, parse the returned content.", "", ""}, | 730 | {"postparse", "postParseThings", "URL", "POST the values of all Things to the URL, parse the returned content.", "", ""}, |
714 | {"quiet", "quiet", "", "Output errors and warnings only.", "", ""}, | 731 | {"quiet", "quiet", "", "Output errors and warnings only.", "", ""}, |
715 | {"remove", "removeThing", "name", "Remove an existing thing.", "", ""}, | 732 | {"remove", "removeThing", "name", "Remove an existing thing.", "", ""}, |
716 | {"sethelp", "setHelp", "name,data", "Change the help for something.", "", ""}, | 733 | {"sethelp", "setHelp", "name,data", "Change the help for something.", "", ""}, |
717 | {"set", "setThing", "name,data", "Set the current value of an existing Thing.", "", ""}, | 734 | -- {"set", "setThing", "name,data", "Set the current value of an existing Thing.", "", ""}, |
718 | -- {"skang", "skangRead", "URL", "Parse the contents of a skang file or URL.", "", ""}, | 735 | -- {"skang", "skangRead", "URL", "Parse the contents of a skang file or URL.", "", ""}, |
719 | -- {"quit", "startQuit", "", "Quit, exit, remove thyself.", "", ""}, | 736 | -- {"quit", "startQuit", "", "Quit, exit, remove thyself.", "", ""}, |
720 | {"stopwhinging", "stopWhinging", "", "Clear all messages.", "", ""}, | 737 | {"stopwhinging", "stopWhinging", "", "Clear all messages.", "", ""}, |