05 Apr, 2007, Skol wrote in the 1st comment:
Votes: 0
Hey all, I thought I'd remembered someone making an m/r/oprog command interpreter that went in interp.c. The use was so that you could type 'pull lever' or 'flip switch' or 'unscrew lid' etc, do actions that were NOT available to do, just to trigger a program in that room (be it a room, object or mobile prog).

Anyway, I didn't find it and wrote my own, but I'm wondering if the other one I saw had a bool for 'has fired' or something along those lines.

Anyone remember who did the other one, and where it is? I'd love to compare.

This before the 'Huh?' part in interp.c after it's found there's no command, no social, matching the players input.

if (!found)
{
CHAR_DATA *mob, *mob_next;
OBJ_DATA *obj, *obj_next;
char old_arg[MSL];
sprintf (old_arg, "%s %s", command, argument);
// Ok, we're going to check the mobs in the room for an interpret trigger
for (mob = ch->in_room->people; mob != NULL; mob = mob_next)
{
mob_next = mob->next_in_room;
if (IS_NPC(mob) && HAS_TRIGGER_MOB( mob, TRIG_INTERPRET )
&& (mob->in_room == ch->in_room)/* make sure we haven't been transfered*/)
p_act_trigger (old_arg, mob, NULL, NULL, ch, NULL, NULL, TRIG_INTERPRET);
}
if (HAS_TRIGGER_ROOM(ch->in_room, TRIG_INTERPRET))
p_act_trigger(old_arg, NULL, NULL, ch->in_room, ch, NULL, NULL, TRIG_INTERPRET);
for (obj = ch->carrying; obj; obj = obj_next )
{
obj_next = obj->next_content;
if (HAS_TRIGGER_OBJ(obj, TRIG_INTERPRET))
p_act_trigger(old_arg, NULL, obj, NULL, ch, NULL, NULL, TRIG_INTERPRET);
}
for (obj = ch->in_room->contents; obj; obj = obj_next)
{
obj_next = obj->next_content;
if (HAS_TRIGGER_OBJ(obj, TRIG_INTERPRET)
&& (obj->in_room == ch->in_room)/* make sure we haven't been transfered*/)
p_act_trigger(old_arg, NULL, obj, NULL, ch, NULL, NULL, TRIG_INTERPRET);
}

}

I added the 'same room' check so that one prog doesn't fire, transfer the char, then the next in the room tries to with the char not there etc.

Comments welcome.
05 Apr, 2007, Skol wrote in the 2nd comment:
Votes: 0
Right now the code works great, you can 'addmprog 1234 interpret "unzip pants" for example, then type unzip pants and have a mob blush and say Hey! (yeah, I make my test progs silly ;p). The issue is, the mprog code doesn't do any kind of boolean to see if it's fired, so regardless of whether one prog or 20, fires, it still gets to the 'Huh?' part. When it only should if it exhausts the room, mobs, objects, and objects on the person without finding a prog that matches the argument.

I'm considering writing a p_found_trigger bool that loops first and sees if one is valid, since the p_act_trigger that the code checks with is a void and can't return a value like that.

Thoughts?
05 Apr, 2007, kiasyn wrote in the 3rd comment:
Votes: 0
change it to return a bool? ^_^
05 Apr, 2007, Skol wrote in the 4th comment:
Votes: 0
Yeah Kiasyn, that's the idea is have a boolean trigger first to see if a valid prog exists through the same criteria, then trigger the progs. But, we wouldn't want to change the p_act_trigger to a bool or it wouldn't work anymore to execute the interpreted 'prog' code.

What I was asking was if a pre-check (aka a bool like we're both talking about) would be the best way to determine if one should have fired. Have an if (fired)// blah do the loop through, else // blah say 'Huh?' etc.

I swore I saw someone do this code already, I feel like the guy who wasn't the Wright brothers going.. hm, lift… ;p Didn't feel like reinventing the wheel heh.
05 Apr, 2007, Davion wrote in the 5th comment:
Votes: 0
Maybe something like this? It works a bit differently if I remember correctly. You alias the command, 'zip' then it'd require the pants to be there.
05 Apr, 2007, Zeno wrote in the 6th comment:
Votes: 0
I think SWR has the code for what you're looking for. They're called custom progs.
05 Apr, 2007, Skol wrote in the 7th comment:
Votes: 0
I KNEW I wasn't crazy heh.

Yeah, that's what I'm thinking too Davion, add the boolean in and go. Stops the hackish 'Huh?' after they have triggered heh.

I'll take a look-see at that when I get back tonight and see if my separate bool vs this would fit best, one thing though is I do want all to fire, just have it return a TRUE if there is one valid, but I haven't looked to see if yours does that. glancing at it, it looks like it'd return the first TRUE it found (which is perfect for the bool side), then run the void to do the prog.

Anyway, typing fast, have to run, back tonight. THanks again!
0.0/7