17 Aug, 2010, thaolen wrote in the 1st comment:
Votes: 0
Hello, I am in the process of making a mud using the NakedMud codebase. My question is how much can python do for me with the codebase? Am I limited at lets say, I want to make a command, or make a mail system inside of NakedMud, how would I go about making them, because I have no clue what to program in a python script, as the tutorials inside of the NakedMud docs don't really go into it. As C is the main code that is used, I was told you can use Python only, and for all aspects of the MUD. thanks
17 Aug, 2010, chrisd wrote in the 2nd comment:
Votes: 0
You can do everything in Python. :biggrin:
17 Aug, 2010, thaolen wrote in the 3rd comment:
Votes: 0
hehe, thanks, could you help me out with NakedMud chrisd? Do you code with it by chance?
17 Aug, 2010, chrisd wrote in the 4th comment:
Votes: 0
I am familiar with it, yes. What is it that you need help with? I'm happy to help you on these forums (as I'm sure others are), but there is also a fairly active NakedMUD IRC channel - #nakedmud on irc.freenode.net - which you can access in your browser here.
18 Aug, 2010, thaolen wrote in the 5th comment:
Votes: 0
I know about them, but there are things they don't answer, that is why I'm here ;) I have been asked them and talking their ear off anyway, giving them a break.

What I need to know is, say I want to make a new command like cast magic missile, that is an easy one for you, and I am learning python a little at a time, which it is easy enough but I don't know what I would need to type, what commands to get something like that going.

I know there is a reference guide for python and C, but an example would really help me out, and in the future I really would like to figure it out if I want to make other commands or a mail system. So it would be the command cast in python code. Or wield etc.. among others as this is just an example, I read the ex in the docs folder but that really doesn't help me. Hope that description helps
18 Aug, 2010, Rudha wrote in the 6th comment:
Votes: 0
add_cmd() is the command you want to add a command to the game, as to how to make it do something, well thats a much bigger problem!

First, you need to make a function for the command, and it has to follow a very specific format:

def command(ch, cmd, arg):
<code here>

CH is the character that did the command. CMD is the command that they did. ARG is any arguments they did with the command. For example if my character did cast 'magic missile' then CH is the character object for Rudha (my character), CMD would be cast, and ARG would be 'magic missile'

You need to use parse_args() to .. well, parse the arguments. The full documentation for that is in ./src/parse.h

Here's an example of a simple command I made to say something TO someone, to have an example to look over:

# —————————————————————————–
# Function: cmd_sayto
# A derivative of Say that allows one to direct speech to a specific person.
#
# In-game usage:
# > sayto <person> <message>
def cmd_sayto(ch, cmd, arg):
# See if we can find the player
try:
tgt, mssg = parse_args(ch, True, cmd, arg, "ch.world.noself string")
except:
message(ch, None, None, None, False, "to_char", "What are you trying to say to someone, and to whom?")
return
do_sayto(ch, tgt, mssg)



The actual sayto thing:

# —————————————————————————–
# Function: do_sayto
# The actual heart of the targetted say code.
def do_sayto(ch, tgt, mssg):
if (mssg == ''):
ch.send("Say what?")
else:
mssg = comm.preprocess_msg(mssg)

teststr = mssg
period = re.compile( r"^(.+)\.$" )
question = re.compile( r"^(.+)\?$" )
exclamation = re.compile( r"^(.+)\!$" )
if (question.match( teststr )):
isQuestion = "yes"
isExclamation = "no"
else:
if (exclamation.match( teststr )):
isQuestion = "no"
isExclamation = "yes"
else:
isQuestion = "no"
isExclamation = "no"
if (isQuestion == "yes"):
# act is "ask"
act_3p = "asks"
act_1p = "ask"
elif (isExclamation == "yes"):
# act is "exclaim"
act_3p = "exclaims"
act_1p = "exclaim"
else:
# act is "say"
act_3p = "says"
act_1p = "say"

# Get names
cname = ch.name
tname = tgt.name

# Send the message
if (isQuestion == "yes"):
msg_3p = ("{C%s %s %s, \"%s\"{n" % (cname, act_3p, tname, mssg))
msg_2p = ("{C%s %s you, \"%s\"{n" % (cname, act_3p, mssg))
msg_1p = ("{CYou %s %s, \"%s\"{n" % (act_1p, tname, mssg))
else:
msg_3p = ("{C%s %s to %s, \"%s\"{n" % (cname, act_3p, tname, mssg))
msg_2p = ("{C%s %s to you, \"%s\"{n" % (cname, act_3p, mssg))
msg_1p = ("{CYou %s to %s, \"%s\"{n" % (act_1p, tname, mssg))

send_message(msg_1p, ch, msg_2p, tgt, msg_3p)

# Say hook
hooks.run("say", hooks.build_info("ch str", (ch, mssg)))


Thats probably a little more complicated an example, the actual sayto, but I didnt want to give a half-assed example

Once you have a command written, you need to add it into the mud system using this:

add_cmd("sayto", None, cmd_sayto, "speaker", False)

the parameters are the command name, a prefered shorthand, the name of the function to run when the player uses the command, and the usergroup you have to be in to use the command, ie, player, admin, wizard, et cetera. (We use speaker as a seperate usergroup for communication commands so that we can easily mute a player by removing them from that group, as an aside.) TThe last is a boolean true/false that indicates whether the command interrupts other current actions.

Maya/Rudha

Edit: Put the code in tags.
18 Aug, 2010, thaolen wrote in the 7th comment:
Votes: 0
Thanks for the speedy reply :) That is a lot to understand, I will do my best, as you have found all the code references you need in that h file. And that looks like Python code but are you referring to both C and Python. Anyway I'll try to understand it best I can. And Python is what I'm after due to the complex ways about C. I think maybe something easier as my skill level progresses, instead how about a stats system, HP MP Gold: maybe that would help me greater. A python ex for that would be great.
18 Aug, 2010, chrisd wrote in the 8th comment:
Votes: 0
Getting a full on combat system working is quite difficult - even for those of us with quite a bit of experience.

I'd suggest that you start on something a bit simpler to begin with. As you complete simple projects your understanding of the codebase will grow and you'll find that you're able to take on bigger and bigger challenges. Some ideas:

* Player stats (health, mana, stamina, etc)
* Player attributes (strength, dexterity, intelligence, etc)
* Levels and experience (including level up/down rewards/punishments)
* Skills
* Death/defeat (including punishments - loss of XP, whatever)

Stats and attributes are actually quite easy with NakedMUD and writing modules for them will introduce you to one of the most important tools you'll work with using NM - auxiliary data.

If you'd like some examples or further advice, just ask!

EDIT: Here's a simple example of some auxiliary data for you:
import auxiliary, storage

class AuxData:
def __init__(self, storage_set=None):
self.whatever = "whatever"

if storage_set is not None:
if storage_set.contains("whatever"):
self.whatever = storage_set.readString("whatever")

def copyTo(self, to):
to.whatever = self.whatever

def copy(self):
new = AuxData()
self.copyTo(new)
return new

def store(self):
storage_set = storage.StorageSet()

storage_set.storeString("whatever", self.whatever)

return storage_set

auxiliary.install("aux_data", AuxData, "character")
18 Aug, 2010, Rudha wrote in the 9th comment:
Votes: 0
The NakedMud Python engine is essentially a scripting engine - Python after all is a scripting language. Everything can be implemented in python and we in Elvenblade have moved just about everything game-related into python as a matter of fact. The NakedMud engine however, offers a lot of built-in functions in the mud, mudsys, etc modules to make things easier for you.

chrisd is right though, a combat system is -not- simple. We've been working the implementation of our skills system since Jan. now :)

Maya/Rudha
18 Aug, 2010, thaolen wrote in the 10th comment:
Votes: 0
I'm feeling rather dull, what is aux data? Just curious where did you learn what to code the actually code for nakedmud, a reference in the code of Nakedmud? I have no ideas and learning Python might help but that won't tell me what to type for nakedmud, sorry for being so dull.
18 Aug, 2010, Rudha wrote in the 11th comment:
Votes: 0
Auxiliary data is the NakedMud way for adding data that isnt already built into things like characters or rooms etc. Essentially it is the method by which you can add things like stats through python.

Maya/Rudha
18 Aug, 2010, chrisd wrote in the 12th comment:
Votes: 0
I learnt to code for NM by looking at examples that other people had posted on the Pastebin and the modules available on Geoff Hollis' site.

As Rudha says, auxiliary data lets you add information to things like characters and rooms. It's useful because it means you don't have to go and modify the core code when you want to add stuff, you just install it - as in the example above.
18 Aug, 2010, Rudha wrote in the 13th comment:
Votes: 0
I have a lot of experience in coding MUDs so that helped :) But honestly, I find the best way is to isolate a segment of code, and play with it until it works as you like. Hands-on experience like that really teaches best, in my opinion :) You just have to be prepared for things breaking every now and again.

Maya/Rudha
18 Aug, 2010, thaolen wrote in the 14th comment:
Votes: 0
Lol ok another question, now that i know what aux does, what do you enter say, lets do something really easy, I want to make a person say something when you poke them in the ribs, you make a poke command just a little command, and what it does when you poke the person the emote says you poke Joe, Joe says that smarts..
18 Aug, 2010, chrisd wrote in the 15th comment:
Votes: 0
import mud, mudsys

def cmd_poke(ch, cmd, arg):
try:
tgt, = mud.parse_args(ch, True, cmd, arg, "ch.room.noself")
except:
return

mud.message(ch, tgt, None, None, True, "to_char", "You poke $N.")
mud.message(ch, tgt, None, None, True, "to_vict", "$n pokes you.")
mud.message(ch, tgt, None, None, True, "to_room", "$n pokes $N.")

tgt.act("say That smarts.")

mudsys.add_cmd("poke", None, cmd_poke, "player", False)
18 Aug, 2010, Rudha wrote in the 16th comment:
Votes: 0
You want a trigger for that. Triggers are pieces of code that you can attach to an object or character when a given event occurs, for example, when a player enters or leaves a room.

TRIGEDIT from within the mud will allow you to edit a trigger. You can then select the condition from the list of conditions possible, and the code is any other python script. In this case all you'd need to do in the code is ch.say("That smarts…"). Its pretty simple when you know how!

But this isnt all you need to do! This part gets novice builders all the time - you need to actually attach the trigger to an object or character. Go into MEDIT or OEDIT as you want, and edit the list of triggers to include your own. Ie, poke_trigger@YourZone

Maya/Rudha
18 Aug, 2010, thaolen wrote in the 17th comment:
Votes: 0
Thanks for all the help, you guys are prompt, I'll have a look at this that will certainly help.
18 Aug, 2010, Rudha wrote in the 18th comment:
Votes: 0
It gives me something to do whilst I do tedious balance testing :) Let us know if you need further help or have other questions!

Maya/Rudha
18 Aug, 2010, Chris Bailey wrote in the 19th comment:
Votes: 0
Just out of curiosity, how well do you know the Python language? If you don't know it well, you might be better off learning the language before attempting to create something with it.
18 Aug, 2010, thaolen wrote in the 20th comment:
Votes: 0
I know a minimal about of python, I'm learning the non-programmers guide 2.6 python slowly, but I have a little exp with C++ so I know the basics nothing fancy though, but what I can't figure is what actual code I need to type for the NakedMud code.
Sorry to sound redundant but I suppose I'll learn as I go, could you give me a tip of what I really need to know more than anything in Python so I can accomplish my task?
0.0/33