[API] event.player:enableMarkingSelector's callback function never called

A big new update is now available, introducing biomes, caves and much more!
Latest hotfix: 0.7.0.3 (2024-02-21)
  • We've had an issue a few days ago where an admin screwed up (LOL you know who you are!) big time by not completing a selection before calling a World Edit command... which resulted in using a previous coordinate and filling up a few hundred meters of blocks, destroying most of the map; he basically started a selection, but never selected an end point, which used (probably) a previous end point a few hundred meters from there.


    While I agree that he screwed up on that, it made me wonder if I could receive feedback from


    Code
    event.player:enableMarkingSelector(function()
    -- receive feedback here about the selection???
    end);


    But the function is, actually, never being called! When reading the API, it is in fact required to pass a function... so... what's the function used for, then? :P


    My guess was that it was being called once an end point was selected, no? Could be nice if that was it's purpose. Then, we could validate the a full selection was being made before calling event.player:disableMarkingSelector, no?

  • It's true, the callback function is never called. We will fix that with the next update ;)
    It was intended that the callback function is called when the client "successfully" enabled the marking selector, so the only thing you know at that moment is that the client actually is in "selection" mode.
    You could use event.player:disableMarkingSelector, the provided callback function is called once the client actually disabled selection mode. Also an information about the area size (or in other words, the coordinates of the start- and endpoint) is provided as a parameter, so this is basically the right place to check if the selected area is valid :)

  • Thanks. However I'd like to know when an end point has been selected, somehow (i.e. know if the user has selected both endpoints when calling disableMarkingSelector). Can this be possible?


    In other words, what are the members of the lua.callbacks.MarkingSelectorStatus class?

  • You can access these variables:


    [lua]player --Player object
    startChunkpositionX --Chunkpos X (start)
    startChunkpositionY --Chunkpos Y (start)
    startChunkpositionZ --Chunkpos Z (start)
    startBlockpositionX --Blockposition X inside this chunk (start)
    startBlockpositionY --Blockposition Y inside this chunk (start)
    startBlockpositionZ --Blockposition Z inside this chunk (start)
    endChunkpositionX --Chunkpos X (end)
    endChunkpositionY --Chunkpos Y (end)
    endChunkpositionZ --Chunkpos Z (end)
    endBlockpositionX --Blockposition X inside this chunk (end)
    endBlockpositionY --Blockposition Y inside this chunk (end)
    endBlockpositionZ --Blockposition Z inside this chunk (end)[/lua]


    If start and endposition are not defined, you receive a "false" as markingStatus. When only a startpoint is defined, and no endpoint, it uses 0 for the endpoint =O We will change this with the next update, so that it only returns a valid result when both start and endposition are defined.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!