Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Aransus

Pages: 1 [2]
16
General / Forge is fun, help!
« on: September 27, 2006, 09:18:21 pm »
A few quick points...




  • Move the function prototypes up to the top of the file, right after the inherits. You've already got one prototype there, just slap the rest there too.

  • You're missing a "; at the end of a tmp += line in ThrustingMenu(), and a ; at the end of a tmp += line in MacesMenu()

  • Looks like you're trying to define a bunch of functions and stuff -inside- do_forge_str(), no need for that. You can call the main menu from do_forge_str(), and have the menus handle things from there

  • You've got two separate definitions of can_forge_str(), and I'm not sure why you've got an object as an argument. I'd say just have one, can_forge_str( string str );

  • I'm not sure where you're getting validate() from, but you'll need to either write a validate() function or include/inherit from somewhere that has it defined

  • In Menu(), the 'menu' variable doesn't seem to have a purpose. Seems like you could just run the switch with the str argument passed to the function. A specific case for "main" doesn't seem necessary either, since by default you're going to the main menu

  • Menu() and process_input() seem to serve the same purpose. You should be able to eliminate one of the two. The other could be called from do_forge_str(), and then from the input_to() calls in each Menu function





Ok, I guess that was more than a few quick points, meh. Hopefully it's not totally garbled uselessness! Good luck getting it running! :P



-- Aransus

17
General / functions update broke.
« on: September 24, 2006, 08:57:23 pm »
It's not really specifying a type, it's declaring a variable. So you can use...



code:
string item, *list = ({ "lemur", "chimp" });
foreach( item in list ) { write( item ); }




or



code:
string *list = ({ "lemur", "chimp" });
foreach( string item in list ) { write( item ); }




If you're familiar with for loops, it's very similar to the difference between:



code:
for( int i=0; i < blah; i++ )




and



code:
int i;
for( i = 0; i < blah; i++ )




-- Aransus

18
General / functions update broke.
« on: September 24, 2006, 12:31:26 pm »
TC, give this a shot. It may clear up a couple things, I've tried to comment the logic behind the code so it makes sense. Even if it doesn't do exactly what you want, you should be able to get there from here.



LPC code:
#include <lib.h>
#include <message_class.h>

inherit LIB_DAEMON;

mixed cmd(string args);
string GetHelp(string str);

mixed cmd(string str)
{
object obj;
string argstr, funcstr;
int i;
mixed *list;
string *list2 = ({ });
if (!str||str=="")
{
return "Syntax: functions <file>";
}
if (!file_exists(str))
{
return "Couldn't find "+str+".";
}
obj=load_object(str);
list=functions(obj, 1);

// For each function array in the list...
foreach( array func in list ) {
  argstr = "";

  // The second element of functions() tells you how many args you have.
  // So we can construct an argument string using that information.
  for( i=0; i < func[1]; i++ ) {

    // The number of arguments will always be correct, but have a peek
    // at the man file on functions(). If the 'save_types' pragma isn't
    // defined in the file for the object you're checking, argument types
    // won't be available. To avoid all those unsightly 0's in the func
    // list, we can do this...
    if( func[3+i] )
      argstr += func[3+i] + ", ";
    else
      argstr += "ARG, ";
  }

  // This just gets rid of the trailing ", " in the argstring ;)
  if( i ) argstr = argstr[0..strlen(argstr)-3];

  // Now that we have an argument string, we can combine it with the return
  // type and function name to make a function string.
  funcstr = sprintf("%s%s (%s)", func[2], func[0], argstr);
  list2 += ({ funcstr });
}

// Now that list2 contains an array of function strings, we can sort
// and page it.
return this_player()->eventPage( sort_array(list2, 1) );
}

string GetHelp(string str)
{
return "name: functions.\n"
"syntax: functions <file>\n\n"
"Description: Will return all known functions in the specified file.\n\n"
"Coded by ~~TheCreator~~ on 09-23-06";
}




-- Aransus

19
General / Yes/No in Teach verb
« on: September 20, 2006, 08:09:24 am »

A couple of things to keep in mind if you're converting from classes to mappings...



Definition:



(class) class teach this_session;

(mapping) mapping this_session = ([ ]); (not mapping teach)



Manipulation:



(class) this_session->Invited -= ({ who });

(mapping) this_session["Invited"] -= ({ who });



That's not going to fix everything, but it's a couple things worth noting for now. If you don't initialize the mappings, you'll get funky errors when you try to manipulate them.



-- Aransus


20
General / Modified Skill Delays, with multiple skills
« on: September 14, 2006, 08:13:40 am »

Hey Tig,



The problem you're having is that create() is only getting called when a new player object is created. So on an existing player, create() isn't running and the skill_delays mapping isn't getting initialized. Try creating a new character, that code will work fine and you'll get no errors.



If you want the skilldelay.c create() function to be called every time a player logs in, you could always add skilldelay::create() to Setup() inside /lib/player.c.



While that will eliminate the error you posted, I'm not sure if it'll end up doing exactly what you want (or doing it in the best way). In any case, I hope this helps a bit :).



Edit: FWIW, you might consider moving the call of skilldelay::heart_beat() from /lib/living.c to /lib/combat.c. If you add to living.c, you have to define a new heart_beat() function solely so that it can call 2 inherited heart_beat()'s. Putting the call inside combat.c seems a bit neater that way. Eh, just a thought :P.



-- Aransus


Pages: 1 [2]