Jump to content

Variable name as String?


Deltt

Recommended Posts

Posted

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

Posted

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.

???

Posted

"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

Posted
local pickups = { } 
local pickup = createPickup ( args... ) 
pickups [ pickup ] = "variable1" 
  
addEventHandler ( "onPickupHit", pickup, 
    function ( ) 
        outputChatBox ( pickups [ source ] ) 
    end 
) 

Element data would work aswell.

Posted

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" ); 

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