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

Help with tables and are they like the game tree?

Asked by 4 years ago

This Place

--the example they have
local module = {}

module.VehicleData = {
    -- Rocket Sled
    RocketSled = {
        displayName = "Rocket Sled",
        topSpeed = 120
    },
    -- Spider Tank
    SpiderTank = {
        displayName = "Spider Tank",
        topSpeed = 40
    },
}

return module

I saw the above code in the link, I am confused about the module.VehicleData part. Is that like the game tree in that they can have different parts to them? You can have it like RandomPart.Stats

1 answer

Log in to vote
0
Answered by 4 years ago
Edited by Ziffixture 4 years ago

That code is in a module script. I've had trouble with a module script before and a player gave a great explanation of what it does because I didn't understand what a module script is. Click here to see my problem and the answer describing module scripts. Hopefully, something in the answer answers your question in more detail, but here I go trying to explain it in what I think it is.

A module script is basically a table. What this is, is a table inside of a table. The table in this example is stats, as in you can use this table to get stats about, in this case, the Rocket Sled or Spider Tank vehicle. If you require the module and look at VehicleData and inside of VehicleData you could choose between what stat table you want. Once you found the stat table you want you can look in there to find the different stats. This means you can use a module script to hold stats for items in a category of items such as a vehicle, weapon, furniture, etc.

0
oh come on this again i didn't even put a ~ COME ON! NarwhalAndMe 141 — 4y
0
StackEdit will recognize a Lua Embed command if a text bundle is indented. Ziffixture 6913 — 4y
0
Thank you, this helps me a lot barfpillow99 28 — 4y
Ad

Answer this question