|
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Wed Oct 29, 2008 11:40 pm
[FR] zs.(lua) function returns mapped |
as we know, type mismatch is one of major annoyances programmer encounters...
and cmud passes returns trough autoconverter, which is btw. _absolutely_brilliant_ in handling variables
but when mapquery returns number for one room and table for more and roomexit can return string when theres only one exit it gets me
master z, please, have function returns ran trough hardcoded conversion table |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Oct 30, 2008 6:38 pm |
I guess I'm not following you. Can you give me more specific examples that I can enter into CMUD that shows the problem you are having?
|
|
|
|
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Thu Oct 30, 2008 7:51 pm |
this isnt really a problem, just would be nice to have some consistency regarding returns, atm i have 3 different wrappers for various combinations, hopefully wont need more, and they just double work that cmud already done (just differently)
anyway:
Code: |
print(type(zs.roomexit())) |
teleport to room with one exit and then with multiple exits
with one exit we get string, with multiple table, with no exits empty string... for roomexit would be logical to get either table in all cases or table if exits are present and nil if not, chosen convention should apply to all functions that can return multiple results (making returns uniform) |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Oct 30, 2008 10:31 pm |
Ah, OK, I see what you are saying.
What CMUD is trying to do is convert a CMUD String List into a Lua table. But there is no way to tell the difference between a single string value and a string list with a single element. The CMUD Lua routine just simply looks for the | character to determine if a string result is a string list (or database variable). Since a single exit or no exits just returns a simple string without any | character, the Lua module has no way to convert it.
The problem is that CMUD is still typeless (auto-typed) as far as functions go. It's only CMUD variables that have a specific type. So, no way to fix this for now. I'd have to assign specific types to every function and that's something for the future.
At least you have a workaround. |
|
|
|
intoK Apprentice
Joined: 18 Feb 2007 Posts: 190
|
Posted: Fri Oct 31, 2008 9:02 am |
All rights, good to hear its planed, cheers.
|
|
|
|
|
|