View Full Version : Faeture request:Object references
Dodgy
04-04-2005, 05:58 AM
Can we have some simple method for storing and retrieving item references in the scene file which works with load from scene then?
Object IDs work great if you just load the scene, but try loading from a scene and it screws the system.
Using names is completely useless as I often have names which are duplicates, and if you load the same scene into the current scene (which you might well for a character) then all your names are duplicates and it's well broken.
Please something this valuable needs making simple and working!
It would be great if LW would just load the scene into a buffer so we could get object agents from their ID's THEN merge the imported scene with the main scene so the object agents get updated, and everything would work....
GregMalick
04-04-2005, 11:53 AM
You got my vote on this one!
I would like a way to uniquely identify an object, period, even disregarding the issues regarding loading and saving. Using names, as you say, breaks if you load duplicate objects, and using IDs breaks if you delete objects with a lower ID (thus causing all the later IDs to shift down by one). Even using the actual mesh object agent breaks just like using IDs does if you delete objects with a lower ID.
options:
{
c1=ctlmeshiitems("Attach to: ");
myobj = getvalue(c1);
myid = myobj.id;
myname=myobj.name;
}
process: ma, frame, time
{
foo=___;
ma.set(POSITION,foo.getWorldPosition(time));
}
10 points: foo=___
A. foo=myobj;
B. foo=Mesh();while(foobar&&foobar.id!=myid)foobar=foobar.next();
C. foo=Mesh(myname);
D. other
Dodgy
05-08-2005, 01:37 PM
You should convert the ID to the object agent in the Options, because if you use Object Agents, then LW should automatically update references as objects are added/cleared. I use Id's only during the save/load process, then convert these to object agents as soon as possible to keep everything working.
I thought if I did this in options:
c1=ctlmeshiitems("Attach to: ");
myobj = getvalue(c1);
myobj will be an object agent, right?
If I set myobj that way in options and then in process simply do
ma.set(POSITION,myobj.getWorldPosition(time));
my object will stay attached to the one I want until I delete an object with a lower ID, at which point it will start attaching it to the next.
Maybe I am doing something wrong?
Dodgy
05-09-2005, 10:01 PM
I seem to remember having a little problem with object agents directly gained from ctlitems, I got the id from the ctlitem then derived a full object agent from that, and it seems to work properly. you might want to try it.
So, I went back to my simple "attach" lscript and confirmed that it now does indeed work if you use the mesh object agent to refer to your object. You don't even need to pull off the ID and then find the mesh from the ID again - a simple myobj=getvalue(v1); works just fine. I went back to 7.5 and it broke again.
So: it just works in 8.2 (maybe earlier)
and: busted in 7.5
Serves me right for not upgrading until this weekend.
Thanks for the help.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.