Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    557
  • comments
    1237
  • views
    423132

Yay, a scripted MUD

Sign in to follow this  
Evil Steve

215 views

My MUD now has simple scripting using DruinkScript [smile] I ended up writing my own string class, since I want a nice lightweight one that can actually free memory when I tell it to, which std::string doesn't (calling std::string::clear() doesn't free memory). The reason is, that I use memory pools in DruinkScript, and if the memory isn't freed, then the pools eventually overflow (It's hard to explain, just take my word for this).
So all strings inside IDruinkScript::Run() are lightning fast.

I've added a few more opcodes to DruinkScript, and I've got a test script working. Here's the list of supported opcodes in DruinkScript now:
push, pop, mov, add, sub, mult, div, pow, sqrt, inc, dec, call, label, jmp, je, jne, jl, jle, jg, jge, cmp, return, rand.
And here's my test script, linked to the OnExit event, which is fired whenever a user tries to exit a room:

; TestScriptExit.ds
; Denies the user from exiting a room 50% of the time

rand 0, 1
pop a
cmp a, 0
je Deny
return 1
label Deny
push "Computer says no.\n
call Send
return 0


Yay! Now I need to bind some more functions, and implement some more commands, and actions. Then I want to get spells and NPCs up and running, then we can have some combat.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!