diff options
Diffstat (limited to 'ClientHamr/GuiLua/skang.lua')
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ClientHamr/GuiLua/skang.lua b/ClientHamr/GuiLua/skang.lua index b8e418b..e89de8e 100644 --- a/ClientHamr/GuiLua/skang.lua +++ b/ClientHamr/GuiLua/skang.lua | |||
@@ -212,6 +212,26 @@ Other Thing things are - | |||
212 | Actually, not sure matrix-RAD solved that either. lol | 212 | Actually, not sure matrix-RAD solved that either. lol |
213 | ]] | 213 | ]] |
214 | 214 | ||
215 | --[[ ideas | ||
216 | use a Lua pattern instead of a mask, with ^ and $ automatically added at the ends. | ||
217 | __newindex could catch a table being assigned - test.foo = {widget = '...', acl='...'} | ||
218 | though that interferes with using tables for Stuff | ||
219 | test.someStuff = {key='blah', field0='something', field1=1, ...} | ||
220 | test.someStuff.key | ||
221 | happily Lua function call syntax supports test.foo{ ... } as a function call with a table argument. B-) | ||
222 | so maybe a use for __call after all, if the argument is that table | ||
223 | the table itself is passed to __call as the first argument, the rest of the arguments follow. | ||
224 | test.foo(1, 'two') -> __call(foo, 1, 'two') | ||
225 | foo has to be a table value though, with a metatable | ||
226 | and the rest of skang is treating test.foo as a nil value so that __index and __newindex work. B-( | ||
227 | test itself is a table, so all is not lost - | ||
228 | test{'foo', widget='...', acl='..'} -> __call(test, {'foo', ...}) | ||
229 | which would assign stuff to skang.things.foo.widget and skang.things.foo.acl | ||
230 | as opposed to - | ||
231 | skang.things.foo = {widget='...', acl='...'} | ||
232 | which blanks out the other stuff. | ||
233 | ]] | ||
234 | |||
215 | -- Default things values. | 235 | -- Default things values. |
216 | Thing.help = 'No description supplied.' | 236 | Thing.help = 'No description supplied.' |
217 | Thing.types = {'string'} | 237 | Thing.types = {'string'} |
@@ -221,6 +241,7 @@ Thing.required = false | |||
221 | 241 | ||
222 | Thing.action = 'nada' -- An optional action to perform. | 242 | Thing.action = 'nada' -- An optional action to perform. |
223 | Thing.tell = '' -- The skang command that created this Thing. | 243 | Thing.tell = '' -- The skang command that created this Thing. |
244 | Thing.pattern = '.*' -- A pattern to restrict values. | ||
224 | 245 | ||
225 | Thing.isReadOnly = false -- Is this Thing read only? | 246 | Thing.isReadOnly = false -- Is this Thing read only? |
226 | Thing.isServer = false -- Is this Thing server side? | 247 | Thing.isServer = false -- Is this Thing server side? |
@@ -256,6 +277,7 @@ Thing.__index = function (table, key) | |||
256 | -- First see if this is a Thing. | 277 | -- First see if this is a Thing. |
257 | -- TODO - Java skang called isValid() on get(). On the other hand, doesn't seem to call it on set(), but calls it on append(). | 278 | -- TODO - Java skang called isValid() on get(). On the other hand, doesn't seem to call it on set(), but calls it on append(). |
258 | -- Ah, it was doing isValid() on setStufflet(). | 279 | -- Ah, it was doing isValid() on setStufflet(). |
280 | -- TODO - Call thing.func() if it exists. | ||
259 | if thing then return thing.value or thing.default end | 281 | if thing then return thing.value or thing.default end |
260 | 282 | ||
261 | -- Then see if we can inherit it from Thing. | 283 | -- Then see if we can inherit it from Thing. |
@@ -322,6 +344,7 @@ thing = function (names, help, default, types, widget, required, acl, boss) | |||
322 | n[i] = v | 344 | n[i] = v |
323 | i = i + 1 | 345 | i = i + 1 |
324 | end | 346 | end |
347 | -- TODO - Should bitch and return if no names, has to be at least one name. | ||
325 | local name = n[1] | 348 | local name = n[1] |
326 | 349 | ||
327 | -- Find type, default to string, then break out the other types. | 350 | -- Find type, default to string, then break out the other types. |