Scripts / using object_property_name(e)

Author
Message
Saintyboy
8
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 24th Oct 2015 00:06
My latest request for advice is on the use of object_property_name(e).
I am comparing its value to a string in an array;

if object_property_name[e]) == objtable17[1] then k=1 etc etc

both variables contain the string named --- Tree

However, GG is having none of it and returns a k of 0

If I run if object_property_name[e]) == tree then k=1 end --------k returns 0
If I run if object_property_name[e]) == "tree" then k=1 end --------k returns 1
However, If I run if objtable17[1] == "tree" then k=1 end --------k returns 0
but If I run if objtable17[1] == tree then k=1 end --------k returns1

So I cant compare them as ii am comparing "tree" with tree
I have looked at various String.format functions to no avail.

Can anyone offer some advice on my dilemma?
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 24th Oct 2015 00:35 Edited at: 24th Oct 2015 00:36
use tostring() (and tonumber() ) to convert maybe?
if object_property_name[e] == tostring(objtable17[1]) then k=1
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Saintyboy
8
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 24th Oct 2015 07:28
Thanks smallg, I did try tostring but i'll try tonumber and see how that goes.
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 24th Oct 2015 10:34
correct, any numeric values being passed need to be numeric as LUA vars take any values and therefore are character in the first instance.
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.
Saintyboy
8
Years of Service
User Offline
Joined: 18th Jun 2015
Playing:
Posted: 24th Oct 2015 18:12
Fantastic Tonumber works a treat - thank you

Login to post a reply

Server time is: 2024-05-04 23:14:54
Your offset time is: 2024-05-04 23:14:54