quadrinka4 Posted August 12, 2016 Share Posted August 12, 2016 (edited) Hello, I am trying to make a mod that allows a player to perform an action if the player is in a certain room definition (ex: church, grocery, livingroom, etc). I've got my idea from Hydrocraft and its' code : if not player:isOutside() then player:Say("There are no flora indoors."); My question is, is there a method that I can use to check if the player is in a certain room? maybe player:isRoom(grocery) type of thing? Thanks in advance. Edited August 14, 2016 by quadrinka4 Link to comment Share on other sites More sharing options...
blindcoder Posted August 12, 2016 Share Posted August 12, 2016 You can do: local room = getPlayer():getCurrentSquare():getRoom(); local roomName = room:getName(); This will get you all the first-level names of the SuburbsDistribution array ("conveniencestore", "burgerkitchen", "grocery", etc). Link to comment Share on other sites More sharing options...
quadrinka4 Posted August 12, 2016 Author Share Posted August 12, 2016 (edited) 1 hour ago, blindcoder said: You can do: local room = getPlayer():getCurrentSquare():getRoom(); local roomName = room:getName(); This will get you all the first-level names of the SuburbsDistribution array ("conveniencestore", "burgerkitchen", "grocery", etc). Thank you so much ^^ so if i want to test if my player is in grocery room, putting if not roomName: ("grocery") then player:Say("You are in wrong room."); this cause error, I am new to the Lua so i guess i am still on the learning phase by looking at other's codes.... Could someone fix what I did wrong? Edited August 12, 2016 by quadrinka4 Link to comment Share on other sites More sharing options...
blindcoder Posted August 12, 2016 Share Posted August 12, 2016 That's not valid in any programming language I know of... Try this: if roomName =~ "grocery" then player:Say("You are in the wrong room."); end =~ here means "is not equal" Link to comment Share on other sites More sharing options...
quadrinka4 Posted August 12, 2016 Author Share Posted August 12, 2016 (edited) 22 minutes ago, blindcoder said: That's not valid in any programming language I know of... Try this: if roomName =~ "grocery" then player:Say("You are in the wrong room."); end =~ here means "is not equal" So i introduced above code in Hydrocraft and I still get error.... function HCFloraGather(items, result, player) local room = getPlayer():getCurrentSquare():getRoom(); local roomName = room:getName(); if roomName =~ "grocery" then player:Say("There are no flora indoors."); end Sorry for being such a pain. But I am learning alot form you about LUA right now. Thank you Edited August 12, 2016 by quadrinka4 Link to comment Share on other sites More sharing options...
blindcoder Posted August 12, 2016 Share Posted August 12, 2016 You're lacking an "end" for the function. 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