Skip to content

Commit

Permalink
Add mmud_edit.py script (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
paladine authored Jan 5, 2022
1 parent 0ef2e06 commit 62ee6dc
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
51 changes: 51 additions & 0 deletions scripts/mmud_edit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/python3

import argparse
import sqlite3
import sys

def _create_parser():
parser = argparse.ArgumentParser(description='Edit your 1.11p MMUD character in MBBSEmu.')
parser.add_argument('--username', help='Username to edit', required=True)
parser.add_argument('--experience', help='Experience value to set', type=int)

return parser.parse_args()

def _main():
args = _create_parser()

conn = sqlite3.connect('WCCUSERS.DB')

c = conn.cursor()
t = (args.username,)
c.execute('SELECT data FROM data_t WHERE key_0=?', t)

data = c.fetchone()
if data is None:
print('Username not found in WCCUSERS.DB')
return

b = bytearray(data[0])

#exp
if args.experience is not None:
#print('Experience is {}'.format(args.experience))
b[0x46F] = args.experience & 0xFF # low byte is validated
b[0x470] = ((args.experience >> 8) & 0xFF)
b[0x471] = ((args.experience >> 16) & 0xFF)
b[0x472] = ((args.experience >> 24) & 0xFF)

# copper farthings (32-bit int) low-byte @ 0x60F
# silver low-byte @ 0x60B
# gold low-byte @ 0x607
# platinum low-byte @ 0x603
# runic low-byte @ 0x5FF

# and write it back
t = (sqlite3.Binary(b), args.username,)
c = conn.cursor()
c.execute('UPDATE data_t SET data=? WHERE key_0=?', t)
conn.commit()

if __name__ == '__main__':
_main()
16 changes: 16 additions & 0 deletions scripts/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Helper Scripts

MBBSEmu includes various scripts to help maintain your configuration.

## mmud_edit.py

**mmud_edit.py** is a [Python3](http://www.python.org) script to edit player data from within **WCCUSERS.DB**. It supports MajorMUD 1.11p and should not be used with any other versions. It should be run when your system is offline because it won't be able to access the sqlite3 database at the same time as MBBSEmu.

### Usage

```
mmud_edit.py --username=USERNAME [--experience=EXPERIENCE]
```

> **Note:** **mmud_edit.py** should be run from the same directory that **WCCUSERS.DB** resides.

0 comments on commit 62ee6dc

Please sign in to comment.