Clarification on function paramter types needed
Hi guys,
I'm new to lua and addon development and I created a function and have a question about paramters for lua functions. In C# I need to pass the input type Code:
function X.FunctionName(bool unlock, string name) Code:
function X.FunctionName(unlock, name) |
read this, it should help:
https://wiki.esoui.com/New_to_lua%3F_GOTCHA In lua you just define the variable and pass whatever type you like to it, function, table, string, number, bool. You do not need to explicitly define the type, only for tables e.g. by using {} Lua Code:
Be sure to use local in front of your variables or they will be polluting the namespace _G (a table named _G which is used to store all global variables. So _G["myVar"] is the same like myVar, if myVar was defined without local). Locals are local to the scope so defined inside functions or if end or for do loops they will be only available inside them! You can define a local at the top of your lua file and then use it inside the whole file (global to the file, local to other addons or files). Or you define a global table Lua Code:
Lua Code:
Lua interprets the lua files from top to bottom so the variables/functions/etc. you want to use need to be known/defined before you access them! You can check the type via the "type" function Lua Code:
|
Quote:
|
All times are GMT -6. The time now is 03:20 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI