I have a variable in a procedure that is a reference to an object. I then call a procedure of another object with that varialbe passed as a parameter.
I have 2 variables referenced to objects in the object that houses the procedure I just called. I set one to the parameter. How do I copy the 1st variable to the 2nd variable. And then delete the first variable. With out the 2nd variable becoming null? Note that the very first variable that is passed as the parameter is null.
Would I use the vars list? Is it even possible with byond.
Since byond references every thing but numbers. I was thinking it was.
ID:269812
Oct 18 2005, 8:50 am
|
|
In response to Lummox JR
|
|
Yeah, I tried awful hard to follow, but it's pretty dense.
|
obj/housing_object{ Am I correct that this is the basic setup you have? I set one to the parameter."field1 = the_object" field1's value is set to the value of "the_object," which is a reference. How do I copy the 1st variable to the 2nd variable."field2 = field1" field2's value is set to the value of "field1," which is a reference. ...And then delete the first variable without the 2nd variable becoming null?'Deleting' field1 will result in the deletion of it's value. In other words, the reference (data object) will be cleared from memory, and DM's reference counter will kick in and null out any references to it, including field2. Therefor the value of field2 now equals null. If you want to null out field1, you can directly set it equal to null: field1 = null This sets the value of field1 equal to null; the value of field2 remains a reference. Note: DM does not have alias variables, or variables that point to other variables. This is probably where your confusion comes from. Here's an example: mob/verb/The_Major(){ Note that the very first variable that is passed as the parameter is null.I have no idea what this means. Please correct me if I am wrong, Mr.JR sir. |
In response to Lummox JR
|
|
Lummox JR wrote:
Um, you'll have to show some sample code here, because what you just said was impossible to follow. O.O LUMMOX JR! I thought u knew every thing *mouth hangs open*. DragonDatum How is that :) |
In response to Green Lime
|
|
Green Lime wrote:
Lummox JR wrote: > DragonDatum How is that :) Since variableone is an atom, when you use del() on it, it deletes the object, and sets all variables referanced to it to null (Can't reference to something that doesn't exist). IainPeregrine was right, all you need to do is change "del(variableone)" to "variableone = null". |
In response to DarkCampainger
|
|
DarkCampainger wrote:
Green Lime wrote: > > DragonDatum How is that :) But the obj will still be on the map right? Which is not what I want. |
In response to Green Lime
|
|
If you delete an object, then the reference counter will null out all references to it, including 'field2' from my above post. If you just want to remove it from the map, but still have a reference to it, then you can set it's location to 'null' and variables will still point to it:
field1 = new /obj() field1.loc = null world << isnull(field1) //Outputs: 0 |
Lummox JR