+Repmul Posted August 30, 2021 Posted August 30, 2021 For testing & bugging purpose, I want to set up a hidden zone that when you enter you are asked to choice a zone to change from Inactive to Active or ice versa. Is there a way to do this without having to create a lot of If/Else test statements? Quote
+capoaira Posted August 31, 2021 Posted August 31, 2021 AFAIK no In this case I would recommend you to write the If/Else commands as code and not with the blocks (it's easier :)) function getZone(zoneName) if (zoneName == "zone1") then return zone1; elseif (zoneName == "zone2") then return zone2; -- And so on end end -- This only works if you also name the zones with an identifier (under description) Or has lua a switch statement? Quote
+Hügh Posted August 31, 2021 Posted August 31, 2021 (edited) 16 hours ago, capoaira said: switch statement You can bodge one together by indexing into a table with named keys, I think. I'm not sure if this works on all players. local LookupTable = { zoneA = ..., zoneB = ..., zoneC = ..., ... } function getName(zoneName) return LookupTable[zoneName] end getName("zoneA") In theory this is as efficient as a jumptable (with some overhead for the hashmap lookup.) Edited September 1, 2021 by Hügh Quote
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.