| Author |
Message |
Topic: for k, v in pairs (tbl) do |
lhf
Replies: 1
Views: 400
|
Forum: Language Posted: Mon Dec 21, 2009 6:41 pm Subject: for k, v in pairs (tbl) do |
| Use lua_next. |
Topic: string format %x of negative number |
lhf
Replies: 2
Views: 487
|
Forum: Language Posted: Sat Dec 12, 2009 7:27 pm Subject: string format %x of negative number |
Under Linux and Mac OS X, I get
-100, -100, 4294967196, ffffff9c, FFFFFF9C
Anyway, %u, %x, %X only handles unsigned numbers. |
Topic: How to get list of functions available? |
lhf
Replies: 2
Views: 524
|
Forum: Language Posted: Fri Dec 04, 2009 7:04 pm Subject: How to get list of functions available? |
| Try the globals script in the Lua demo: http://www.lua.org/demo.html |
Topic: [C/C++] use some script without reloading again and again |
lhf
Replies: 3
Views: 591
|
Forum: Integration Posted: Fri Dec 04, 2009 7:32 am Subject: [C/C++] use some script without reloading again and again |
| Use the registry or any other table to cache the script functions. So when you want to run a script, first test whether there's a function store at the key given by the script name. If there isn't, lu ... |
Topic: [C/C++] use some script without reloading again and again |
lhf
Replies: 3
Views: 591
|
Forum: Integration Posted: Fri Dec 04, 2009 4:23 am Subject: [C/C++] use some script without reloading again and again |
luaL_loadstring returns a function corresponding to the body of the script.
luaL_loadstring does not run the script.
So, simply save the function left on the stack by luaL_loadstring and run it as m ... |
Topic: Lua in C++ without exception |
lhf
Replies: 3
Views: 586
|
Forum: Integration Posted: Wed Dec 02, 2009 3:57 am Subject: Lua in C++ without exception |
| Since Lua can be built both as C and C++, there's mechanism one for C (via longjmp) and one for C++ (via exceptions). |
Topic: Lua in C++ without exception |
lhf
Replies: 3
Views: 586
|
Forum: Integration Posted: Tue Dec 01, 2009 7:25 pm Subject: Lua in C++ without exception |
| Either build Lua as C or change luaconf.h to use longjm even for C++. |
Topic: Implementing a Lua timeout in the runtime? |
lhf
Replies: 1
Views: 549
|
Forum: Integration Posted: Sat Nov 14, 2009 7:20 am Subject: Implementing a Lua timeout in the runtime? |
| Set a count hook for a large count and raise an error inside the hook. |
Topic: how to catch error in coroutine function. |
lhf
Replies: 2
Views: 589
|
Forum: Language Posted: Wed Oct 21, 2009 5:33 am Subject: how to catch error in coroutine function. |
| Try this:print(coroutine.resume(co)) |
Topic: Table length |
lhf
Replies: 3
Views: 496
|
Forum: Language Posted: Thu Oct 15, 2009 10:22 am Subject: Table length |
| There is no other way. Again, why do you need it? |
Topic: Table length |
lhf
Replies: 3
Views: 496
|
Forum: Language Posted: Thu Oct 15, 2009 5:23 am Subject: Table length |
| This number is not known internally. Why do you need it? |
Topic: halting/resuming lua execution |
lhf
Replies: 4
Views: 907
|
Forum: Integration Posted: Wed Oct 07, 2009 4:48 am Subject: halting/resuming lua execution |
| Another way I've seen mentioned to drive a GUI is to respond to GUI events asap by enqueuing them in a Lua queue and then handling the queued events in Lua using coroutines. |
Topic: multi-dimensional table question |
lhf
Replies: 5
Views: 910
|
Forum: Language Posted: Wed Sep 30, 2009 8:48 pm Subject: multi-dimensional table question |
| contacts = { people = { } } works fine. |
Topic: multi-dimensional table question |
lhf
Replies: 5
Views: 910
|
Forum: Language Posted: Wed Sep 30, 2009 4:14 pm Subject: multi-dimensional table question |
| You can write contacts.people[3].name, which is nicer to read. |
Topic: multi-dimensional table question |
lhf
Replies: 5
Views: 910
|
Forum: Language Posted: Wed Sep 30, 2009 3:07 pm Subject: multi-dimensional table question |
Doesn't this work?
table.insert(contacts["people"], {name = "beth", age = 19 }) |
| |