+Tequila Posted March 3, 2010 Share Posted March 3, 2010 Is there an easy way to change the status of all currently active zones to inactive? I am writing a cartridge where the player will be presented with a multiple choice question. Each possible answer requires the player to walk to a different zone. When they get to the correct zone, I want to turn the currently active zones inactive, present a new question with 3 new zones active. I am looking for a simple way to do this without having to code a separate line for each zone. Thx Quote Link to comment
+charlenni Posted March 3, 2010 Share Posted March 3, 2010 (edited) This function sets all Zones to Active=false. I'm sure, Jan have a better way , but it should work. function unsetZones() for k,v in pairs(CartridgeName.AllZObjects) do if tostring(v) == "a Zone instance" then v.Active = false end end end Best regards Dirk (Charlenni) Edited March 3, 2010 by charlenni Quote Link to comment
+Tequila Posted March 3, 2010 Author Share Posted March 3, 2010 I pasted that into a user code box on URWigo and nothing happened. Is there something else I should be doing? Quote Link to comment
+sTeamTraen Posted March 3, 2010 Share Posted March 3, 2010 You did then add a call to unsetZones(), I hope? Otherwise, paste the code which Dirk provided but without the first ("function...") and last ("end") lines. Quote Link to comment
+Tequila Posted March 3, 2010 Author Share Posted March 3, 2010 You did then add a call to unsetZones(), I hope? Otherwise, paste the code which Dirk provided but without the first ("function...") and last ("end") lines. I removed the function/end statements and it turned the zones inactive but it also crashed the cartridge in the Emulator. Quote Link to comment
+sTeamTraen Posted March 4, 2010 Share Posted March 4, 2010 Try putting all of Dirk's code in the Author Script section and just say "unsetZones()" in your event handler. That shouldn't make any difference, but it's less code each time and it stops anything weid happening if the code gets executed at compile time. I also wonder how the emulator copes if you set the current zone inactive... Quote Link to comment
+Tequila Posted March 4, 2010 Author Share Posted March 4, 2010 Try putting all of Dirk's code in the Author Script section and just say "unsetZones()" in your event handler. That shouldn't make any difference, but it's less code each time and it stops anything weid happening if the code gets executed at compile time. I also wonder how the emulator copes if you set the current zone inactive... Author Script blows up too. In this case, I used just the GS Builder and a text editor. Setting current zone inactive happens all the time. That is how I do all my cartridges. Enter Zone 1, Display a message, De-activate Zone 1, Activate Zone 2 and move on. Quote Link to comment
Ranger Fox Posted March 4, 2010 Share Posted March 4, 2010 I'd suggest the following, so long as you replace "zcart" with your cartridge object: function SetAllZoneActive(isActive) local allZones = zcart:GetAllOfType('Zone') for _,zone in ipairs(allZones) do if zone ~= nil then zone.Active = isActive end end end 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.