Modding Help Querying for trees?

Discussion in 'Starbound Modding' started by magewish4, May 7, 2016.

Tags:
  1. magewish4

    magewish4 Pangalactic Porcupine

    I'm trying to find the position of nearby trees. Can I get a list of nearby trees with a command like entityQuery? I've tried entityQuery and objectQuery and they don't show up in the list.
     
  2. C0bra5

    C0bra5 Oxygen Tank

    The thing is that trees aren't entities they are almost considerated as blocks, the rule of thumbs to know if you can use a command to query for entities is if it has something around it when you do /debug it will pick it up in a world.entityQuery call since it just an entity query that isn't filtered in any way

    Sent from my SM-T350 using Tapatalk
     
  3. magewish4

    magewish4 Pangalactic Porcupine

    OK, so they aren't entities and won't be picked up by entityQuery. They do show up with the boxes command, but I can't get info on them with world.material either. Is there any way to get info on the trees?
     
  4. C0bra5

    C0bra5 Oxygen Tank

    I haven't gone far enough into the LUA API to answer that but my best guess is maybe but most likely not
     
  5. C0bra5

    C0bra5 Oxygen Tank

    ok so i've done a bit of research on my own and found out something,
    while it isn't possible to detect only trees, you can detect all plants to do so just use this code
    Code:
    for _,EntityId in pairs(world.entityQuery([InsertSearchLocationHere], [insertSearchRadiusHere])) do
        if world.entityType(EntityId) == "plant" then
            --do stuff
        end
    end
     
  6. magewish4

    magewish4 Pangalactic Porcupine

    Thanks! That gets me the list of IDs. I don't suppose there's any way of getting info about their item drops?
     
  7. C0bra5

    C0bra5 Oxygen Tank

  8. C0bra5

    C0bra5 Oxygen Tank

    Though you could get the position with world.entityPosition and destroy the block at the position by using world.damageTiles or something like that
     
  9. magewish4

    magewish4 Pangalactic Porcupine

    yeah, I was able to 'chop' down all the trees with world.damageTiles({world.entityPosition(EntityId)},"foreground",position,"plantish",200) I need to make a short video with the exploding trees set to the 1812 overture, but that's just bonus.
    I'm trying to set up some NPC tenants to automate some tasks and I was hoping to set one up to gather lumber. To simplify the automation when the player is gone I would rather spawn the appropriate amount of logs. However, some trees spawn different types of logs, so I'm trying to get info about the trees that would have been harvested.
     

Share This Page