Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I get the data of an specific data in a module table?

Asked by
B_rnz 171
6 years ago
Edited 6 years ago

I came past an ROBLOX Catalog API and thought weather or not I can edit it and make it as my own? I am going to be handling a lot of data soon, once I add more knives to the module's table.

I watched an video on youtube on How to make a case clicker game a few weeks ago and saw the HttpService and JSON part.. which I don't understand.

ROBLOX Catalog API Example:

local Module = [[
    {
        "AssetId" : 1031429,
        "Name" : "Domino Crown",
        "AveragePrice" : 1453877
    },
]]

return Module;

My example:

-- Setting up the table.

local Knives = {
    ["Basic"] = {KnifeName = "Basic", KnifeImage = "rbxassetid://1", KnifeRarity = "Common"}, KnifeSold = 0, Tradable = false
}

return Knives

In order for me to get the Knife data for all knives in a specific way, do I have to return using a function?

If you can help me with this, i'd be very thankful.

1 answer

Log in to vote
0
Answered by 6 years ago

Its relatively simple. Think of an API like this:

An API connects to outside things. There are all sorts of APIs, Discord webhook APIs (They post using webhooks), google sheet APIs (they edit google sheets).

API's don't always need to connect to outside things, but generally they do.

For a roblox catalog API, it pulls live data from the roblox catalog. You could edit it, yes. Assuming roblox made it, lets hope its as good as we will get.

For pulling data off a table, generally I configure something like this on a Module script.

-- Module Script
local Module = {}

Module.Data = {
    Knives = {
        SomeKnife = "Hey"
    }
}

return Module
-- Server Script

local module = require(ModuleLocation.Module)
print(module.Data.Knives.SomeKnife)

-- This will print "Hey"
0
Oh wow.. I used this and it actually works! Thanks bro! Took me some days to figure it out. B_rnz 171 — 6y
Ad

Answer this question