Scripts / Keeping an entities object number the same

Author
Message
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 15th Oct 2015 00:31
In my level I have several trees which each have a 'main' lua script and are thus marked as not static.

I am noting that each time I run the program the object numbers are different from the previous run.

Anyone know how to make assigning the numbers the same each time I run?

Also is there any lua function where we can obtain the entity name as displayed in its dashboard?
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Oct 2015 10:11
It'll only change if you remove an object from before them in the chain (I.e. delete object 2 and object 3 will become 2 etc - if you don't place a new object after deleting, otherwise the new object will become 2)
Hope that makes sense

For the name yes but you need to set up the script differently
Function scriptname_init_name(e,name)
Variable = name
End

^ the only parts you change are "scriptname" and "variable"
(Take a look at the default weapon.lua)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 15th Oct 2015 16:43
Thanks smallg - as normal you are extremely helpful and I am very grateful for your help - thanks again!
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 15th Oct 2015 16:48
just a follow on - if the player moves an entity in game that wont reorder the sequence im guessing but what if the player deletes an entity in game - i.e blow a barrel up or something?
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Oct 2015 18:50
no thats fine, it's only in editor changes (and it wont apply until the entities have been "loaded" (i.e. saved and/or opening the level again)
stuff that gets blown up or killed in game is still counted as being there (as it's still present in the editor map)

my usual workaround for this sort of thing is to grab the name of an entity and store it's 'e' value from there (if you have more than 1 that you need and they have the same name then you can adjust by distance or whatever - of course this means you need to have the object in question as dynamic which might not be ideal)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 15th Oct 2015 18:55
thanks again smallg!
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 16th Oct 2015 21:53
I can't get this to work - when I run GG it fires back an error due to nil value for 'name'.
I have listed the code below and would welcome any suggestions - all I'm trying to do is to get the name of an entity to be shown onscreen at its location- several entities/objects use the same script.

function object_property_init_name(e,name)
x={}
y={}
z={}
object_property_name={}
object_property_name[e]=name
end

function object_property_main(e)
-- whatever object uses this script we put its co-ord in the array
object = g_Entity[e]['obj'];
x[object]= g_Entity[e]['x']
y[object]= g_Entity[e]['y']
z[object]= g_Entity[e]['z']
--PromptLocal(e,object) <<<<< this works fine
PromptLocal(e,object_property_name)
--Text(x[object],z[object],1,object_property_name)
end
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 17th Oct 2015 01:39
Quote: "PromptLocal(e,object_property_name)
--Text(x[object],z[object],1,object_property_name)"


you stored it as an array so you need to call it as an array

i.e.
Quote: "PromptLocal(e,object_property_name[e])
--Text(x[object],z[object],1,object_property_name[e])"
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 17th Oct 2015 02:44
Hi smallg - I originally tried that but GG crashes and returns to editor so I thought tthat was an error on my part - with this code:

function object_property_init_name(e,name)

object_property_name={}
object_property_name[e]=name
end

function object_property_main(e)

object = g_Entity[e]['obj'];
PromptLocal(e,object_property_name[e])
end
Saintyboy
9
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 17th Oct 2015 02:47
Actually - just saw the issue as I posted the code in the last reply - I need to put the declaration of the global array outside the init function !
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 17th Oct 2015 12:50
glad you got it resolved, yes all globals and arrays to the top.
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.

Login to post a reply

Server time is: 2024-12-22 06:59:04
Your offset time is: 2024-12-22 06:59:04