So the title explains it self how would i be able to make a converter with the same properties, I’ve been using an API to do that but it’s very old and not updated, I’ve found another API (From a topic) For it but it’s not working.
Here is my current script.
local module = {}
local myProps :{string} = {}
function fetchProperties(classToCollect :string)
local HttpService = game:GetService("HttpService")
local apiDumpClasses = HttpService:JSONDecode(HttpService:GetAsync("")).Classes
local found = false
repeat found = false
for _, class in pairs(apiDumpClasses) do
if class.Name ~= classToCollect then continue end
for _, member in pairs(class.Members) do
if member.MemberType == "Property" then
table.insert(myProps,member.Name)
end
end
classToCollect = class.Superclass
found = true
end
assert(found,"Class not found: "..classToCollect)
until classToCollect == "<<<ROOT>>>"
print(myProps)
return myProps
end
function module.getProperties(instance)
fetchProperties(instance)
print(myProps)
print(myProps[instance]) -- prints nil
if not myProps[instance] then warn(instance.. " isn't found and Can't be changed.") return "error" end
return myProps[instance]
end
Note I Didn’t put the id because for some reason I couldn’t post it here But here is it (remove spaces).
What are you trying to do with this converting idea? Partial conversions are easy if you know what properties you want to apply. What you’re asking for is very broad, the best answer you would get here is a link to a different api dump.
I’m trying to make a Converter with the API I’m using.
Could you get a look at my script and the API to know what I’m doing wrong? I’ve been using an old API it does work but it’s very old and doesn’t have the new stuff.
I don’t know what is wrong with your script because you need to explain what you expect to happen and what is actually happening with the script. Is is infinitely looping? are there errors thrown? what is the value of myProps when printed? is it what you expected?
It seems like there are a lot of issues because of how the global variables, function parameter variables, and repeat-until are being used. Returning myProps when you probably want to return classToCollect, and you need to store the result when using the function local properties = fetchProperties(instance)
But why are you trying to generically convert instance types? My thought is that you probably do not want to do this, and that there is a simpler way around whatever your underlying issue is. Or at least there is a more minimalist way to do conversions for your use case.
Hi, I’m trying to make a converter Plugin with it saves it’s properties (When converted, Like ReClasser Plugin) the Problem is I’ve to use an API for it and that API is currently not working for me?
It’s not infinitly looping, It just errors when I do
print(myProps[instance])
But, It prints it’s Properties.
print(myProps)
I’ve also tried doing
print(instance[myProps]
I’ve also changed the script to this and it’s not working.
local module = {}
local HttpService = game:GetService("HttpService")
local apiDumpClasses = --Can't put the API here for some reason
local MyProps :{string} = {}
function GettingProperties(ClassToCollect)
for _, class in pairs(apiDumpClasses) do
if class.Name ~= ClassToCollect then continue end
for _, member in pairs(class.Members) do
if member.MemberType == "Property" then
table.insert(MyProps,member.Name)
end
end
ClassToCollect = class.Superclass
return MyProps
end
end
function module.getProperties(instance)
local Mypropsx = GettingProperties(instance)
print(Mypropsx) -- prints its properties.
print(instance[Mypropsx]) -- prints nil
if not instance[Mypropsx] then warn(instance.. " isn't found and Can't be changed.") return "error" end
return instance[Mypropsx]
end
return module
myProps is an array with member names inserted into it. addressing it with an instance or string will always result in nil, only a number index has the potential to yield a result after fetchProperties is run.
print(myProps[instance])
I think you want to iterate over myProps like so to copy the old properties into my_new_thing obviously replacing the Instance.new class name
local my_new_thing = Instance.new("some new thing of inheriting class")
for _, property in ipairs(myProps) do
my_new_thing[property] = instance[property]
end
Well, If i try that it will break.
I currently Have 2 Modules One for the Main one for the Property.
Here is my current main one for converting So I’ve to indeed use this system…
function module.ConvertingProccess()
local Selected = SelectionService:Get()
if SelectedInstance and #Selected >= 1 then
for i, SelectedObject in ipairs(Selected) do
local OldInstanceParent = SelectedObject.Parent
local properties = PropertiesModule.getProperties(SelectedObject.ClassName)
if properties == "error" then return end
local NewInstance = Instance.new(tostring(SelectedInstance.InstanceName.Text))
for i,v in ipairs(SelectedObject:GetChildren()) do
v.Parent = NewInstance
end
for _ , v in pairs(properties) do
local hasProperty = pcall(function() NewInstance[v] = SelectedObject[v] end)
if not hasProperty then continue end
local samePropertyType = (typeof(NewInstance[v]) == typeof(SelectedObject[v]))
if not samePropertyType then continue end
NewInstance[v] = SelectedObject[v]
end
pcall(function()
NewInstance.Parent = OldInstanceParent
SelectedObject:Destroy()
end)
end
end
end
local module = {}
local myProps :{string} = {}
function fetchProperties(classToCollect :string)
local HttpService = game:GetService("HttpService")
local apiDumpClasses =
local found = false
repeat found = false
for _, class in pairs(apiDumpClasses) do
if class.Name ~= classToCollect then continue end
for _, member in pairs(class.Members) do
if member.MemberType == "Property" then
table.insert(myProps,member.Name)
end
end
classToCollect = class.Superclass
found = true
end
assert(found,"Class not found: "..classToCollect)
until classToCollect == "<<<ROOT>>>"
print(myProps)
return myProps
end
function module.getProperties(instance)
fetchProperties(instance)
print(myProps)
print(myProps[instance])
if not myProps[instance] then warn(instance.. " isn't found and Can't be changed.") return "error" end
return myProps[instance]
end