HaveItem doesnt find table["index name"] , bug or a feature?

Report any Hollywood bugs here
Post Reply
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

HaveItem doesnt find table["index name"] , bug or a feature?

Post by Bugala »

example code:

Code: Select all

testtable = {}

testtable["Movement Cost"] = 2
testtable[1] = 3

If HaveItem(testtable, 1) Then DebugPrint("1 is found")
If HaveItem(testtable, "Movement Cost") Then DebugPrint("Movement Cost found")
it prints "1 is found" as expected, but unexpectedly (to me at least), it doesnt print "Movement Cost found".

Is this a bug or a feature?

And trying this with Hollywood 8 on Windows.

I can get around it with RawGet, but RawGet makes difference between capital and non capital letters if I correctly understood.
Last edited by Bugala on Tue Nov 10, 2020 11:17 am, edited 1 time in total.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: HaveItem doesnt find table["index name"] , bug or a feature?

Post by Bugala »

Might be a feature.

I investigated this issue more and noticed following.

table["Name"] = 1

cant be found using table.name, as example: b = table.name

However, if I use all small letters:

table["name"] = 1

then I can use b = table.name and it works.

And same with HaveItem() works fine too.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: HaveItem doesnt find table["index name"] , bug or a feature?

Post by airsoftsoftwair »

RTFM :) This is what the HaveItem() doc says:
Note that if you pass a string in the key parameter, it will be converted to lower case automatically. If you don't want that, use RawGet() instead.
So yes, it's a feature...
Post Reply