Jump to content

Variable name as String?


Deltt

Recommended Posts

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

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
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...