View Full Version : Naming conventions for data types?
k410
February 18th, 2020, 17:59
Is there a post or style guide that shows the naming conventions for the data types in FG?
So far I gather the following:
a = array
b = [edit: boolean]
s = string
k = key
v = value
t = table
i = index
Not sure about:
n (number?)
r (resource?)
f (floating number?)
v (vector? when used as a prefix instead of by itself)
I might have missed some other prefixes.
Thanks!
Talyn
February 18th, 2020, 18:17
b == boolean
r == recordtype (at least the scripter I asked thinks that's what it is)
k410
February 18th, 2020, 18:24
Thanks, Talyn. I thought "boolean" and typed "binary". Not a good start!
r == recordtype makes sense, now that you mention it.
Moon Wizard
February 18th, 2020, 19:28
It's all a bit ad hoc. I started adding those lower case letters in front to help people reading the code know what "type" variables are expected to be, since Lua is untyped.
Prefix
b = boolean
n = number (usually integer, but not always)
f = number (float)
s = string
a/t = table
v = variable (could be anything, or even different value types) (example: database path or database node reference)
r = "record" (basically a table with some sort of expected format)
Variable Names
k = arbitrary ipairs/pairs key
v = arbitrary ipairs/pairs value
i/j = arbitrary number value
Regards,
JPG
k410
February 18th, 2020, 19:32
Thanks, Moon Wizard!
(I'm finally motivated to learn Lua and am partway into the 2019 Lua Beginner's Guide from Lua Publishing.)
Varsuuk
February 25th, 2020, 17:04
It a bad thing to toss up on the developer page, Moon. As you might recall, I asked the same thing long ago. If I’d seen this before now, I could have answered all except t (hadn’t seen), f (didn’t recall) and v (variable one, stand-alone I recall as part of k,v)
Moon Wizard
April 25th, 2025, 19:18
Added these conventions to the wiki:
https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644496/Ruleset+-+Scripting#Script-Variable-Naming
Regards,
JPG
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.