Deltt Posted July 9, 2013 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
Deltt Posted July 9, 2013 Author Posted July 9, 2013 if i do this, the outputChatmessage shows me a "userdata.00000AD" or something...
Deltt Posted July 9, 2013 Author 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. ???
Castillo Posted July 9, 2013 Posted July 9, 2013 You can store the pickups on tables, defining there the variables for each.
AMARANT Posted July 9, 2013 Posted July 9, 2013 How can i get the name "variable1" as a string? Actually, there's no way. Because it's not necessary.
Deltt Posted July 9, 2013 Author 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
Castillo Posted July 9, 2013 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.
Tete omar Posted July 9, 2013 Posted July 9, 2013 Actually, there's no function in lua that converts variable name to string, but you can make one.
50p Posted July 9, 2013 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" );
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