Search found 13 matches

by davidk
Mon Jan 25, 2010 10:13 am
Forum: Howtos, FAQs and Tips & Tricks
Topic: The Shared Namespace and You
Replies: 34
Views: 97462

Re: The Shared Namespace and You

I suggest having a look at the documentation as well. Ok, here it is: ( http://www.lua.org/manual/5.1/manual.html#pdf-module ) (Emphasis added by me). module (name [, ···]) Creates a module. If there is a table in package.loaded[name], this table is the module. Otherwise, if there is a global table...
by davidk
Mon Jan 18, 2010 1:31 pm
Forum: Howtos, FAQs and Tips & Tricks
Topic: The Shared Namespace and You
Replies: 34
Views: 97462

Re: The Shared Namespace and You

Lua modules are tables which contain all the functions and variables, so in the end the result is the same. No. The distinction is that Lua modules, if done properly, does not pollute the users' namespace. Read the documentation for the module function. This function creates a table and uses setfen...
by davidk
Mon Jan 18, 2010 1:22 pm
Forum: Help Forum
Topic: Find if an item exists in an array
Replies: 1
Views: 2761

Re: Find if an item exists in an array

The fastest way would be to use your item names as keys, e.g. foo = { ["one fish"] = true, ["two fish"] = true, ...} Then you can test for the existence using the expression foo["one fish"]. If for some reason you cannot have such a lookup table you would have to use th...
by davidk
Fri Jan 15, 2010 11:53 am
Forum: Howtos, FAQs and Tips & Tricks
Topic: The Shared Namespace and You
Replies: 34
Views: 97462

Re: The Shared Namespace and You

Lua have modules and closures to solve this very problem. Why would you want to promote this anti-pattern over those features? Lua modules are tables which contain all the functions and variables, so in the end the result is the same. If you thought of the "module ()" function, that funct...
by davidk
Fri Jan 15, 2010 11:38 am
Forum: Help Forum
Topic: %pop in lua?
Replies: 6
Views: 5165

Re: %pop in lua?

Just keep in mind that key-pair tables in Lua don't preserve order. If you'd like to keep it, use the "php-like" tables available from here: http://lua-users.org/wiki/MakingLuaLikePhp In the example in the original post integer keys were used so the order is explicitly the order of those ...
by davidk
Sun Jan 03, 2010 10:31 pm
Forum: Mudlet Development
Topic: mudlet TTYPE policy
Replies: 2
Views: 3143

Re: mudlet TTYPE policy

I don't run a MUD myself, but I am currently playing with an experimental MUD-Driver/MUD-Lib I am writing and got some thoughts about the TTYPE option, too. The Telnet protocol allows the server to ask the client for further TTYPEs until it either recognized one or the client repeated a TTYPE twice ...
by davidk
Sun Jan 03, 2010 8:47 pm
Forum: Mudlet Development
Topic: Mudlet Mapper
Replies: 139
Views: 150898

Re: Mudlet Mapper

Alright. How about we follow an MVC model - with the viewer being a 3d one, or a 2d one, or an ascii one if you'd like. The model will be shared, just the views will take care of handling the display and visual navigation. Controller would be the same for them all too. Oh, I fear I wasn't quite cle...
by davidk
Fri Jan 01, 2010 11:48 am
Forum: Mudlet Development
Topic: Mudlet Mapper
Replies: 139
Views: 150898

Re: Mudlet Mapper

Personally I would prefer it if the 3D-mode is optional. On GNU/Linux I couldn't get OpenGL to work ever since I upgraded to a bigger monitor (my computer and my graphics card is already quite old and the proprietary drivers aren't supported by NVIDIA anymore...). If Mudlet depended on OpenGL I coul...
by davidk
Thu Dec 17, 2009 8:58 am
Forum: Help Forum
Topic: executing a function that is a value in a table
Replies: 5
Views: 4525

Re: executing a function that is a value in a table

There is also a third syntax:

Code: Select all

attackTable = { }

function attackTable.axehere ()
  -- ...
end
by davidk
Tue Dec 15, 2009 7:04 pm
Forum: Mudlet Development
Topic: Some feature requests
Replies: 4
Views: 5187

Re: Some feature requests

- Well, speed wasn't the main reason I asked for bit operators. I find them extremely useful in a multitude of situations, but mainly when doing stuff with bitflags/bitmasks. I guess I can just make my own functions to emulate these - I just thought the Lua libraries might be somewhat more efficien...