Author Topic: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)  (Read 10471 times)

Offline paven

  • Acquaintance
  • *
  • Posts: 20
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #15 on: August 22, 2013, 09:22:34 PM »
is there an efun for  to_string(mixed str); - or is it even needed?

varargs string pad(mixed str, int len, int padchar) {
  string sp_format;

  str = to_string(str);
....

Offline FallenTree

  • BFF
  • ***
  • Posts: 484
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #16 on: August 22, 2013, 09:45:52 PM »
you could use sprintf("%O", xxx);   you can also create a simul_efun for that.

Offline paven

  • Acquaintance
  • *
  • Posts: 20
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #17 on: August 22, 2013, 10:00:00 PM »
Think I'll have to create a simul_efun

Odd that it doesn't exist already. It's been in drivers for ever (literally since the early 90's)

Offline FallenTree

  • BFF
  • ***
  • Posts: 484
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #18 on: August 22, 2013, 10:01:51 PM »
driver will auto cast it if you do something like ""+ ob

Offline Stavros

  • Acquaintance
  • *
  • Posts: 36
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #19 on: August 23, 2013, 12:47:21 PM »
You may want to try #define OLD_TYPE_BEHAVIOR... not 100% sure that's what you're running into, but when we tried to move to a modern driver, that was the one option that finally let us log in.

Offline FallenTree

  • BFF
  • ***
  • Posts: 484
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #20 on: August 23, 2013, 01:07:24 PM »
Be very careful about using anything start with OLD_* , it's all broken behavior that rarely tested. You should spend sometime try to fix it. Stick with the stock config as much as you can.

Also, don't set anything that you are not absolutely sure what it is. People has been complaining about driver broken because they look at and weird option and think, I think I need that, and get broken behavior as intended. If you are already spending time to fix old lib, fix it to the latested standard. Don't try to fix something for a broken state and left it there.

Offline paven

  • Acquaintance
  • *
  • Posts: 20
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #21 on: August 23, 2013, 01:36:42 PM »
Just out of curiousity, am I going to have to write simul_efuns for all of these?

to_array
to_struct
to_int  (nevermind, I see this one in the 'floats' efun doc)
to_float (and this one is in the 'numbers' efun doc)
to_string
to_object

Offline FallenTree

  • BFF
  • ***
  • Posts: 484
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #22 on: August 23, 2013, 03:20:08 PM »
I don't know,  Here is what I would do

create a bunch of fake simul efuns that do

mixed* to_array(mixed arg) { return arg;}
struct to_struct(mixed arg) { return arg;}
string to_string(mixed arg) { return arg;}

you get the idea, get things to compile first, and then deal with the runtime errors.

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #23 on: August 24, 2013, 03:49:06 PM »
I guess the question is... what do you actually intend to DO with all those?

to_int() and to_float() are pretty obvious and easy.

to_array()... how do you intend to use this?  If I pass it a simple type, this is just:

mixed *to_array(mixed a) { mixed *tmp; tmp[0] = a; return tmp; }

But if you pass it a mapping.. what do you want?  The keys?  The values?  Both, alternating?  An array with the mapping as it's first value?

Then there's to_object()... what exactly would this do?

If you want to pass it code and have it produce an object, that would be nice... but FluffOS doesn't currently support compiling form a string.  That's been on my wishlist for years.

And to_string()... for simple types that'd be sprintf()'s job.  But for other things, you'd need to serialize the items.  And for objects... again... there's no easy way to ensure you can always get the source code unless the driver supports keeping the source that compiled the object around.

Or am I missing something here?

Offline paven

  • Acquaintance
  • *
  • Posts: 20
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #24 on: August 26, 2013, 10:17:30 AM »
to_array() is used to convert strings and symbols to an int array that consists of the args characters
mixed * to_array(string)
mixed * to_array(symbol)
mixed * to_array(quotedarray)
mixed * to_array(mixed *)
mixed * to_array(struct)

to_object() is used to convert the argument into an object, if possible
object to_object(string arg)
object to_object(closure arg)
object to_object(object arg)
for strings, the object with a matching object_name() is returned, or 0 - like find_object()

Now, granted, I'm not sure how much these functions are used throughout all the current code in the mudlib, but I know they are supported, and I know that to_string() is used in a current simul_efun.  Recoding the simul_efun to use sprintf() is not such a big deal, but not knowing where else it is used and how much recoding would need to be redone, I was just curious as to if these efuns existed.

Offline paven

  • Acquaintance
  • *
  • Posts: 20
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #25 on: August 27, 2013, 11:59:05 AM »
I've gotten around the to_string efun by just checking stringp and returning 0 if it's not a string.

Next question, how do you call an efun directly?  Say I have a simul_efun that does some checking on the command() efun before I pass it through.

Code: [Select]
varargs int command(mixed str, mixed ob) {
  do_some_checking here, if conditions are not what I want() {
     tell_object(some_ob, "Some message\n");
     return 0;
  }

  return efun::command(str, ob);  <--- This is not working, and it's the syntax I'm used to
}

Thanks

Offline FallenTree

  • BFF
  • ***
  • Posts: 484
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #26 on: August 27, 2013, 01:33:45 PM »
that is how you call efun directly,  what errors are you getting?

(You can see examples in src/testsuite,  the code there should covers most of the syntax questions, if you see something is written there, it is likely how it should be used.)

Offline FallenTree

  • BFF
  • ***
  • Posts: 484
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #27 on: August 27, 2013, 01:34:47 PM »
Oh, BTW, command() efun only comes with #undef NO_ADD_ACTION,   it is likely you have not defined that, hence the problem.

Offline paven

  • Acquaintance
  • *
  • Posts: 20
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #28 on: August 27, 2013, 01:44:15 PM »
I do have that defined in my local_options

#undef NO_ADD_ACTION

Here's the error

Code: [Select]
WARNING: rlimit for core dump is 0, you will not get core on crash.
using config file: config
Initializing internal tables....
----------------------------------------------------------------------------
Testmud (FluffOS v3.0-alpha7.3) starting up on Linux - Tue Aug 27 14:39:45 2013


Event backend in use: epoll
/closed/simul_efun/command_efun.c line 22: Too many arguments to command before ;
No error handler for error: *Error in loading object '/closed/simul_efun/command_efun'
program: (none), object: (none), file: (none)
The simul_efun (/obj/simul_efun) and master (/obj/master) objects must be loadable.

And here's the code
Code: [Select]
varargs int command(mixed str, mixed ob)
{
  int obLevel;
  object th;

  if(ob && objectp(ob) && query_ip_number(ob) &&
     (obLevel = (int)ob->query_level()) >= 21)
  {
    if((th = this_player()) && (int)th->query_level() <= obLevel &&
       th != ob)
    {
      tell_object(th, "Yeah, No.\n");
      tell_object(ob, (string)th->query_real_name() +
                        " tried to force you to " + str +".\n");
      return 0;
    }
    if(!th) return 0;
  }
  if(!ob) ob = previous_object();
  return efun::command(str, ob);
}

Offline Tricky

  • BFF
  • ***
  • Posts: 189
  • I like what I code and I code what I like!
    • View Profile
Re: Amylaar/LPmud 3.1.2 modified mudlib on FluffOS3.0 (latest build alpha)
« Reply #29 on: August 27, 2013, 01:55:51 PM »
command only takes 1 (one) argument.

Code: [Select]
command - execute a command as if given by the object

int command( string str );

This efun is only available if NO_ADD_ACTION isn't defined.

Execute 'str' for the object this_object() as a command (matching against
add_actions and such).  The object must have called enable_commands() for
this to have any effect.
In case of failure, 0 is returned, otherwise a numeric value is returned,
which is the LPC "evaluation cost" of the command.  Bigger numbers mean
higher cost, but the whole scale is subjective and unreliable.

See also:
 add_action,
 enable_commands