Event Variables
Displaying 1-17 of 17 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
pthaloearth

namely event.tx and event.ty

here's the code

void openChest()
{
setzone(event.tx,event.ty,0);
settile(event.tx,event.ty,1,83);
}


this should then open the chest at the location that was just activated, correct?

It is however doing it to the event prior that was activated.

EX: I go and look into a barrel, a text box opens and says "You have found a pickle." I then go and open the chest with the above event and the barrel now transforms into an open chest...

So am I simply misunderstanding the variables or something else?

Posted on 2008-03-29 09:49:30

Swordsman

Would it be possible for you to upload a short, simple demo displaying the problem? If I could see this in action, I might be able to target the error more accurately, and give you some feedback. As it is now, I don't know what to think about this.

Posted on 2008-04-04 15:25:17

pthaloearth

I went and uploaded it.

http://www.verge-rpg.com/files/detail.php?id=722

After some more testing I've realized it is something with my code, I'm just not sure what? I'd guess it's in buttons.vc as a start, but it's just a guess.

I was working on getting the chests to work and then building the first town before releasing anything *shrugs* so here's a pre-demo I suppose.

After I get some of the glitches out I plan on getting a real demo out for you all.

Posted on 2008-04-05 10:56:30

Swordsman

Alright, I downloaded it, threw in maped3, took a look, and dug around your code a bit.

I think... you should try to structure your code better. You'll get better at that with time though. The demo looks pretty nice.

I think I may have found your problem... Look at the entity data for Heda the Giant Hare, and the zone data for Zone 5 (sword).

They're both bound to the function event_6 in town.vc.

In fact, I don't see event_5 being called anywhere, which is pretty bizarre, since it seems to be calling it for the magic sword event.
Anyhow, if you try giving your zone/entity scripts actual names instead of numbers, it'll probably clear up stuff like this :)

I'm probably missing some stuff, I'm going to keep looking, I'll let you know what I find.

edit:

Changing event_6 to event_5 for the zone in question fixes the problem of the chest claiming to be Heda the Hare. Nothing on the correct tile switch yet though.

Posted on 2008-04-05 22:05:55 (last edited on 2008-04-06 03:30:57)

Swordsman

Hmm, well...

This page in the V3 Manual seems to be a outdated. The comment at the bottom claims that event.tx/ty relate to the last event adjacently activated instead of the one last walked over, but it seems to be the reverse now. (I never trusted those variables anyhow)

If you make the chests through code instead, you could just write the proper tx/ty to your chest-struct array (chests[MAXCHESTS] in item.vc), instead of relying on event.tx/ty.

It might be a bit of a pain, but I think that's the proper way to do it.

Also, you might consider using dictionaries instead of pre-defined arrays with size constants. That might make things a little easier.

Posted on 2008-04-06 03:50:56

pthaloearth

thanks for looking swordsman,

well that explains it then. Old docs.

The code works without flaw when the event.tx and event.ty are not used, that's tested in another event in the same map so I knew that. It was just a nice thought to not have to type the x and y out for every single chest in the game.

I also actually got the idea from the boards, it was suggested a while back that it would work that way.

I could try the dictionary but I'm more comfortable with a array. Perhaps latter I'll switch to them? Are they really that much better? What are the advantages?

Posted on 2008-04-06 09:34:37

pthaloearth

OH, I put a note into the docs on that page so others don't go through all the effort we did as well!

Posted on 2008-04-06 09:37:32

Overkill

Actually.

I just tested this, on three separate builds. The 2005 release, the 2007 release, and a fairly recent 2008 build. For all of them, adjacent activation with event.tx and event.ty were doing as documented.

For instance, this is a snippet of door opening code used in Rubbish Rogue. It removes the obstruction at the activated tile, and the two door tiles for that door zone are dropped.


void OpenDoor()
{
if (GetObs(event.tx, event.ty))
{
// "Screak!" went the hinges.
SetTile(event.tx, event.ty, 1, 0);
SetTile(event.tx, event.ty - 1, 2, 0);
SetObs(event.tx, event.ty, 0);
}
}


I'll test your code shortly though!

Posted on 2008-04-06 11:52:59

Overkill

Wow... That's interesting. Yeah, I have no idea what's going on there. All I know is it doesn't happen with my test map, yet it does with yours? :o

Sounds like a bug. Anyway. Needs fixing rather than redocumenting. The intended behaviour for these variables are the ones documented. Any behaviour besides that is a mistake.

Posted on 2008-04-06 12:17:29

Swordsman

Hmm. I added another adjacently activated zone to your town.map, and


SetTile(event.tx, event.ty, 0, 1);


Works perfectly in the test event. If I activate that zone and then head back to the chest containing the magic sword, and activate that zone, it puts the empty chest tile on the test event tile instead. However, if I walk back over zone 1 after activating the test event, event.tx/ty still seem to get registered to that.

This means...

1. event.tx/ty can get set to a non-adjacently activated tile.

2. The magic sword chest isn't registering to event.tx/ty.

The first point isn't too important, but it conflicts with the docs and what OverKill said, so it's still a bug.

The second point... I don't know what's causing that yet. I'm kinda suspecting it might have something to do with the way you're doing custom controls, but I'm not sure yet.

Posted on 2008-04-06 20:31:09

Swordsman

This is really weird. If I make a new zone which seems to be identical to yours just a few tiles away, it does everything exactly as it should. Maybe you're doing something with the chests through code somewhere?

edit:

Another odd thing, I noticed I can activate the cross to heal myself through adjacent activation, but adjacent activation for zone 2 is disabled.

Posted on 2008-04-06 20:57:35 (last edited on 2008-04-06 21:04:17)

pthaloearth

That adjacent activation thing's due to the way the buttons search for a zone first and then if no zone if found it uses the equipped item.

The problem seems related to that! If I do not hook those buttons, it works. The getZone function seems to grab zone 1 and then zone 5. Am I heading in a logical direction?

this is the code the buttons are hooked to:

void useEquipedItem0()
{
switch(entity.face[player])
{
CASE 1: if(GetZone(entity.x[player]>>4,entity.y[player]>>4-1)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4,entity.y[player]>>4-1)));
else useItem(itemEquiped[0]);//use item

CASE 2: if(GetZone(entity.x[player]>>4,entity.y[player]>>4+1)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4,entity.y[player]>>4+1)));//call zone event
else useItem(itemEquiped[0]);//use item

CASE 3: if(GetZone(entity.x[player]>>4-1,entity.y[player]>>4)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4-1,entity.y[player]>>4)));//call zone event
else useItem(itemEquiped[0]);//use item

CASE 4: if(GetZone(entity.x[player]>>4+1,entity.y[player]>>4)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4+1,entity.y[player]>>4)));//call zone event
else useItem(itemEquiped[0]);//use item
}
}

void useEquipedItem1()
{
switch(entity.face[player])
{
CASE 1: if(GetZone(entity.x[player]>>4,entity.y[player]>>4-1)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4,entity.y[player]>>4-1)));//call zone event
else useItem(itemEquiped[1]);//use item

CASE 2: if(GetZone(entity.x[player]>>4,entity.y[player]>>4+1)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4,entity.y[player]>>4+1)));//call zone event
else useItem(itemEquiped[1]);//use item

CASE 3: if(GetZone(entity.x[player]>>4-1,entity.y[player]>>4)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4-1,entity.y[player]>>4)));//call zone event
else useItem(itemEquiped[1]);//use item

CASE 4: if(GetZone(entity.x[player]>>4+1,entity.y[player]>>4)!=0) callFunction("event_"+str(GetZone(entity.x[player]>>4+1,entity.y[player]>>4)));//call zone event
else useItem(itemEquiped[1]);//use item
}
}

Posted on 2008-04-07 08:28:18

pthaloearth

just to note:

useEquipedItem0() finds zone 1 then 5 (from one key press no less)

useEquipedItem1() finds zone 1 only

Posted on 2008-04-07 08:36:35

Overkill

Problem found!

You're using CallFunction(). All this does is call a function by that name. If you manually call functions, instead of using the map engine, the event struct will not be changed. Thus it is YOUR duty to populate event.tx, event.ty with the proper values if you're calling things manually.

Also, why aren't you using zone.event[zone_index]? It's more flexible. And string-calling syntax sugar? Much prettier!

Here, I rewrote your code slightly, not tested. But should work.

// Equipped has two p's! Not one! :D
void useEquippedItem0()
{
int x, y, zoneIndex;

// Contrary to what you think, bitshifting will probably not speed things up much in VC.
// It also makes things harder to read.
// I also saw a lot of repeated code, made this less
// bug prone by having the calls after the zone detection.
x = entity.x[player] / 16;
y = entity.y[player] / 16;
switch(entity.face[player])
{
case 1: y--;
case 2: y++;
case 3: x--;
case 4: x++;
}

zoneIndex = GetZone(x, y);
if(zoneIndex)
{
// Initialize event information
event.tx = x;
event.ty = y;
event.zone = zoneIndex;
event.entity = player;

// Call zone event using string-calling!
zone.event[zoneIndex]();
}
else
{
// Use item
useItem(itemEquipped[0]);
}
}

Posted on 2008-04-07 16:07:46 (last edited on 2008-04-07 16:49:17)

pthaloearth

I wasn't aware of any of the zone or event vars until updating my verge version and docs last week. My copy was pretty old, the docs I had were extremely old.

Much thanks, overkill.

Posted on 2008-04-08 08:15:53

pthaloearth

I tried your code overkill, it gives me an error but only when searching down or left, searching up and right work as expected. Any clues as to how to fix this?

unknown HVAR(34) (set 56):
useEquippedItem

Posted on 2008-04-08 19:45:45

Overkill

Oh hm, I guess the event variables are readonly! D:

I didn't know. So uhm, I guess a way to get around this for now is to make it so you just have similar variables or something!

int event_was_userside; // flag to decide whether to use event_tx instead of event.tx, etc.
int event_tx, event_ty, event_entity, event_zone;
string event_param;

void EventGetInfo()
{
if(!event_userside)
{
event_tx = event.tx;
event_ty = event.ty;
event_entity = event.entity;
event_zone = event.zone;
event_param = event.param;
}
}


Then in your calling code:

// Equipped has two p's! Not one! :D
void useEquippedItem0()
{
int x, y, zoneIndex;

// Contrary to what you think, bitshifting will probably not speed things up much in VC.
// It also makes things harder to read.
// I also saw a lot of repeated code, made this less
// bug prone by having the calls after the zone detection.
x = entity.x[player] / 16;
y = entity.y[player] / 16;
switch(entity.face[player])
{
case 1: y--;
case 2: y++;
case 3: x--;
case 4: x++;
}

zoneIndex = GetZone(x, y);
if(zoneIndex)
{
// Initialize event information
event_userside = 1;
event_tx = x;
event_ty = y;
event_zone = zoneIndex;
event_entity = player;

// Call zone event using string-calling!
zone.event[zoneIndex]();

event_userside = 0;
}
else
{
// Use item
useItem(itemEquipped[0]);
}
}


Then in your event:

void MahEvent()
{
EventGetInfo();
MessageBox("Triggered zone " + str(event_zone) + " with entity " + str(event_entity) + " at (" + str(event_tx) + ", " + str(event_ty) + ")!");
SetTile(event_tx, event_ty, 0, 0);
}


That's sort of ugly though, yeah...

Posted on 2008-04-09 15:58:08 (last edited on 2008-04-09 16:05:39)


Displaying 1-17 of 17 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.