Element properties

  • ChargedCreeper
    9th Feb 2021 Member 0 Permalink

    Are element properties using bit masking for the flags?

  • LBPHacker
    9th Feb 2021 Developer 0 Permalink
    They do, and the Lua versions TPT supports don't have bitwise operators, but unless you're modifying existing flagsets, you can just use the addition operator '+' to combine flags, as long as you never use the same flag twice.
  • QuanTech
    9th Feb 2021 Member 0 Permalink
    @LBPHacker (View Post)
    doesn't tpt have the lua 'bit' library which has bitwise operators?
  • LBPHacker
    9th Feb 2021 Developer 0 Permalink
    It does, but it's overkill for what I described, which is the most common use case.
  • ChargedCreeper
    9th Feb 2021 Member 0 Permalink

    Well I managed to find a way to check if a flag is set or not. The bit libarary is in fact what I needed.


    bit.band(tpt.el.stne.properties,elements.TYPE_PART) == elements.TYPE_PART

  • LBPHacker
    9th Feb 2021 Developer 0 Permalink
    Be more specific next time then :P Also, try to avoid using tpt.* stuff, use elem.property(elem.DEFAULT_PT_STNE, "Properties") instead of tpt.el.stne.properties.
  • ChargedCreeper
    9th Feb 2021 Member 0 Permalink

    Is it still bad to use tpt.* in console? I know it shouldn't be done in production code. Also I never noticed that elem can be used instead of elements.

    Edited once by ChargedCreeper. Last: 9th Feb 2021
  • LBPHacker
    9th Feb 2021 Developer 0 Permalink
    It doesn't really matter, but everyone has (should have) more experience with the new APIs and can provide help better if you just use those. The tpt.* API is only (supposed to be) provided for compatibility (except we still add stuff to it like setdrawcap, which we really shouldn't).
    Edited once by LBPHacker. Last: 9th Feb 2021