Skip to content

Instantly share code, notes, and snippets.

@desht
Last active August 1, 2021 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save desht/2a669e394f7a0ca02609887c857bb9f7 to your computer and use it in GitHub Desktop.
Save desht/2a669e394f7a0ca02609887c857bb9f7 to your computer and use it in GitHub Desktop.
PneumaticCraft player-global variables

Player globals

  • Existing prefix "#" for global variables now means "player-global" variables
  • New prefix "%" for global variables means "server-global" variables - shared among all players on a server, like "#" globals used to be
  • GPS Tool, GPS Area Tool and Remote items which have global variable names in their saved NBT will have those saved var names updated with a "#" prefix when first accessed
    • Previously these items just stored an unprefixed variable name
  • GPS Tool and Remote GUI's now allow specification of "#" or "%" as a prefix for global variables where they are entered
  • Player-global and server-global variables can exist with the same name, e.g. #var1 and %var1 can both exist, and are separate variables
  • Existing global variables in a older world will appear as server-global
    • This may cause backwards compat issue with existing programs that refer to a previously-set value for a global variable (since a query for #var1 now references a player-global, which won't exist initially)
    • Mitigation: there is a /pncr global_var import command which imports all existing server global vars into your player-global var space. This command can be run only once per player per server, and is intended as a backwards-compatibiliy migration tool.
    • This command will go away in the next major MC release (1.17/1.18) since it's just for legacy compat
    • On a server where multiple people have been using global variables, a bit of manual cleanup is going to be necessary, unfortunately. This is largely unavoidable.
  • Command syntax has been overhauled
    • Got rid of old /dumpNBT, setGlobalVar, getGlobalVar and amadrone_deliver commands
    • Everything is now under new /pncr command (/pncr dumpNBT, /pncr amadrone_deliver, /pncr global_var ...)
    • Global variable handling is now under /pncr global_var command:
      • /pncr global_var list lists all defined server and player globals (for the player issuing the command)
      • /pncr global_var get #varname or /pncr global_var get %varname displays the value of a player- or server-global variable, respectively
      • /pncr global_var set #varname <pos-or-item-id> sets a player-global variable (and of course %varname for a server-global)
      • /pncr global_var delete #varname (or %varname) deletes a global variable from memory. Note this is not the same as just setting it to (0,0,0) as in earlier versions. There is a better distinction now between "undefined" and (0,0,0), which will be more important in 1.17/1.18
      • /pncr global_var import - see above for details of this temporary command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment