+northernpenguin Posted February 2, 2009 Share Posted February 2, 2009 I'm working on a 'game' Wherigo, and I'm wondering if there is an easy way to determine if another object is in the current zone without hard coding the zone itself into the action. I want to have a scenario where two objects cannot be in the same place at the same time, across several different zones. Rather than hard coding everything (and having mountains of repetitive code) I'd like to have a test if the person goes to "place" the object like follows say the player wants to "drop" ObjectB at the zone the player is standing in: if objectA is in the currentZone show a message "cannot be placed here" else move objectB to currentZone Just wondering if I can do this without having to test every zone/object combination each time an object is moved. Quote Link to comment
Ranger Fox Posted February 2, 2009 Share Posted February 2, 2009 It is possible, but not within the Builder. There's a way to retrieve all zones in a cartridge. You could use that in a loop. The following code retrieves all zones and makes them inactive: local allZones = zcart:GetAllOfType('Zone') for _,zone in ipairs(allZones) do if zone ~= nil then zone.Active = false end end If you'll notice, it's also possible, then, to return all items or timers in a cartridge for other operations. You could even do a logic test based off the name so that only, say, items starting with "zitemCoin" are manipulated in this way. Quote Link to comment
+charlenni Posted February 10, 2009 Share Posted February 10, 2009 Hello, if "in the current zone" means is visible to the player than you can check, if the player sees the object: function isItemVisible(parItem) local retValue = false for k,v in pairs(Player.GetVisibleObjects(Player)) do if v == parItem then retValue = true end end return retValue end Hope this helps Best regards Dirk Quote Link to comment
Recommended Posts
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.