Khakis7
Khakis7

Reputation: 433

:string syntax in Lua

I'm following along with a github project online written in Lua and have come across a variable declaration that I don't seem to understand.

    local pPlayerConfig :table = PlayerConfigurations[playerID];
    local statusMessage :string= Locale.Lookup(pPlayerConfig:GetPlayerName());

in these cases what does the :string / :table do? Are those like predefined types that override the normal type of string?

Upvotes: 0

Views: 120

Answers (2)

uknonot
uknonot

Reputation: 493

Even though this question is already answered, I can explain what it means. In typed Lua (used by Roblox), local identifier: type = value means that the variable with name identifier and value value has a type of type, but this only works when the variable is local. Examples:

local name: string = "John"

local emptyTable: table = {}

Upvotes: 0

Nicol Bolas
Nicol Bolas

Reputation: 473447

As far as standard Lua is concerned, that's a compile error. There's a decent chance that this is meant to be a specialized version of Lua with a modified compiler or something. But you'll have to investigate the specific project to find out what's going on (since you neglected to say what project this is, we can't help you with that).

Also, string and table are the names of standard Lua library components, so they shouldn't be used for local variable names regardless. That may be what the prefix : syntax is intended to deal with in this modified version of Lua.

Upvotes: 4

Related Questions