SquidDev-CC / CCTweaks

Random additions to ComputerCraft (somewhat deprecated, use CC-Tweaked if you're on Minecraft 1.12).
MIT License
12 stars 2 forks source link

/trigger command queues events on command computers #102

Closed dirthsj closed 8 years ago

dirthsj commented 8 years ago

The trigger command is used to set or increment a trigger scoreboard objective. It's only accessible to non-players unless explicitly allowed. In fact, it has to be re-allowed each time they use it, as demonstrated by commenting out line 30 of my CC-Jam 2016 project.

As for the event it would fire, I imagine it would look something like this:

local event, player, objective, newvalue, oldvalue = os.pullEvent( "trigger_command" )
SquidDev commented 8 years ago

Sadly there isn't an easy way to check that an objective has been changed: I'd have to loop through every player/objective combination to see which ones have changed. It is probably easier to handle this on the Lua end. If you use commands.async.* functions you can ensure there is only a 1 tick delay.

dirthsj commented 8 years ago

From the Lua side, it's actually rather annoying. The only way to identify the value is

commands.scoreboard( "players test", playerName, objectiveName, lower, upper )

...which is tedious if you have, for example, 100 different values. You can cut the number of commands down by doing halves (is it between 1 & 50, 1-25, etc.), but you're still guessing. Even if you can't detect when the scoreboard has changed, it'd be great if you could add something to get the value directly (that way I could simply test if it's non-nil).

SquidDev commented 8 years ago

@KingofGamesYami I've opened another issue (#105) with some command related stuff. Feel free to add anything else: though I don't just want to recreate OpenPeripheral's sensor.