Modding Help how do you make world.entityQuery recognize you as the tech source?

Discussion in 'Starbound Modding' started by Robertshadow, May 28, 2016.

Tags:
  1. Robertshadow

    Robertshadow Big Damn Hero

    So im trying to make a tech where it designates a area near your cursor where it scans for any creature, because this will probably come in handy in the future, but the problem im having is that the tech always targets me, no matter what.

    Currently im using
    world.entityQuery(tech.aimPosition(), 3, {includedTypes = {"creature"}, order = "nearest", withoutEntityId = sourceentityid, somethingsomething})
    I would assume it would just act upon my cursor but i guess not, so i guess i just gotta figure out how to make it ignore me as an entity...
     
  2. v6ooo

    v6ooo Space Kumquat

    I saw this just as I was heading to work but I didn't have time to reply. Yep, work on Saturdays! :nuruconfused:

    Do you have "somethingsomething" defined or why is that there?

    I haven't really worked much with Techs but entity.id() in this case should return your own player id.
    You will need to enter the player's id into withoutEntityId OR if you just wish to ignore all players then instead of "creature" you could use"npc", "monster"

    world.entityQuery() can and will return more than 1 entity unless you limit it. You can loop through the returned table and find what you need.
     
    Last edited: May 28, 2016
    Robertshadow likes this.
  3. Robertshadow

    Robertshadow Big Damn Hero

    The somethingsomething is just a placeholder for some kind of code, whenever i have an idea i replace it by some kind of call script.

    I tought entity.id() was the name of any kind of entity, and by player ID, do you mean the UUID?
    Do i have to define entity.id() = my UUId/ some kind of Id ?
     
  4. v6ooo

    v6ooo Space Kumquat

    Oh I just thought you were actually using that because you said you were.

    Depends where it's called from, from tech, it returns the player.

    Code:
    world.entityQuery(tech.aimPosition(), 3, {includedTypes={"creature"}, order="nearest", withoutEntityId=entity.id()})
     
    Last edited: May 28, 2016
    Robertshadow likes this.
  5. Robertshadow

    Robertshadow Big Damn Hero

    i have tried to run some tests on punchys wether i could target them or not, tought id use party time since it makes them glowy so it would be easy to see effects, but seems like
    world.entityQuery(tech.aimPosition(), 1, {includedTypes = {"creature"}, order = "nearest", withoutEntityId=entity.id(), callScript = "status.addEphemeralEffect", callScriptArgs = {partytime}})
    doesnt affect either me or them.
     
  6. v6ooo

    v6ooo Space Kumquat

    Don't think you're allowed to manipulate creatures like that.

    You could spawn an invisible projectile on the target that applies the effect.

    Edit: I couldn't actually get partytime to work. Try using something else.
     
    Last edited: May 29, 2016
    Robertshadow likes this.
  7. TheElderScroller

    TheElderScroller Pangalactic Porcupine

    the callScript (and callScriptArgs) parameters use world.callScriptedEntity() as far as I know. You can't call that from a tech script on a npc, monster or object.
    I think to get world.callScriptedEntity() working both environments (the one calling it, and the one getting called) need to be the same.
    This was a change made to the function because it used to be pretty unsafe and easy to abuse.

    Use projectiles or world.sendEntityMessage() and message.setHandler()
     
    Robertshadow likes this.
  8. Robertshadow

    Robertshadow Big Damn Hero

    I think its something with the targeting, i had a friend in a server tell me if it affected him, but it only affected me no matter what.
    tried using

    world.entityQuery(tech.aimPosition(), 3, {includedTypes = {"creature"}, withoutEntityId=entity.id()/self.ownerEntityId/my UUId, order = "nearest", callScript = status.setResourcePercentage("energy", 0.75)})

    seems like the code targets me, wich i dont understand why, it should aim at my cursor and ignore my Id...
     
  9. v6ooo

    v6ooo Space Kumquat

    I hope you read what TheElderScroller said. He confirmed what I had already said and added upon it with another possible solution.
    In the future when you post code, only post the actual code you are using. No "placeholders" as we assume this is breaking the code. You can explain what you're trying to do in your post instead.

    I said you could just use withoutEntityId=entity.id() to remove the player from the table returned, where did "withoutEntityId=entity.id()/self.ownerEntityId/my UUId" come from?
    And don't forget, callScript doesn't work.


    @TheElderScroller, are you able to define new handlers in a remote script or does it have to happen in init of the object/creature?

    Edit: That's what I assumed but I just wanted confirmation, thanks @TheElderScroller.
     
    Last edited: May 29, 2016
    Robertshadow likes this.
  10. TheElderScroller

    TheElderScroller Pangalactic Porcupine

    Yes, ou have to set handlers in the entity's script which will be called.
    The reason for this was to lock out clientside loaded scripts from others
     
  11. Robertshadow

    Robertshadow Big Damn Hero

    I didn't read what TheElderScroller said because we literally posted on the exact same minute, so it didn't render for me,and the reason i used all the different Id types was because everyone of them made the effect apply to me ( always lost the 0.25 of my energy )...

    Correct me if im wrong, but after reading up about sendentitymessage, specifically severedskullz's comment, on quote: ''Thats because they seemed to completely isolate the client side techs from the server, which is a good thing. Techs, Scripted GUI, Etc. are all clientside scripts and had no place running in an authorotative enviournment to begin with. So what has happend is now you cannot directly call synchronous functions on other entities. I dont *exactly* understand what is going on under the hood yet as I have not had a chance to talk to Meta or Healthire. Still, you must route your calls to the new messaging system using the parameter that is specified when you set up the handler for that call.'' , does this mean most scripts can no longer interact with entities at all, or am i interpreting this wrong?

    I guess to a certain extent, projectiles can suffice...
     
  12. v6ooo

    v6ooo Space Kumquat

    If we knew the end goal we might be able to help better.
     
    Robertshadow likes this.
  13. Robertshadow

    Robertshadow Big Damn Hero

    Anything that interacts with others, mostly focused on 2 things: either sending griefers away from spawn or killing them.
    Currently the server i visit practically only has staff protection during the night, and very rarely for 30 minutes at random times by a person who can apparently kill griefers with some form of tech or unknown thing.
     

Share This Page