Help with code mod

Posted by Corey on Wed 19 Dec 2007 07:33 AM — 20 posts, 68,791 views.

#0
I am trying to add a mod to my mud which uses smaugfuss 1.8 lua in cygwin.

Syntax
------
Disable <command> -- Toggles the command from disabled or enabled.
Disable -- Views list of disabled commands

Installation
------------
1.) Copy the following code (do_disable) into your source (preferably act_wiz.c):

void do_disable( CHAR_DATA *ch, char *argument )
{
CMDTYPE *command;
CMDTYPE *cmd;
char arg1[MAX_INPUT_LENGTH];
int hash, cnt;

smash_tilde( argument );
argument = one_argument( argument, arg1 );

set_char_color( AT_IMMORT, ch );

if ( arg1[0] == '\0' )
{
send_to_char( "Disable what command?\n\r&WCommands currently disabled:&D\n\r", ch );
for ( cnt = hash = 0; hash < 126; hash++ )
for ( cmd = command_hash[hash]; cmd; cmd = cmd->next )
{
if ( IS_SET( cmd->flags, CMD_FLAG_DISABLED ) )
ch_printf(ch, "&w%s&D\n\r", cmd->name );
}
return;
}

command = find_command( arg1 );

if ( !command )
{
send_to_char( "No such command.\n\r", ch );
return;
}

if ( !str_cmp( command->name, "disable" ) )
{
send_to_char( "Ha! No.\n\r", ch );
return;
}

if ( command->level > get_trust(ch) )
{
send_to_char( "You cannot touch this command.\n\r", ch );
return;
}

if ( IS_SET( command->flags, CMD_FLAG_DISABLED ) )
{
ch_printf( ch, "The command '%s' is no longer disabled.\n\r", command->name );
REMOVE_BIT( command->flags, CMD_FLAG_DISABLED );
save_commands();
return;
}
else if ( !IS_SET( command->flags, CMD_FLAG_DISABLED ) )
{
ch_printf( ch, "The command '%s' is now disabled.\n\r", command->name );
SET_BIT( command->flags, CMD_FLAG_DISABLED );
save_commands();
return;
}

}

2.) In mud.h, find these lines:

#define CMD_FLAG_POSSESS BV00
#define CMD_FLAG_POLYMORPHED BV01
#define CMD_WATCH BV02 /* FB */

And below them, add this:
#define CMD_FLAG_DISABLED BV03

3.) In interp.c, find this line:
buf = check_cmd_flags ( ch, cmd );

Before that, add these lines:
if ( IS_SET( cmd->flags, CMD_FLAG_DISABLED ) )
{
send_to_char( "That command is currently disabled.\n\r", ch );
return;
}

4.) Add the appropriate line to mud.h for do_pecho and the 2 lines to tables.c.

5.) Make clean, make and hotboot/reboot the MUD. Use cedit to create the command.

I am having some problems thou, number 4, I can't find the routine do_pecho in my code, and what 2 lines? I guess this is written for someone who knows the code pretty well.
so, will/can someone smaugfuss 1.8 lua-fy this code mod for me? please.

thanks,

Corey
USA #1
i am guessing he meant do_disable as in:

DECLARE_DO_FUN( do_disable );

for tables.c he is talking about similar declarations, do a search for do_goto or something similar, there should be two entries, add do_disable to the appropriate spots.
USA #2
You do not need to do tables.c if you're using FUSS with dynamic tables.
#3
it's not working or compiling, can someone mod this mod for smaugfuss 1.8 lua in cygwin for me?
USA #4
an easier suggestion is to post the errors you get when compiling so we can provide you the necessary info to fix your code.
#5
thought of that, can't figure out how to capture the errors to a file. I am a dos person and more won't capture in cygwin tcsh.
Australia Forum Administrator #6
Cygwin runs in a "dos" window, the output of which can be copied to the clipboard. Use the system menu (top left corner) and find the Edit -> Mark command. Then drag over the relevant part to select it and then hit <enter> to copy the selected text to the clipboard.
#7
this is all it would give me:

/cygdrive/c/sfuss/src/mud_prog.c:3260: undefined reference to `call_lua_num(char
_data*, char const*, int)'
o/mud_prog.o: In function `_Z18oprog_drop_triggerP9char_dataP8obj_data':
/cygdrive/c/sfuss/src/mud_prog.c:3276: undefined reference to `call_lua_num(char
_data*, char const*, int)'
o/reset.o: In function `_Z10reset_areaP9area_data':
/cygdrive/c/sfuss/src/reset.c:897: undefined reference to `call_mud_lua(char con
st*, char const*)'
o/save.o: In function `_Z13save_char_objP9char_data':
/cygdrive/c/sfuss/src/save.c:236: undefined reference to `call_lua(char_data*, c
har const*, char const*)'
o/shops.o: In function `do_buy':
/cygdrive/c/sfuss/src/shops.c:578: undefined reference to `call_lua_mob_num(char
_data*, char const*, int, int)'
o/update.o: In function `_Z11char_updatev':
/cygdrive/c/sfuss/src/update.c:844: undefined reference to `call_lua(char_data*,
char const*, char const*)'
o/update.o: In function `_Z14hallucinationsP9char_data':
/cygdrive/c/sfuss/src/update.c:1875: undefined reference to `call_lua_num(char_d
ata*, char const*, int)'
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make: *** [all] Error 2

C:\sfuss\src>
USA #8
Doesn't look like it has anything to do with the snippet.

Can you post those lines?
#9
Which lines?
USA #10
what is the very first error you see when you compile
#11
this is all I can copy, it only lets me copy whats in the window.
Australia Forum Administrator #12
You need to take charge of your output or you will not get very far. If you can't see all the error messages how can you fix them?

In Cygwin you can set the number of lines to be saved in the output window, you can also drag and resize it (in fact this applies to any Dos window).

Another approach is to tell make to "page" the compiler output. For example:


 make 2>&1 | less


This will send stderr (the error messages) to stdout (normal output) and then send all of that to the "less" program which stops after a screenfull.
Australia Forum Administrator #13
However from what I can see of your error messages, they are nothing to do with the snippet, but are something to do with the Lua code either not compiling, or not being linked in. Have you changed the Makefile? Perhaps the lines to link in the Lua parts have gone missing.
#14
ok, I got it to compile, it seems it only sees lowercase file names and my editor, quickedit seems to save files in uppercase in nt. so the compiler can't see any file I edited. boy, this stuff just gets funner ever day....
so, it compiles, disable don't work, all I get is HUH? HUH?
big surprise here...
USA #15
Did you make sure to follow step 5? To use cedit?
#16
cedit says command unknown and this is in the log.
BUG: Error locating do_disable in symbol table. Illegal seek.
BUG: fread_command: Function do_disable not found for disable
USA #17
Did you remember to add the correct line to mud.h for do_disable, and did a clean compile?
#18
ah ha, ok works now. great mod for muds. thanks.
hmm, maybe I should add what I learned to the text file.
we just lua-ized a smaug code mod.
now works on SmaugFuss Lua 1.8!
USA #19
umm unless you did something to the code that we aren't aware of, nothing you did lua-ized it.