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 » Scripters
Home Search
 

Getting and setting values in tables with default index?

Previous Thread :: Next Thread 
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
08 Aug 2015 05:45 PM
Basically my main question is if it's possible to somehow have a table return or set one of it's values called without indexing it, so only using the table variable as reference. The main purpose of this would be to allow myself to use methods on single values.

So ideally I'd want to be able to do something like this:

local t = {value = 10;}

function t:randomMethod()
print("Bob's your uncle")
end

print(t) --> 10
t = 13
print(t) --> 13
t:randomMethod() --> Bob's your uncle

However, I want t to remain a table, so it returns t.value, but when I set t = x It's actually updating t.value = x. There very well may not be a solution but I figure I'd better ask.
Report Abuse
Funse is not online. Funse
Joined: 11 Jun 2012
Total Posts: 7887
08 Aug 2015 05:48 PM
local t = {}
t.value = 10

local t:randomMethod() = function()
print("s")
end

print(t.value)
t.value = 13
print(t.value)
t:randomMethod()
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
08 Aug 2015 06:08 PM
I know you can do that, but I'm specifically wondering about my above question.
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
08 Aug 2015 06:32 PM
Bump.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
08 Aug 2015 06:37 PM
yay my with module works here (although your table must be global):
http://www.roblox.com/CntKillMes-With-Module-item?id=252348051


require(workspace.MainModule)();

t = {t = 10;}
function t:randomMethod()
print("Bob's your uncle")
end
with2(t) do
print(t);
t = 13;
print(t);
self:randomMethod();
end with2();
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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