ChatGGPT
(K_J)
August 14, 2024, 7:52pm
#1
For example
You see how all these options show up? How could I do this with a function such as
function foo(bar : baz)
-- ...
end
foo("p") -- Part, Player, Pose, etc.
Could I also do this with a table? Like
local foo : bar = {...}
foo.d -- Decal, Dialog, Dragger, etc.
Any help will be appreciated
3 Likes
Amritss
(EmperorOfChickens)
August 14, 2024, 7:53pm
#2
I’m not completely sure what you’re asking for but type checking should be the way to go.
3 Likes
ChatGGPT
(K_J)
August 14, 2024, 7:58pm
#3
What I’m asking is that I want to make it so that when you try and access the index of a table it will show all the instances that shows up in the first parameter of Instance.new
Here is a photoshopped image of what I want to happen
1 Like
Amritss
(EmperorOfChickens)
August 14, 2024, 8:04pm
#4
Is this for a command bar system or something similiar for clients?
Or do you just want this to be used in your scripts when you’re coding?
2 Likes
Amritss
(EmperorOfChickens)
August 14, 2024, 8:10pm
#6
Yeah, so I think you need to type check. That way you get the auto writer thing.
Also, if you wanna take the easy way there’s apparently a studio code editor module that actually type checks everything for you automatically so it will always show you the auto writer thing.
I think it was called VSC?
1 Like
ChatGGPT
(K_J)
August 14, 2024, 8:10pm
#7
No I wanna do it with typechecking
Amritss
(EmperorOfChickens)
August 14, 2024, 8:14pm
#8
Well alright then, do you know how to?
1 Like
Amritss
(EmperorOfChickens)
August 14, 2024, 8:15pm
#10
1 Like
ChatGGPT
(K_J)
August 14, 2024, 8:17pm
#11
Ok thanks
Amritss
(EmperorOfChickens)
August 14, 2024, 8:24pm
#12
If it’s what you wanted I think you should mark it as a solution for other people.
1 Like
ChatGGPT
(K_J)
August 14, 2024, 8:35pm
#13
I can’t really find what I wanted
There is nothing that tells me how to do this
Amritss
(EmperorOfChickens)
August 14, 2024, 10:57pm
#14
Simply, sometimes roblox’s auto type writer does not occur because roblox does not know what type you are writing.
Type checking solves this since roblox will know what type you are accessing.
I can provide some code in a second.
1 Like
ChatGGPT
(K_J)
August 15, 2024, 2:05am
#15
It’s been 3 hours lol But thanks for the help
You can’t 100% replicate the menu because that behavior is builtin. The closest you can get to that is:
local Services = {}
local Modules = {}
for _, Module in pairs(script:GetChildren()) do
if Module:IsA("ModuleScript") then
Modules[Module.Name] = require(Module)
end
end
type Services = typeof(Services)
type GetService = -- i assume not all of these modules exist, but this is what the type definition should look like (as an example)
((self: Services, name: "MyService") -> typeof(require(script.MyService))) &
((self: Services, name: "TestService") -> typeof(require(script.TestServ…
Although, if you really needed to, you can do this:
local create: typeof(Instance.new) = function(class)
-- ...
end
create( --> this will give you a list of class options like in the screenshot
But you cannot customize the behavior beyond what the engine has defined for it
1 Like
string.find would be the one.
30limitcharcharchar
1 Like
oh boy you’re gonna have fun learning what magic types are.
The short answer is, unless you want to statically generate a string union with 500 different strings, its not possible, though if you want to bully yourself, the syntax for this is:
type StringUnion = "cat" | "dog" | "fox"
function makeAnimal(animalType: StringUnion)
end
1 Like
ChatGGPT
(K_J)
August 15, 2024, 2:47am
#19
What