Deltt Posted July 9, 2013 Share Posted July 9, 2013 Hey there, i have short question: how can i make a variable (the "name" of the variable) into a string? Example: local variable1 = createPickup(x, y, z) How can i get the name "variable1" as a string? Greetings Link to comment
Deltt Posted July 9, 2013 Author Share Posted July 9, 2013 if i do this, the outputChatmessage shows me a "userdata.00000AD" or something... Link to comment
iPrestege Posted July 9, 2013 Share Posted July 9, 2013 Why you want to set the variable as string? Link to comment
Cadu12 Posted July 9, 2013 Share Posted July 9, 2013 You can make own custom pickup, its not hard to do. Link to comment
Deltt Posted July 9, 2013 Author Share Posted July 9, 2013 What do you mean by that, Cadu12? I want it because i stored the coordinates where the pickup should teleport the player in my database, in the name of the pickup should be used to link the right pickups to the right coordinates. ??? Link to comment
Castillo Posted July 9, 2013 Share Posted July 9, 2013 You can store the pickups on tables, defining there the variables for each. Link to comment
AMARANT Posted July 9, 2013 Share Posted July 9, 2013 How can i get the name "variable1" as a string? Actually, there's no way. Because it's not necessary. Link to comment
Deltt Posted July 9, 2013 Author Share Posted July 9, 2013 "You can store the pickups on tables, defining there the variables for each." can someone give me a clue how i do that? unfortunately im not much into lua yet Link to comment
Castillo Posted July 9, 2013 Share Posted July 9, 2013 local pickups = { } local pickup = createPickup ( args... ) pickups [ pickup ] = "variable1" addEventHandler ( "onPickupHit", pickup, function ( ) outputChatBox ( pickups [ source ] ) end ) Element data would work aswell. Link to comment
Tete omar Posted July 9, 2013 Share Posted July 9, 2013 Actually, there's no function in lua that converts variable name to string, but you can make one. Link to comment
50p Posted July 9, 2013 Share Posted July 9, 2013 You can simply set pickup "element ID", like: local pickup = createPickup( .... ); setElementID( pickup, "pickup:myPickup1" ); --------------- -- Then you can get the pickup by ID: local mypickup = getElementByID( "pickup:myPickup1" ); 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