Jump to content

Setting an active zone to current zone


Chaman Calle

Recommended Posts

I am doing a Wherigo with the urwigo but have a problem with the active zones. I have a random selection of zone. Then, you use an object that calls a funtion to dig. If you are in the correct area, you find a treasure. If not, you don't find anything. However, the problem comes when I use the "compare" function to see if the player is inside the active zone. The active zone is not the one "chosen" to have the treasure, and don't know why.

 

Any help will be great. Thanks in advise.

post-5964721-028219900 1459201671_thumb.png

post-5964721-059787400 1459201678_thumb.png

Link to comment

I don't know, what "CurrentZone" is. To see, what Urwigo use for this, you have to look into the source code of your cartridge. "CurrentZone" isn't part of the Wherigo definition.

 

So it is perhaps better to save the treasure zone to a variable (when creating it) and check, if the player is in this treasure zone.

 

Btw. you set only one zone active. With this, the player sees always only one zone. The other zone isn't used.

Link to comment

There's a list of items to select, such as zones, player, function, tasks... And there's a menu for "current objects". Inside this menu, there are options for current zone, current item, current task, and so on.

 

The Wherigo will have 10 zones where you can dig, and one is selected randomly. You play a hot/cold game in order to find the zone where you have to dig. A simple hot/cold with just 1 area is simple to program (distance to area, and select the area in play), but the problem begins when the area is not defined by the user and it is selected randomly. I don't know how to say to the cartridge "I want to use this zone". I thought that with that option of "current zone" the problem should be solved because the randomly select area is the only active, but it doesn't work properly.

Link to comment

The problem is, that a player could be inside of moire than one zone. That's the case, if the zone are overlap.

 

I made a small cartridge with 4 zones to show you, how it could be done. I assume, that there are more than this solution for the problem, but this was the first I get. You have 4 zones (Zone A - D) and a shovel to dig inside of the zones.

 

If you have any questions or problems, don' hesitate to ask.

 

Best regards,

Dirk (Charlenni)

Treasure.zip

Link to comment

I looked into it. CurrentZone is only a string, which holds the name of a zone. I didn't see, how it is set to another zone than the first one. I have to investigate this further.

 

Regarding the distance: this is only a check for the State of the zone. In the example it would be 'treasureZone.State == "Proximity"'. "Proximity" could be although "Inside", "Distant" or "NotInRange". So you could use a "Lua user expresion" to reproduce this.

Link to comment

Here is the definition of how current objects work according to yourself:

 

"CurrentObject represents a zone/item/... for which is the code executing. It is not useful in classic OnEnter, OnExit, ... handlers for objects. It is intended to be used in user functions, that are reused between different objects. Lets assume you have zoneA and zoneB and in OnEnter handler both call function myFunction. CurrentObject will represent zoneA or zoneB, depending from where the function has been called."

Link to comment

Final step: I have to set some messages for the "random area", like a reverse Wherigo, forthe distant and proximity areas. However, the target of the "distance to a zone" expression doesn't work with variables. Is there any other way than setting 10 "if" condition for every area? I set the "contains" LUA expression, but don't know if there is any other for that conditions.

 

Thanks in advise :)

Link to comment

If your trying to simplify the code for each zone you could create a function and do a function call for each zone of the same code. I am not sure I am understanding the problem 100% though.

 

In terms of the "distance to zone" function. This actually does work with variables. Create a "set function." Within the set function have a compare statement with one side be the variable and the other side be a numeric operation. You will need to pull the distance to target to within the numeric operation and then set the multiplier to 1. Johnny65 posted about this a couple years ago and if you search his forum posts there is one relating to how to set up the distance to target function in urwigo.

 

Another option, is you could use the proximitiy setting for each zone and create a series of nested zones that would work as proximity rings. I did this once to create a hot and cold Wherigo. One ring was at 300 ft, another at 200, 100 ect. If a player leaves a ring then they get a message they are getting colder. If the player enters the ring then they get a message that they are getting warmer.

Link to comment

The way you play this Wherigo is:

> The cartridge selecs a random area over 10 possibilities.

> You have an item tha allows you to dig.

> If you are in the area and you use the item, you find a treasure. If not in the area, there's a message telling you how far are you from the area (distant, in proximity, out).

 

As you can see at the picture, there's a LUA expresion for the "inzone", but don't know if there is similar for the other functions (in proximity and distant).

 

I don't want to set a function with a variable and compare 10 possible solutions, doing 10 copy-paste (one for each area) as the image shown.

Link to comment

The function in Wherigo you search is Wherigo.VectorToPoint(). If you want the correct distance to the treasure zone, you should use

math.floor((Wherigo.VectorToPoint(Player.ObjectLocation, treasureZone.OriginalPoint):GetValue "m") + 0.5)

Details:

Wherigo.VectorToPoint(Player.ObjectLocation, treasureZone.OriginalPoint)

returns a distance object between player location and the variable treasureZone, which contains the treasure zone ;)

Wherigo.VectorToPoint(Player.ObjectLocation, treasureZone.OriginalPoint):GetValue "m"

returns the value of a Distance object in meters. The rest (math.floor(x+0.5)) formats the distance, so that you have a integer value without decimals.

 

I added this in the example (see Shovel.Dig).

Treasure.zip

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...