Re: Problem with a check using dg_events.

From: Thomas Arp (t_arp@stofanet.dk)
Date: 09/09/02


Answer below.

From: "Mathew Earle Reuther" <graymere@zipcon.net>
> I'm trying to make and if else statement based upon a condition which may
> or may not exist in an event structure.  So, for example, I have an event
> structure like so:
>
>
> struct growling_tummy_event_obj {
>   struct char_data *ch;         /* person who has tummy problem */
>   int severity;                 /* how bad is the problem? *?
> };
>
>
> So In my if else, it looks like so:
>
>
>   /* Find out how bad it is and tell them */
>   if (GET_TUMMY_RUMBLING_EVENT(ch)) {
>     if (ch->tummy_rumbling_event->severity >= 5 )
>       send_to_char(ch, "You feel like your belly may burst!!\r\n");
>     else {
>       send_to_char(ch, "Your tummy aches a bit.\r\n");
>     }
>   }
>
> So, the problem is that it says that the structure has no member named
> severity.

There aren't. GET_TUMMY_RUMBLING_EVENT(ch) is an event struct:

struct event {
  EVENTFUNC(*func);
  void *event_obj;
  struct q_element *q_el;
};

You need to reference the *event_obj in this structure, to get to the
severity var.

> There is no actual structure NAMED "tummy_rumbling_event", just
> tummy_rumbling_event_obj and the tre created from it by event_create . . .

tummy_rumbling_event is an EVENTFUNC(), right ?

> How do I reference the information in the events?
>
I must admit, I never thought of this before. event_obj is a structure
to be used by the eventfunc, primarily. However, you should be able to
reference a part of the event_obj like this:

/* temp var to make the line fit the wrap. */
void *temp = GET_TUMMY_RUMBLING_EVENT(ch)->event_obj;
((struct growling_tummy_event_obj *)temp).severity

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT