diff options
author | David Walter Seikel | 2014-03-27 00:03:34 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-03-27 00:03:34 +1000 |
commit | 1342d5655da85c87c3ff1d5441ffd5117effc07f (patch) | |
tree | cf1682052baac6f4bea421ebb5cad4f81a22a59a | |
parent | Small tweaks to skang.thing() types parsing. (diff) | |
download | SledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.zip SledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.tar.gz SledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.tar.bz2 SledjHamr-1342d5655da85c87c3ff1d5441ffd5117effc07f.tar.xz |
More notes, TODO, and default Thing pattern.
Diffstat (limited to '')
-rw-r--r-- | ClientHamr/GuiLua/GuiLua.c | 6 | ||||
-rw-r--r-- | ClientHamr/GuiLua/skang.lua | 23 |
2 files changed, 29 insertions, 0 deletions
diff --git a/ClientHamr/GuiLua/GuiLua.c b/ClientHamr/GuiLua/GuiLua.c index 87766b0..3588ea0 100644 --- a/ClientHamr/GuiLua/GuiLua.c +++ b/ClientHamr/GuiLua/GuiLua.c | |||
@@ -172,6 +172,12 @@ of telling if the number is pixels or character cells. Also, relative | |||
172 | to what part of the other widget? Some more thought needs to be put | 172 | to what part of the other widget? Some more thought needs to be put |
173 | into this. | 173 | into this. |
174 | 174 | ||
175 | Another idea for relative numbers could be to have a coord object with | ||
176 | various methods, so we could have something like - | ||
177 | |||
178 | widget:bottom(-10):right(5) -- 10 pixels below the bottom of widget, 5 pixels to the right of the right edge of widget. | ||
179 | widget:width("12") -- 12 characters longer than the width of widget. | ||
180 | |||
175 | */ | 181 | */ |
176 | 182 | ||
177 | 183 | ||
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. |