Author Topic: MudOS/FluffOS Parsing Question  (Read 2259 times)

Offline Holyavenger

  • Friend
  • **
  • Posts: 92
    • View Profile
MudOS/FluffOS Parsing Question
« on: March 23, 2013, 12:25:26 AM »
A little background, In 1999/2000, I talked to a Developer named Scatter and he had a mighty coder named about their lima derivative they were running.

In the end, because the muds were were creating where to appeal to non-english users. We wanted the ability to use verbs and local commands (add_actions).

Scatter modified this file /driver/func_spec.c, I think near the #ifndef add_action area
Code: [Select]

#include "spec.h"

#include "op_spec.c"
 * This file specifies types and arguments for efuns.
 * An argument can have two different types with the syntax 'type1 | type2'.
 * An argument is marked as optional if it also takes the type 'void'.
 * Comment out the efuns that you do not want.  Be careful not to comment
 * out something that you need.
 * The order in which the efuns are listed here is the order in which opcode
 * #'s will be assigned.  It is in your interest to move the least frequently
 * used efuns to the bottom of this file (and the most frequently used
 * ones to the top).  The opcprof() efun could help you find out which
 * efuns are most often and least often used.  The reason for ordering
 * the efuns is that only the first 255 efuns are represented using
 * a single byte.  Any additional efuns require two bytes.

#define OR_BUFFER
#define OR_BUFFER | buffer

/* These next few efuns are used internally; do not remove them.
 * The leading _ is used to keep track of which efuns should exist,
 * but not be added to the identifier lookup table.
 * These names MUST exist, and may either be real efuns, or aliases
 * for another efun.  For example, one could remove clone_object
 * above, and change the internal one to:
 * object _new(string, ...);
/* used by X->f() */
unknown _call_other(object | string | object *, string | mixed *,...);
/* used by (*f)(...) */
mixed _evaluate(mixed, ...);
/* default argument for some efuns */
object _this_object();
/* used for implicit float/int conversions */
int _to_int(string | float | int OR_BUFFER);
float _to_float(string | float | int);
/* used by new() */
object _new(string, ...);

unknown call_other _call_other(object | string | object *, string | mixed *,...);
mixed evaluate _evaluate(mixed, ...);
#ifdef COMPAT_32
mixed funcall _evaluate(mixed, ...);
object this_object _this_object();
int to_int _to_int(string | float | int OR_BUFFER);
float to_float _to_float(string | float | int);
object clone_object _new(string, ...);

function bind(function, object);
object this_player(int default: 0);
object this_interactive this_player( int default: 1);
object this_user this_player( int default: 0);
mixed previous_object(int default: 0);
object *all_previous_objects previous_object(int default: -1);
mixed *call_stack(int default: 0);
int sizeof(mixed);
int strlen sizeof(string);
#ifdef USE_ICONV
int strwidth(string);
int strwidth sizeof(string);
void destruct(object default: F__THIS_OBJECT);
string file_name(object default: F__THIS_OBJECT);
string capitalize(string);
string *explode(string, string);
mixed implode(mixed *, string | function, void | mixed);
int call_out(string | function, int,...);
void call_out(string | function, int,...);
int member_array(mixed, string | mixed *, void | int, void | int);
int input_to(string | function,...);
int random(int);
void defer(function);

object environment(void | object);
object *all_inventory(object default: F__THIS_OBJECT);
object *deep_inventory(object | object * | function, void|function default: F__THIS_OBJECT);
object first_inventory(object|string default: F__THIS_OBJECT);
object next_inventory(object default: F__THIS_OBJECT);
void say(string, void | object | object *);
void tell_room(object | string, string | object | int | float, void | object | object *);
object present(object | string, void | object);
void move_object(object | string);

void add_action(string | function, string | string *, void | int);
string query_verb();
int command(string);
int remove_action(string, string);
int living(object default: F__THIS_OBJECT);
mixed *commands();
void disable_commands();
void enable_commands();
void set_living_name(string);
object *livings();
object find_living(string);
object find_player(string);
void notify_fail(string | function);
void set_this_player(object | int);
void set_this_user set_this_player(object | int);

string lower_case(string);
string replace_string(string, string, string,...);
int restore_object(string, void | int);
mixed save_object(string | int | void, void | int);
string save_variable(mixed);
mixed restore_variable(string);
object *users();
mixed *get_dir(string, int default: 0);
int strsrch(string, string | int, int default: 0);
#ifdef COMPAT_32
int strstr strsrch(string, string | int, int default: 0);

/* communication functions */

void write(mixed);
void tell_object(object, string);
void shout(string);
void receive(string OR_BUFFER);
void message(mixed, mixed, string | string * | object | object *,
                  void | object | object *);

/* the find_* functions */

    object find_object(string, int default: 0);
    object load_object find_object(string, int default: 1);
    int find_call_out(int|string);
    int find_call_out(string);

/* mapping functions */

    mapping allocate_mapping(int | mixed *, void | mixed);
    mixed *values(mapping);
    mixed *keys(mapping);
#ifdef COMPAT_32
    mapping map_delete(mapping, mixed);
    mapping m_delete map_delete(mapping, mixed);
    mixed *m_values values(mapping);
    mixed *m_indices keys(mapping);
    void map_delete(mapping, mixed);

    mixed match_path(mapping, string);

/* all the *p() type functions */

    int clonep(mixed default: F__THIS_OBJECT);
    int intp(mixed);
    int undefinedp(mixed);
    int nullp undefinedp(mixed);
    int floatp(mixed);
    int stringp(mixed);
    int virtualp(object default: F__THIS_OBJECT);
    int functionp(mixed);
#ifdef COMPAT_32
    int closurep functionp(mixed);
    int pointerp(mixed);
    int arrayp pointerp(mixed);
    int objectp(mixed);
    int classp(mixed);
    string typeof(mixed);

    int bufferp(mixed);
    buffer allocate_buffer(int);

    int inherits(string, object default: F__THIS_OBJECT);
    void replace_program(string);

    mixed regexp(string | string *, string, void | int);
    mixed *reg_assoc(string, string *, mixed *, mixed | void);
    mixed *allocate(int, void | mixed);
    mixed *call_out_info();

/* 32-bit cyclic redundancy code - see crc32.c and crctab.h */
    int crc32(string OR_BUFFER);

/* commands operating on files */

    mixed read_buffer(string | buffer, void | int, void | int);
    int write_buffer(string | buffer, int, string | buffer | int);
    int write_file(string, string, int default:0);
    int rename(string, string);
    int write_bytes(string, int, string);

    int file_size(string);
    string read_bytes(string, void | int, void | int);
    string read_file(string, void | int, void | int);
    int cp(string, string);

    int link(string, string);
    int mkdir(string);
    int rm(string);
    int rmdir(string);

/* the bit string functions */

    string clear_bit(string, int);
    int test_bit(string, int);
    string set_bit(string, int);
    int next_bit(string, int);

    string crypt(string, string | int);
    string oldcrypt(string, string | int);

    string ctime(int|void);
    int exec(object, object);
    mixed *localtime(int);
    string function_exists(string, void | object, void | int);

    object *objects(void | string | function);
    string query_host_name();
    int query_idle(object);
    string query_ip_name(void | object);
    string query_ip_number(void | object);
#ifndef NO_SNOOP
    object snoop(object, void | object);
    object query_snoop(object);
    object query_snooping(object);
    int remove_call_out(int | void | string);
    int remove_call_out(void | string);
    void set_heart_beat(int);
    int query_heart_beat(object default:F__THIS_OBJECT);
    void set_hide(int);

#ifndef NO_RESETS
    void set_reset(object, void | int);

#ifndef NO_SHADOWS
    object shadow(object, int default: 1);
    object query_shadowing(object);
    mixed *sort_array(mixed *, int | string | function, ...);
    void throw(mixed);
    int time();
    mixed *unique_array(mixed *, string | function, void | mixed);
    mapping unique_mapping(mixed *, string | function, ...);
    string *deep_inherit_list(object default:F__THIS_OBJECT);
    string *shallow_inherit_list(object default:F__THIS_OBJECT);
#ifdef COMPAT_32
    string *inherit_list deep_inherit_list(object default:F__THIS_OBJECT);
    string *inherit_list shallow_inherit_list(object default:F__THIS_OBJECT);
    void printf(string,...);
    string sprintf(string,...);
    int mapp(mixed);
    mixed *stat(string, int default: 0);

 * Object properties
    int interactive(object default:F__THIS_OBJECT);
    int has_mxp(object default:F__THIS_OBJECT);
    int has_zmp(object default:F__THIS_OBJECT);
    void send_zmp(string, string *);
    int has_gmcp(object default:F__THIS_OBJECT);
    void send_gmcp(string);
    string in_edit(object default:F__THIS_OBJECT);
    int in_input(object default:F__THIS_OBJECT);
    int userp(object);
#ifdef COMPAT_32
    int query_once_interactive userp(object);

#ifndef NO_WIZARDS
    void enable_wizard();
    void disable_wizard();
    int wizardp(object);

    object master();

 * various mudlib statistics
    int memory_info(object | void);
    mixed get_config(int);

#ifdef PRIVS
/* privledge functions */
    string query_privs(object default:F__THIS_OBJECT);
    void set_privs(object, int | string);
#endif                          /* PRIVS */

    int get_char(string | function,...);
    object *children(string);

    void reload_object(object);

    void error(string);
#ifdef COMPAT_32
    void raise_error error(string);
    int uptime();
    int strcmp(string, string);

#ifndef WIN32
#if (defined(RUSAGE) || defined(GET_PROCESS_STATS) || defined(TIMES))
    mapping rusage();
#endif                          /* RUSAGE */

    void flush_messages(void | object);

#ifdef OLD_ED
    void ed(string | void, string | int | void, string | int | void, int | void, int | void);
    string ed_start(string | void, int | void, int | void);
    string ed_cmd(string);
    int query_ed_mode();

    string cache_stats();

    mixed filter(string | mixed * | mapping, string | function, ...);
    mixed filter_array filter(mixed *, string | function, ...);
    mapping filter_mapping filter(mapping, string | function, ...);

    mixed map(string | mapping | mixed *, string | function, ...);
    mapping map_mapping map(mapping, string | function, ...);
    mixed *map_array map(mixed *, string | function, ...);
 * parser 'magic' functions, turned into efuns
    string malloc_status();
    string mud_status(int default: 0);
    void dumpallobj(string | void);

    string dump_file_descriptors();
    string query_load_average();

#ifndef NO_LIGHT
/* set_light should die a dark death */
    int set_light(int);

    string origin();

/* the infrequently used functions */

    int reclaim_objects();

    int set_eval_limit(int);
    int reset_eval_cost set_eval_limit(int default: 0);
    int eval_cost set_eval_limit(int default: -1);
    int max_eval_cost set_eval_limit(int default: 1);
#ifdef COMPAT_32
    int get_eval_cost set_eval_limit(int default: -1);

    void set_debug_level(int|string);
    mapping debug_levels();
    void clear_debug_level(string);

#if defined(OPCPROF) || defined(OPCPROF_2D)
    void opcprof(string | void);

    mapping *function_profile(object default:F__THIS_OBJECT);

    int resolve(string, string|function);
#ifdef USE_ICONV
    int set_encoding(string);
    string to_utf8(string, string);
    string utf8_to(string, string);
    int *str_to_arr(string);
    string arr_to_str(int *);
    void act_mxp();
    void websocket_handshake_done();
    void request_term_type();
    void start_request_term_type();
    void request_term_size(void | int);
/* shutdown is at the end because it is only called once per boot cycle :) */
    void shutdown(void | int);

Within the library, I think it was /lima/lib/secure/simul_efun/userfuncs.c
Code: [Select]
/* Do not remove the headers from this file! see /USAGE for more info. */

#include <mudlib.h>
#include <daemons.h>
#include <security.h>

string base_name(mixed val);

nomask object *bodies()
    return users()->query_body() - ({ 0 });

nomask object this_body()
    object u = this_user();

    return u ? u->query_body() : 0;

varargs nomask object find_user(string str, int even_linkdead)
    object *choices;

    if ( even_linkdead )
choices = children(USER_OB);
choices = users();
    choices = filter(choices, (: $1->query_userid() == $(str) :));

    if ( sizeof(choices) )
return choices[0];

    return 0;

varargs nomask object find_body(string str, int even_linkdead)
    object u = find_user(str, even_linkdead);

  if(!str || str==""){return 0;}
    if (u && (u = u->query_body())) return u;
    foreach (object b in bodies()) {
if (b->query_nickname() == str)
    return b;
    return 0;

nomask int wizardp(mixed m)
    if ( objectp(m) )
m = m->query_userid();

    if ( stringp(m) )
return SECURE_D->query_is_wizard(m);

    return 0;

nomask int adminp(mixed m)
    if ( !m )
m = this_user()->query_userid();
    else if ( objectp(m) )
m = m->query_userid();

    return member_array(m, SECURE_D->query_domain_members("admin")) != -1;

nomask int user_exists(string user)
    return USER_D->user_exists(user);

//:FUNCTION get_user_variable
// Get a variable value from the current user's shell object.
nomask mixed get_user_variable(string varname)
    object shell;

#define UNDEFINED_VALUE ([])[0]

    if ( !this_user() )
    shell = this_user()->query_shell_ob();
    if ( !shell )
    return shell->get_variable(varname);

//:FUNCTION set_this_user
//Works like set_this_player().  It was added for consistancies sake.
nomask void set_this_user(object ob)

And removing the /lima/lib/secure/badness file that stopped the driver from running with a non-standard option

I would like to offer this particular mud to other languages and need the ability temporarily remove the straigtjacket.

Point: I believe that  there is opportunity still if you appeal to multiple cultures. For example brail, spanish, chinese and or russian would appeal to a demographic that otherwise would be left untapped. These people could literally bring back old technology. All you have to do is use multi language descriptions.

all that is left if getting the parser to behave and get a few non english coders.

Does any one have a solution to adding these add_actions commands back. Should I rip the simulefuns from LIL for add_action. or whats the easiest way to re-add the feature I need?

Any coders know how this wizardry was originally done for me by Scatter/Musashi to modiefy function spec? and the other three files or whats the solve other then "use something else".

Back in 1999 Loriel was helping us out and I discared the perversion of lima with add_actions because I didnt want to slight Dave. I lost the modified files over the years.

Offline coupdeforce

  • Acquaintance
  • *
  • Posts: 1
    • View Profile
Re: MudOS/FluffOS Parsing Question
« Reply #1 on: September 06, 2014, 06:07:35 AM »
You might be able to do what you want without needing to get add_actions to work.  It's possible to use functions in add_item, like this:

Code: [Select]
void search_desk();

int desk_has_file = 1;

void setup()
   add_item("desk", ([ "look" : "The desk has all kinds of papers and files spread all over it.", "search" : (: search_desk :) ]));

string search_desk()
   if (desk_has_file)
      desk_has_file = 0;

      this_body()->simple_action("$N $vsearch the desk and $vfind the missing file.");


      return " ";

   return "You don't come across anything interesting in your search of the desk.";

The functions always need to return a string that's not empty.

To be able to do this, you just need to edit the direct_verb_rule function in /obj/mudlib/simple_ob.c to look like this:

Code: [Select]
mixed direct_verb_rule(string verb, string rule, mixed args)
   string s = msgs[verb];

   if (s)
      if (stringp(s))
         return s[<1] == '\n' ? s : s + "\n";
      else if (functionp(s)) // Makes functions work in add_item!
         return evaluate(s);

   // can't use that verb on us...
   return 0;