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
 

Re: Is there an inheritance for StringValues(or any value)

Previous Thread :: Next Thread 
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 04:30 PM
I've been looking for years and i'm still uncertain. What I found, the answer is no. I think that's a little crazy, considering meshes have their own(DataModelMesh).

If they don't, then roblox should make one(it would be REALLY helpful) Here's the criteria to be under an abstract class called "Value":
Must have .Value
Must be suggested in the advanced object toolbox in studio when a configuration instance i selected
Must have "Value" in the name(IntValue, StringValue, ect.)

So now, if i have a BoolValue, StringValue, and a part in a model, i could do...

for _,Obj in pairs(Model:GetChildren()) do
if Obj:IsA("Value") then
print(Obj.Value)
end
end


--Siggeh: "asd" - MakerModelLua
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
15 Apr 2015 04:32 PM
We should avoid trying to be radical on roblox.
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
15 Apr 2015 04:36 PM
They only inherit from Instance because polymorphism.
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 04:36 PM
Not sure this proposal is all that radical when meshes(Mind you, there's only 3 meshes that have this[there's like 2 other deprecated ones(that i know of)]) have a longer class inheritance than values do(there are 12)


--Siggeh: "asd" - MakerModelLua
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Apr 2015 04:44 PM
Although logically, no

..But here's a h4xxy workaround by yours truly, warspyking


function Val(obj)
local val = obj.ClassName:sub(-5) == "Value"
return val, val and obj.ClassName:sub(1, -6)
end

for _,Obj in pairs(Model:GetChildren()) do
if Val(Obj) then
print(Obj.Value)
end
end
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 04:46 PM
I have my haxy way around too:

if ypcall(function() return Value.Value end) then
end

Just sayin roblox should really make an inheritance


--Siggeh: "asd" - MakerModelLua
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Apr 2015 04:53 PM
"I have my haxy way around too:

if ypcall(function() return Value.Value end) then
end

Just sayin roblox should really make an inheritance"


Ahem, let's just wrap that up in a function


function IfValue(Value, func)
if ypcall(function() return Value.Value end) then
func(Value)
end
end

local Val = newproxy(true)
getmetatable(Val).__index = function(self, key)
if key == "Value" then
return true
else
return error()
end
end

IfValue(Val, function(v) print(v.ClassName) end)

--An error occurred


Looks like your method isn't as fool-proof as mine, hmm?
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
15 Apr 2015 04:54 PM
http://wiki.roblox.com/index.php?title=API:Class

They are all separate because roblox put some values in non value like places
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Apr 2015 04:57 PM
They don't inherit because what would they inherit? Value's type isn't consistent throughout them.
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 05:00 PM
@warspyking

I don't often(ever) use metatables, so it's not a concern
Also what if roblox releases a new object that has "Value" in it, but it doesn't have .Value


--Siggeh: "asd" - MakerModelLua
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Apr 2015 05:04 PM
Well mine checks to see if it's an instance who's ClassName ends with Value, then returns true if it is, and if it is also returns what type it is.

So even if roblox added more (these will most likely never occur but for example)

FunctionValue
TableValue
UserdataValue

They would all still return true. Add a pcall and some safety measures and you won't be able to fool it with a metatable with .ClassName in the __index either.
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 05:04 PM
Actually they do all inherit .Value

http://wiki.roblox.com/index.php?title=API:Class/StringValue
http://wiki.roblox.com/index.php?title=API:Class/CFrameValue
http://wiki.roblox.com/index.php?title=API:Class/DoubleConstrainedValue
http://wiki.roblox.com/index.php?title=API:Class/Vector3Value
http://wiki.roblox.com/index.php?title=API:Class/BoolValue
http://wiki.roblox.com/index.php?title=API:Class/Color3Value
http://wiki.roblox.com/index.php?title=API:Class/IntConstrainedValue
http://wiki.roblox.com/index.php?title=API:Class/IntValue
http://wiki.roblox.com/index.php?title=API:Class/ObjectValue
http://wiki.roblox.com/index.php?title=API:Class/RayValue


--Siggeh: "asd" - MakerModelLua
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 05:06 PM
Each value type is something, it's only nil if it's an ObjectValue(which is still an instance)


--Siggeh: "asd" - MakerModelLua
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
15 Apr 2015 05:06 PM
Um..Guys..

local function isVal(ob)
return string.find(ob.Name,"Value")
end
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
15 Apr 2015 05:07 PM
ClassName*
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
15 Apr 2015 05:07 PM
@warp

wat if i name a model TrollModelString

hmmm

rekt
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 05:08 PM
@MrJoeyJoeJoey

u must not have read our conversation. We know there's other ways, just no native inherited way


--Siggeh: "asd" - MakerModelLua
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
15 Apr 2015 05:09 PM
I was reading the conversation but unlike your solutions with metatables and pcalls, which I've heard to be laggy, Mine isn't at all.
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
15 Apr 2015 05:10 PM
what if i have a part named stringcheese

;o
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
15 Apr 2015 05:10 PM
local function isVal(ob)
return string.find(ob.ClassName,"Value")
end

I corrected it in a different post
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
15 Apr 2015 05:12 PM
what if roblox makes another class named valuethatsnotvalue ;o
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Apr 2015 05:14 PM
@iiE

function Val(obj)
local val = obj.ClassName:sub(-5) == "Value"
return val, val and obj.ClassName:sub(1, -6)
end


I don't even use .Name so goodluck breaking it with that



@Above

function Val(obj)
local val = obj.ClassName:sub(-5) == "Value"
return val, val and obj.ClassName:sub(1, -6)
end

I don't use pcalls or metatables? So goodluck lagging it with that. Besides, neither pcall or metatables are laggy.
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
15 Apr 2015 05:16 PM
btw war I used ypcall, not pcall

I think ypcall doesn't invoke metamethods so i should be safe C:


--Siggeh: "asd" - MakerModelLua
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
15 Apr 2015 05:18 PM
why arent y'all using

int:IsA("")
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
15 Apr 2015 05:19 PM
Lol @Model, anything run in ypcall will still invoke metamethods if applicable:


local x = setmetatable({}, {__call = function(self, ...) print(...) end})

ypcall(function() x("Hi") end)
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