Skip to content

Passing lua tables to a pallene script? #360

Answered by hugomg
srijan-paul asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a table type.

local function vec2_mag(p: {x: float, y: float}): float
	return math.sqrt(p.x * p.x, p.y * p.y)
end

You can also use a typealias to give a name to the type

typealias Point = {x: float, y: float}
local function vec2_mag(p: Point): float

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@srijan-paul
Comment options

srijan-paul Apr 15, 2021
Collaborator Author

@hugomg
Comment options

@srijan-paul
Comment options

srijan-paul Apr 17, 2021
Collaborator Author

@hugomg
Comment options

@srijan-paul
Comment options

srijan-paul Apr 19, 2021
Collaborator Author

Answer selected by srijan-paul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants