generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Table help

Previous Thread :: Next Thread 
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
08 Aug 2011 02:09 PM
I have a table where there are some values that do stuff:

{["sit"]=true,["stand"]=true,["jump"]=false}

It is basically, if set to true, that thing will happen. If false, that thing won't happen.

However, I have it so that when someone talks and says one of the keys, it will happen. But I want it so that both "stand" and "unsit" will do the same thing, but then you would have to change both. I tried this:

t = {["stand" and "unsit"]=true}

unsit worked but not stand. Then I did:

t = {["stand" or "unsit"]=true}

And the opposite happened: stand worked but not unsit. Is there a way to make it so they both work?
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
08 Aug 2011 02:41 PM
Try not inserting new table values, just add another condition for your chatted event. I.E

if msg == "stand" or msg == "unsit" then
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
08 Aug 2011 03:08 PM
I wanted it so that people who use the script can easily turn off the commands if they want to, but only one switch can be flipped for commands that do the same thing.
Report Abuse
ThePHPguy is not online. ThePHPguy
Joined: 05 Aug 2011
Total Posts: 35
08 Aug 2011 03:34 PM
Hi Bunny,

the reason this happened is because lua uses and and or as conditional operators. So basically when you're saying

"stand" and "unsit"


it's like saying

if "stand" then "unsit"

so of course, when checking if something is there with conditionals, anything that isn't nil or false will return true. However when you say


"stand" or "unsit"

it will return the first one that it finds to be true. If you want to try to do something like this, try using this function.

function manipulate(tab,boolean,...)
local args={...}
for _,v in pairs(args) do
if tab[v] then
tab[v]=boolean
end
end
end


this way you could just do

manipulate(t,true,"stand","unsit")
Report Abuse
Nexun is not online. Nexun
Joined: 04 Aug 2011
Total Posts: 371
08 Aug 2011 03:49 PM
["stand"] = true, ["unsit"] = true
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
08 Aug 2011 03:52 PM
@Nexun: I said I wanted them together because they do the same thing, so that if someone wants to turn them off, they only have to change one false into true.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image