Command: /settime
Posted: Wed Feb 27, 2008 8:09 pm
I apologize, but I have been banging my head against a wall for hours on what I assumed was something very simple; adding a new Command to set the world time (so when it gets all dark, we can make it light again
).
If you do not have time to deal with this right now, please do not worry about it. It's just me trying to get into the coding aspect with something simple. Obviously, nothing is simple but Hello World!
Here's what I have successfully done.
Commands.h:
#define COMMAND_SETTIME 58 (next one after 57 heh)
`commands` table in DB:
added record for settime, handler 58.
Commands.cpp:
What this does is if you type /settime and hit enter, it gives the syntax - that was the easy part. The part that threw me was the arg[0], which I am pretty sure I understand but other example commands used sep->arg[0] where mine would only work with sep->arg[1].
Anyway, typing /settime 1 (anything really) now prints out my debug line. Wee! Ok, here's where it all falls apart...
world_time.hour = part of the value
world_time.minute = other part
I know how to split them up at the :, but it's the "world_time.hour" part that's got me boggled. I took the code from World.cpp (init). Since it fails completely, I am assuming that is incorrect.
Anyway, if I gain an understanding of how to access World data/variables from within the command switch, maybe I could help add a few commands here and there.
The one I really want to see is /commands [text], which will list available commands that contain [text]. So then, we can build the /{command} help features using the helptext field. That should be easy... however, C++ is definitely not phpScript.
Thanks for your time with the noob.
If you do not have time to deal with this right now, please do not worry about it. It's just me trying to get into the coding aspect with something simple. Obviously, nothing is simple but Hello World!
Here's what I have successfully done.
Commands.h:
#define COMMAND_SETTIME 58 (next one after 57 heh)
`commands` table in DB:
added record for settime, handler 58.
Commands.cpp:
Code: Select all
case COMMAND_SETTIME:
{
if(sep && sep->arg[1]) {
client->SimpleMessage(CHANNEL_COLOR_YELLOW,"I'm in!");
} else {
client->SimpleMessage(CHANNEL_COLOR_YELLOW,"Usage: /settime {HH:MM}");
}
break;
}Anyway, typing /settime 1 (anything really) now prints out my debug line. Wee! Ok, here's where it all falls apart...
world_time.hour = part of the value
world_time.minute = other part
I know how to split them up at the :, but it's the "world_time.hour" part that's got me boggled. I took the code from World.cpp (init). Since it fails completely, I am assuming that is incorrect.
Anyway, if I gain an understanding of how to access World data/variables from within the command switch, maybe I could help add a few commands here and there.
The one I really want to see is /commands [text], which will list available commands that contain [text]. So then, we can build the /{command} help features using the helptext field. That should be easy... however, C++ is definitely not phpScript.
Thanks for your time with the noob.