How to detect what object an object is

Problems Koding something? Get help from other users here!
TheInventor
Level 1
Level 1
Posts: 24

How to detect what object an object is

Post#1 » Mon Feb 26, 2018 9:13 pm

I have a world that has natural trees and rocks that generated with the world. I want to be able to harvest the trees and rocks for resources. I have an object that adds a brain to every object that's visible with the fixed physics type. The brain basically turns off the invulnerability of the object and drops items on death. How can I make it so that that brain can tell what type of object it is in, such as tree or rock? I need this so that rocks can drop stone, and trees can drop sticks and wood.

Thanks!

bpottle
Level 1
Level 1
Posts: 21

Re: How to detect what object an object is

Post#2 » Wed Jun 13, 2018 4:12 pm

It's been a while, but maybe use the when 'death' do 'increment global stone variable' or something like this. For the trees it's the same thing but with the global wood variable (or the character's wood variable)

TheInventor
Level 1
Level 1
Posts: 24

Re: How to detect what object an object is

Post#3 » Sun Jun 17, 2018 3:54 am

I don't think you understand what I'm trying to say, so let me reword it. I have a ton of trees and rocks around my world that generated with the world when I created it. I want my brain to tell whether the object is a tree or a rock, without the hassle of going through each object individually and setting a variable like "isRock" or "isTree".

User avatar
LucidStew
Level 3
Level 3
Posts: 184

Re: How to detect what object an object is

Post#4 » Wed Jun 20, 2018 6:24 pm

You might be able to do something by checking against the gallery? But assuming that worked, you'd still need to check every tree and rock type. There's no other way for the engine to "know" what a thing is without some kode in it.
End of line.

User avatar
Psychokiller1888
Site Admin
Posts: 381
Contact:

Re: How to detect what object an object is

Post#5 » Fri Jun 22, 2018 8:31 am

Technically you set it once only.... In the template, and you spawn templates that have the variable already set...

Return to “Koding Konversations”

Who is online

Users browsing this forum: No registered users and 1 guest

cron