Modding Help sendEntityMesssage for setResourcePercentage not working

Discussion in 'Starbound Modding' started by Errors4l, Aug 25, 2015.

  1. Errors4l

    Errors4l Spaceman Spiff

    Hello,

    Based on this thread (http://community.playstarbound.com/...-world-callscriptedentity-return-error.98292/) and this random diff file I found online (http://stag.ccdyn.com/diffs/nightly/nightlyDiff.15_06_28.full.txt), the only difference between the outdated callScriptedEntity and the new sendEntityMessage function seems to be the name.

    My question is, what modifications to the following code should I make to have it work again?
    Code:
    world.sendEntityMessage(entityId[1], "status.setResourcePercentage", "health", -math.huge)
    world.sendEntityMessage(entityId[1], "status.setResourcePercentage", "energy", -math.huge)
    entityId contains the entity id fetched with the world.entityQuery function, and is checked to be valid. Right now, the script isn't crashing but the target entity is unaffected.

    Thanks in advance!
     
  2. Best Answer
    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.

    Think of it like this: Your call is a piece of mail that you wish to send to an entity. In order to send your mail, you need to know the address of the recipient. The handler is that address - which in turn recieves the mail you sent.

    So going off of Storm_UK's example to which I will change to make it relevant:
    The problem with your idea though, is there is no easy way that I am aware of to override the init() method to RUN the first portion, because you would have to do that in the init() method within the main lua file for each monster / monster type. I dont have a solution for your particular problem, but this is how you should use it.
     
    zekrom_vale, lornlynx and The | Suit like this.
  3. callScriptedEntity is *NOT* outdated. The difference between callScriptedEntity and sendEntityMessage is that a CSE call is Synchronized (Meaning everything else waits for the call to finish before returning a value) whereas sendEntityMessage is Asynchronous (Meaning fire and forget / dont wait for results to complete and return)

    If you are communicating from object to object, you dont need to make any modifications. If you ARENT, then add the message handler to wrap the callScriptedEntity call like Storm_UK showed you in the initialization method of your object.
     
    Last edited: Aug 25, 2015
    The | Suit likes this.
  4. Errors4l

    Errors4l Spaceman Spiff

    I'm sorry, I thought it was outdated as I had been using the CSE function with it's parameters without problems until the latest stable update.

    I still don't really understand what I'm supposed to be doing. I'm trying to call the function from a tech script (blink.lua), using tech.aimPosition and world.entityQuery to obtain the entity ID.
    Previously, the CSE call worked and killed the entity, now it tells me the entity is not a local master scripted entity. Using the sendEntityMessage function doesn't give this warning, but it doesn't affect the targeted entity either.

    Sorry if I'm just being dumb ;-;.
     
  5. Narks

    Narks Scruffy Nerf-Herder

    It's probably a "security" enhancement to stop server admins from breaking unwanted unbreakable objects or destroying malicious NPCs through tech scripts.

    Try moving it to a non-tech script.

    Edit: doesn't work from a stats script either (player_primary.lua). Looks like griefers are going to have a field day.
     
    Last edited: Aug 25, 2015
  6. Best Answer
    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.

    Think of it like this: Your call is a piece of mail that you wish to send to an entity. In order to send your mail, you need to know the address of the recipient. The handler is that address - which in turn recieves the mail you sent.

    So going off of Storm_UK's example to which I will change to make it relevant:
    The problem with your idea though, is there is no easy way that I am aware of to override the init() method to RUN the first portion, because you would have to do that in the init() method within the main lua file for each monster / monster type. I dont have a solution for your particular problem, but this is how you should use it.
     
    zekrom_vale, lornlynx and The | Suit like this.
  7. Errors4l

    Errors4l Spaceman Spiff

    The problem with that is that there seems to be no restriction on doing things like spawning monsters in via LUA. I just tried spawning a dragonboss via my blink.lua and it worked fine. This means it's only getting easier for (even novice) griefers to cause trouble on servers, with less or even no methods to easily clean up the messes created by them.

    Anyways, thanks for the responses. I guess (for now) there's no way to accomplish my desired result.
     

Share This Page