My who code.

Submitted by MrWigggles on Thu, 2011-09-29 02:26

This is my who code, or more accurately, my who & where code. I manage to get the pertinent information, in under 80 character lengths. Overall, I'm pretty happy with it. This is the third iteration of it, and I'm not done with it. The last part, as far I know I'll be adding, is changing the connection record to reflect unique connects vs. actual connections.

It does use some custom functions, though none of them were particularly needed to make the who/where work. That just to make coding projects on my Mu*, have more uniformity.

Semaphore example

Submitted by raevnos on Thu, 2011-06-02 20:22

Commands like @switch and @dolist that can put multiple entries into the queue will interact badly when the command that uses them is run at the same time, especially if the queue entries depend on object state like the value of an attribute being the same value at the start of entry N+1 as it was at the end of entry N. If entry M from a separate run of the command also modifies the attribute between N and N+1's execution, things break. Semaphores help control race conditions like these.

Rooms with Columned Players

Submitted by Mercutio on Sat, 2011-05-14 14:39

Let's assume a game wants their conformat's players to be
displayed in three columns, thus as follows:

Player 1                  Player 2                  Player 3
Player 4                  Player 5                  Player 6

The way to display each single name is:

&conformat`name OBJ=left(name(%0),25)

The logic behind using 25 is because a name default can be 24 characters.

Handling Large Lists, and the Buffer Limit

Submitted by Mercutio on Fri, 2011-05-06 10:48

Let's assume you have a large player base, with say... ~255 players that actively get used. And let's assume they are all in an attribute, except for the staffers. This way, during this exercise, there will be a stable amount of output.

Now, let's assume we wanna display information about these players, and stick them into an align()ed area. Most new coders would use iter() or map() to show them all. But they run into a problem! Due to the way align() works, one reaches the buffer limit extremely fast, and one will be cut off around #118 or so.

Sure, one can increase the buffer length to twice its size by altering mushtype.h, but that is nowhere near ideal, and will crash your game over a 2x increase. So... how do you handle this?

A Random Player

Submitted by Mercutio on Thu, 2011-05-05 23:31

This is perhaps a fairly simple thing, but does have a semi-decent amount of use on games:

Out of all the players on your game, pick one. That's it. Just pick one player, but do it /at random/.

One problem, many solutions

Submitted by Mercutio on Thu, 2011-05-05 22:41

This book is a collection of the column pages posted that pose a Softcode problem, then contains a solution, and asks other users to post their version of the code.

The meaning of this column is to teach softcode, and show off useful code-snippets that optimize against buffer length and function calls, or show useful logic or rarely used functions.

But more importantly, it shows different ways of tackling things, and how to solve certain very common problems.