Merentha
Come code with us
Come code with us
The adventure begins

Merentha Website
Overview
About LPC Coding
Header Files
The Problem Sets

Rooms
Normal Rooms
Monster Rooms
Search Rooms
Exit Rooms
Door Rooms

Monsters
Normal Monster
Random/Emote Monster
Patrol/Talking Monster
Skills/Interactive Monster

Armour
A Vest
A Ring
Cursed Armour

Weapons
Normal Staff
Two Handed Sword
Special Attack Weapon
Cursed Weapon
Talkin Weapon

Lights
A Match
A Torch
A Lantern

Bags
A Normal Bag
A Backpack (wearable)
An Expanding Bag

Misc Objects
A Leaf
A Sea Shell
A Key
A Snowball

Getting Started

These problem sets have been writen as a tutorial for those wishing to code on the Merentha Builders port. To use this you will need to have been made a coder on that port. At that time you will also have been given a short introduction and set on your way.

Setting it Up

The commands in LPC as a coder are simular to the ones in Linux or UNIX and somewhat simular to the old DOS command prompts. To make things easy on us now, type this:
cd
I will explain that command later.

Now if you haven't yet you should set your prompt to display your current directory. This will make things a lot easier in the future for you. The command is:
set PROMPT $D >

Now, if your prompt hasn't changed, quit and come back from the Builders and we will be set to begin.

Basic Commands

Here are some basic UNIX commands:

  • cd - change directory (folders)
  • ls - list the files in a given directory.
  • cp - copy a file
  • more - displays a file on the screen
  • mv - move a file
  • rm - remove a file
  • mkdir - make a new directory (folder)
  • rmdir - remove a directory (folder)
Here are some basic LPC coder commands:
  • update - updates the master object named in memory
  • clone - creates a copy of the file named

Follow the following steps to discover how to use these commands.

cd [directory] changes into the directory named. If you don't name one it will take you to your home directory. Your home directory is where you should be doing all your work. So first off type:
cd

ls [directory] list the files in the directory named. If you don't name one it will list the files in your current directory. Your current directory is displayed as your prompt and right now should be /realms/yourname/ Now, type
ls
That lists all the files in your directory, there should only be a few files there right now.

cp copies a file named source to a file called destination. If your destination file already exists the new file will be copied over it.

So now lets put these 3 commands to work. You have access to the Cabeiri area on Builders. So lets go there and take a look at the code. Type:
cd /domains/Praxis
Then type:
ls
This will cause a couple of lines of text to scroll across your screen. In the future you can type:
ls -m
Adding the -m will make the ls scroll though the more system so you can see the files easier if you wish to. Now lets chose a file to copy. Type:
cd obj/weapon

I will now take a moment to point out something. Notice that when we cd-ed into the Cabeiri area we used /domains/Praxis but when we cd-ed into the weapn directory we used obj/weapon. The point to look at is that one starts with a forwardslash / and the other doesn't. When you use a / at the start it means to start from the root directory structure. When you don't put the / at the front it means continue on from the current directory you are in. Also, in both cases we have a / in the middle. The / in the middle is to save time. We could have typed the following instead:
cd /domains
cd Praxis
cd obj
cd weapon
or we could have just typed cd /domains/Praxis/obj/weapon which saves us a lot of time.

Now get a listing of the files in your directory. It should look something like this:

 1   beak.c            1   knife2.c          1   staff.c
 1   bow.c             1   newbie_sword.c    1   sword.c
 1   dagger.c          001 orc_slayer.c      1   sword2.c
 1   horse_whip.c      1   rake.c            001 whammer.c
 1   knife.c           004 ranger_bow.c
The number in front is not to important right now. bascilly it is a number representing how big the file is. Lets copy sword.c into our home directory. Type:
cp sword.c ~
Ok, whats with the ~? Well the ~ means your home directory. You could also have typed cp sword.c /realms/yourname but this way was shorter.

After typing that you should see a line like:
Copied: /domains/Praxis/obj/weapon/sword.c to /realms/petrarch/sword.c
to tell you the file was copied correctly.

more will display a file on your screen. So now that we have a file in our home directory, lets see what is in it. Return to your home directory. To do so type:
cd
Get a listing of your directory. Notice that there is now a file called sword.c. Lets now see what is in that file. Type:
more sword.c
It should look something like this:

--==** /domains/Praxis/obj/weapon/sword.c **==--

#include 
inherit WEAPON;

void create() {
    ::create();
    set_id(({"sword","dull sword","a dull sword"}));
    set_name("sword");
    set_short("a dull sword");
    set_long( "This sword has seen better days. It appears to have "
      "been sitting in the sewers a while and as a consequence it "
      "is rusted almost to the point of uselessness.");
    set_mass(10);
    set_material(({"metal", "steel"}));
    set_value(0);
    set_wc(6);
    set_ac(1);
    set_type("blade");
}
That first line isn't part of the file, it just shows you what the filename is. That is because it is possbile to use wildcards. For example I could have typed more swo* and gotten the same result. Try it. The * is a pattern matching character.

We will be editing the sword file later. So let us make a backup of the sword.c file incase we mess it up later on. To make a backup copy type:
cp sword.c oldsword.c
Now when you list the directory you will see an oldsword.c file.

mv will move (or rename) a file. If the newname is a file which already exists the old file is copied over. To test it out type:
mv sword.c mysword.c
Then take another listing of your directory. Notice now there is no more sword.c file but there is a new file mysword.c Basiclly you have renamed the file.

rm will remove a file. Lets make a file we can remove just so you can test it out. Type cp mysword.c sword.c and then type ls notice now there is a sword.c file, that is the file you just copied. Now remove it. Type:
rm sword.c
And then take another directory lising. Notice that the sword.c file is now gone again.

mkdir will make a new directory. Type:
mkdir area
Then take a directory lising. There is now a file called area/ in your directory. Notice that directories don't have a sile number and end in a / so you know they are directories. You can cd into that directy if you want.

rmdir will delete a directory. This command only works if the directory is empty. Remove the directory you just created. You will have to return to your home directory if you went into the area/ directory.

Play around with creating and delete directoies, copying files and so on. Once you are confortable with these actions continue to the second part of this problem set.

Part 2 - Basic Coder Commands

More commands will be described later. Right now only two are important. Return to your home directory and we can start.

update [file] - updates a file after changes. For now type:
update mysword.c
If any changes were made to the file, type that command again to make the changes load into memory. Of course no changes were made, and the next problem set describes how to make them. If you did not enter a file name you will update the room you are in.

clone - clones a file. Type:
clone mysword.c
And you now have your very own weapon.



Merentha
It's your creation
Merentha Entertainment
© Copyright 1998-2002
Merentha Entertainment
All rights reserved.