Okamikurainya Posted September 12, 2019 Share Posted September 12, 2019 Hey all! Hopefully someone can help me out here, I'm trying to figure out exactly how the world's name is stored. Specifically so I can use it for world based scripting. Here's a simple example: function WhichWorld() local where = getWorld(); local player = getSpecificPlayer(0); if where == "Madhbih Oasis" then --Name of the map's Lots player:Say("I am in the desert."); else player:Say("I have no idea where I am."); end end Events.EveryHours.Add(WhichWorld); The name of the Lots isn't working and trying to print the variable throws up errors. Where am I going wrong and what direction can I take to get on the right path? Link to comment Share on other sites More sharing options...
Dr_Cox1911 Posted September 12, 2019 Share Posted September 12, 2019 Didn't look to closely into this, but getWorld() gives you an Instance of IsoWorld, so you can't directly deprive the name of it. There is the method getWorld() inside IsoWorld, so maybe it does work if you rewrite your example code to something like this: function WhichWorld() local where = getWorld(); local player = getSpecificPlayer(0); if where.getWorld() == "Madhbih Oasis" then --Name of the map's Lots player:Say("I am in the desert."); else player:Say("I have no idea where I am."); end end Events.EveryHours.Add(WhichWorld); Notice the getWorld() that I added to your where in the if statement. Link to comment Share on other sites More sharing options...
Okamikurainya Posted September 12, 2019 Author Share Posted September 12, 2019 Still no luck, but thanks! That throws up "java.lang.RuntimeException: getWorld: Expected a method call but got a function call." What about a way to set a global variable? I could set it to false on game start, but set it to true in the spawnpoints.lua. Link to comment Share on other sites More sharing options...
Okamikurainya Posted September 13, 2019 Author Share Posted September 13, 2019 (edited) 16 hours ago, Dr_Cox1911 said: (snip) I cracked it! the correct way to do it is: function WhichWorld() local player = getSpecificPlayer(0); local where = getWorld():getMap(); if where == "Madhbih Oasis" then --Name of the map's Lots player:Say("I am in the desert."); else player:Say("I have no idea where I am."); end end Events.EveryHours.Add(WhichWorld); This opens up so many possibilities... Map based loot tables, individual map climates... Woo! Edited September 13, 2019 by Okamikurainya tommysticks and Dr_Cox1911 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now