Raimis_R Posted June 2, 2011 Share Posted June 2, 2011 Hello all i'm today i'm started with lua and i have problem with mysql "defines" If where are macro function #define ? Because i have error unexpected symbol near "#" my stuff: #define MySQL_HOST "localhost" #define MySQL_USER "root" #define MySQL_PASS "" #define MySQL_DATA "fr" mysql = mysql_connect(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DATA) if (not mysql) then outputDebugString("Unable to connect to the MySQL server") mysql_close(mysql) else outputDebugString("Connected") end Ohh at this moment i'm confused because i think where are somethink like #define Link to comment
karlis Posted June 2, 2011 Share Posted June 2, 2011 you don't need to define anything, just write name=var you should check these http://www.lua.org/pil/index.html http://lua-users.org/wiki/TutorialDirectory https://wiki.multitheftauto.com/wiki/Scr ... troduction http://www.lua.org/manual/5.1/#index https://wiki.multitheftauto.com/ Link to comment
Raimis_R Posted June 2, 2011 Author Share Posted June 2, 2011 You mean like: String = "localhost"; ? And thanks for links i will check it : ) EDIT: Fixed problem thanks for helping. Link to comment
Raimis_R Posted June 2, 2011 Author Share Posted June 2, 2011 Okey thanks but anyway if where are macro like #define ? Link to comment
Orange Posted June 2, 2011 Share Posted June 2, 2011 You don't need them. If you don't write a "local" before the name of variable, it'll be global Link to comment
Raimis_R Posted June 2, 2011 Author Share Posted June 2, 2011 No you don't understand maybe what i mean just with define you can bind colors like: #define COLOR_WHITE FFFFFF It's just example what can i do with #define Link to comment
AGENT_STEELMEAT Posted June 2, 2011 Share Posted June 2, 2011 There is no way to define a constant in LUA like you can in C. It's really not necessary. In your case, just do: MySQL_HOST = "localhost" MySQL_USER = "root" MySQL_PASS = "" MySQL_DATA = If you want them to be global to all server or client side scripts in this resource. Since this is MySQL stuff though, your probably only going to need it in this script, so: local MySQL_HOST = "localhost" local MySQL_USER = "root" local MySQL_PASS = "" local MySQL_DATA = would be a better solution. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now