Building in different codebases
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    mudlab.org Forum Index -> Building
View previous topic :: View next topic  
Author Message
kaylus



Joined: 04 Jun 2005
Posts: 5
Location: Tallahassee, Florida

PostPosted: Thu Jun 16, 2005 12:49 am    Post subject: ColdC Reply with quote

Quote:
Cold looks like geek heaven, as well as someone taking olc a little too far.


I would probably put it into the "geek heaven" category. I have used it for various personal implementations (since the uses of it far extend the creation of MUDs). The OLC part is only true of ColdCore and other similar "Cores" which are actually usually just snapshots of people's current databases on release. For instance the minor core I work on for fun has no real OLC to speak of. I just twiddle in the text dump of the database.

Quote:
While I'm not entirely sure how my contribution is useful, I do have a question, does any of these languages have a switch statement?


Yes, ColdC has all the regular statements. The full reference manual can be viewed at the cold.org site: ColdC Reference Manual

I'm partial to the building systems on most LPC-type games, though as mentioned earlier it does seem like a lot of coding. Here is an example of building in GenMUD, a pike version of an LP-esque driver that i'm about to release. (ignore both the poor descriptions and the different handling of strings in both the files)

Code:
/**********************************************************
 **  File Name: gen_store.pike
 ** Created by: Kaylus@Solice / 01-23-03
 **********************************************************/
inherit "std/shop.pike";
#include <mudlib.h>
inherit ROOM;

void create()
{
  ::create();
  set("short", "%{C}General Store");
  set("light", 1);
  set("long",
"   This building is small and raggedy in appeareance, the wall \
adjacent the road is made so it can be lifted up and hooked into \
place, which gives the store an almost temporary feeling despite \
it's large timbered foundation. The walls are made of mismatched \
boards, any holes appear hastily packed with mud and straw. On the \
far east wall is a curtained door.");
  set("exits",([ "east":"zones/ardne/store_room.pike",
                 "west":"zones/ardne/nroad.pike" ]));
  set("item_desc", ([ "sign":
    "%{O}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"+
    " %{W}%{+}list or list <item>%{-}\n"+
    "  Lists all items in the store or all items that\n"+
    "  match the description <item> specified.\n"+
    " %{W}%{+}buy <item or #>%{-}\n"
    "  Buy an item in the store by name or by item #.\n"+
    " %{W}%{+}sell <item>%{-}\n"+
    "  Sells an item in your possession.\n"+
    " %{W}%{+}value <item>%{-}\n"+
    "  Value an item in your possessions.\n"+
    "%{O}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n%{.}",
    "mud":"Just plain mud.", ]) );
  set("pre_exit", "@@this_object::exit_east");
  reset();
}

int exit_east()
{
  if(this_object()->present("feilwar"))
  {
    this_player()->write(iwrap(
    "Feilwar pushes you away from the door and says, \"I'm sorry, but no"+
    " one is allowed back there. Please get away from the store room.\""));
    return 0;
  }
  return 1;
}

void reset()
{
  ::reset();
  if(!present("feilwar"))
    set_keep("zones/ardne/living/feilwar.pike");
    set_store("zones/ardne/store_room.pike");
}


While this seems complicated it is not indicative of all the rooms across the entirety of the world. Most of them are mainly:

Code:
/**********************************************************
 ** File Name: nroad.pike
 **********************************************************/
#include <mudlib.h>
inherit ROOM;

void create()
{
  ::create();
  set("short", "%{O}Northern Road");
  set("light", 1);
  set("long",
"   The dirt road widens a bit at this point, likely due to the "+
"the general shop to the east. An aged and wizened oak tree stands "+
"next to the store, it's full branches hanging high above the road. "+
"Changing direction here, the road heads south towards the center "+
"of town and northeast towards the forest. %!NIGHT:Light overflows "+
"from the store to the east, causing the shadow of the oak to flicker "+
"across the road%!");
  set("exits",([ "northeast":"zones/ardne/neroad1.pike",
                 "south":"zones/ardne/square.pike",
                 "east":"zones/ardne/gen_store.pike" ]));
}


The long descriptions are read by a function which wraps them to a specified length and parses out any %!CODE%!'s within them. The codes I currently have available are NIGHT,DAY, and a poorly implemented SKILL(usage SKILL_MOVEMENT>X). These can also call functions by using the @@object:function text inside the %!CODE%!.

Since I found large world creation to be moderately cumbersome I also implemented OLC into the game, actually it was offline first but due to the fact I had written it in Pike it meshed in pretty well.

Here is a small example.

Code:

GenMUD> build
%{G}Solice Builder%{-}

1 ... Create a Zone
2 ... Edit a Zone
3 ... Set Default Areas

h ... get help
q ... quit out

Your choice: 1
What is the name of this zone: test
Are the majority of rooms outside [0=no/1=yes]: 1
Are the majority of rooms lit [0=no/1=yes]: 0
How many rooms wide is this zone: 5
How many rooms deep is this zone: 4


Zone name: test.

x Y0 1 2 3 4  (6)
0  . . . . .
1  . . . . .
2  . . . . .
3  . . . . .

What coordinates to edit (h for help): 1,3


Name: test1-3

[1] .. Short: A room of test
[2] .. Long:

This room is nondescript.

[3] .. Has Light: 0             [4] .. Outside: 1
[5] .. Item Descs.              [6] .. Exits
[7] .. Objects:

([ ])

[8] .. Random Object Chance: 0
[9] .. Random Objects

What is your choice [ '!' deletes, 'q' saves and exits ]: q

Zone name: test.

x Y0 1 2 3 4  (6)
0  . . . . .
1  . . . * .
2  . . . . .
3  . . . . .

What coordinates to edit (h for help): compile

Completed compilation.
Press [enter] to continue.


This creates the code for the files <zonename><x>-<y>.pike, in this case test1-3.pike. The finished output looks quite similar to the above rooms. Of course in this case it really is a room that doesn't have much and no exits!

Unfortunately I haven't finished implementing object creation into it yet, and may not before release. There is also the problem of security within the %! code's (calling functions from @@). Since I use a compiler handler to compile the in-game code and keep it seperate from the true Pike language the chance of system damage with this ability isn't there (any longer), but game damage is a heavy possibility ATM.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    mudlab.org Forum Index -> Building All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
BBTech Template by © 2003-04 MDesign