Page 1 of 1

FetchEntityMaterial() - nonsense Function?!

Posted: Fri Mar 07, 2014 9:52 am
by Bananenfreak
Heyho,

I have a question about materialnumber = FetchEntityMaterial(#Entity, #Material [, SubEntity]). First, I don´t know how to use this, because I have to set a materialnumber to get a materialnumber?! Even if first materialnumber is only the second materialnumber, which numbers can I use for FetchEntityMaterial()?
I mean, if I use #Material = 1 and I already got an Material with number "1", what shall I do?
Ah, one more question: Is there Support for #PB_Any?

EDIT: There is Support for #PB_Any with #Material. Could you add this to the Documentation.
There´s another Thing wrong with this function. In the bottomline of the IDE (I forgot the Name of that line) there is an issue with this function... Too much arguments.

Re: FetchEntityMaterial() - nonsense Function?!

Posted: Mon Mar 10, 2014 12:43 pm
by Fred
This command should assign the mesh material to a #Material number, so you can use the material library command on it. Does it works as expected ?

Re: FetchEntityMaterial() - nonsense Function?!

Posted: Mon Mar 10, 2014 1:43 pm
by applePi
refer to the FetchEntityMaterial.pb example
if you want to use the matNumber as this
matNumber = FetchEntityMaterial(#Entity0, #Material1)
then this works:
CreateEntity(#Entity1, MeshID(#Mesh1), MaterialID(#Material1), 60, 0, 0)
also this will work:
CreateEntity(#Entity1, MeshID(#Mesh1), matNumber, 60, 0, 0)
i guess matNumber is a pointer to the material (long number), correct me if wrong

Re: FetchEntityMaterial() - nonsense Function?!

Posted: Mon Mar 10, 2014 3:36 pm
by Bananenfreak
Ah, then FetchEntityMaterial() gives you pointer to the "fetched" material back as result and #Material is the PB-intern value; Material will set to this #Material.
Ok, now it´s clear why we need a #Material for a materialnumber.

Personally, I don´t like this command, because there are 2 (different) functions in 1 command...

Re: FetchEntityMaterial() - nonsense Function?!

Posted: Mon Mar 10, 2014 4:21 pm
by Fred
No, only the #Material number is valid. It returns the materialID, but it's not documented. You have to use MaterialID() if you want it

http://www.purebasic.com/documentation/ ... erial.html

Re: FetchEntityMaterial() - nonsense Function?!

Posted: Mon Mar 10, 2014 9:24 pm
by Bananenfreak
Aha, then the german Documentation isn't up-to-date. I will post it in the german forum.