Jump to content




skyTerm

api command utility

16 replies to this topic

#1 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,095 posts
  • LocationTasmania (AU)

Posted 19 April 2015 - 04:15 AM

pastebin get Wq132HyT skyTerm

Another "just for giggles"-type-script. This one's an API for Command Computers; somewhat similar to the window API, it offers one function, "create", which returns a terminal object.

The object in concern is the sky.

For now, only your current background colour is rendered (using wool blocks), though this still allows for some interesting "drawings" to be made.

Usage

Because you'll typically want to be able to see your main display while using this, you'll probably want to create an aggregated terminal object out of it, eg:

Example

It does have a rather notable flaw in that, because commands.execAsync() can't be trusted to execute asynchronously, it needs to yield on all writes. This means you'll need the likes of the parallel API to use it reliably alongside eg timers and the like.

Screenshots

Edited by Bomb Bloke, 10 February 2016 - 11:11 PM.


#2 Lupus590

  • Members
  • 1,952 posts
  • LocationUK

Posted 19 April 2015 - 01:55 PM

here's a challenge for you, get your sky monitor touch compatible

you could do this by checking for screen blocks being destroyed (or have glass in front as a touch layer)

#3 ItsRodrick

  • Members
  • 72 posts
  • Location= gps.locate() or "unknown"

Posted 20 April 2015 - 12:14 AM

Great program! Following Lupus' suggestion you could make a layer with 'block 36', or 'piston_extension'. Its invisible and non-solid, and when you right-click it, it dissapears.

Edited by RodrickLord, 20 April 2015 - 12:16 AM.


#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,095 posts
  • LocationTasmania (AU)

Posted 20 April 2015 - 01:14 AM

Heh; the catch there is that users would need to run a coroutine (eg a secondary multishell tab) alongside their scripts in order to pick up on the clicks... Still, the piston thing sounds cool enough to make me want to try it.

I suppose the way to go would be to register a ton of test conditions into the scoreboard, each rigged to generate a unique block directly above the Command Computer. The system itself then only needs to keep checking that one position, to see which block is placed there - it can then map block type to a screen co-ordinate.

Of course, that involves defining a table of blocks to check against... something like a thousand of the things!

The other option would be to have the Command Computer itself check the entire front facing of the "display". I suppose that wouldn't be too awful - something like six seconds to detect a click, I think? - but it still wouldn't exactly be "usable"...

#5 Wojbie

  • Members
  • 630 posts
  • LocationKinda lost

Posted 20 April 2015 - 06:43 AM

Not sure if its doable in 1.7 but in 1.8 you could get player position and angle they are looking at + detect that they used dongle prop and calculate what block they where looking at.

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,095 posts
  • LocationTasmania (AU)

Posted 20 April 2015 - 10:07 AM

Er, you can? I've got a vague idea you might be able to get the scoreboard to act on that sort of data, but how would you pass it on to a command computer?

#7 Wojbie

  • Members
  • 630 posts
  • LocationKinda lost

Posted 20 April 2015 - 10:58 AM

A bit hacky but set different blocks above the computer using scoreboard tests. Then just test what block is above computer?

I am not a commandblock expert thought and this is all 1.8 theory-crafting

Edited by wojbie, 20 April 2015 - 06:24 PM.


#8 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 20 April 2015 - 05:06 PM

How do you get the angle the player is looking at?

#9 ItsRodrick

  • Members
  • 72 posts
  • Location= gps.locate() or "unknown"

Posted 20 April 2015 - 06:25 PM

In 1.8 you can use target selectors:
@a[x,y,z,rx=0,rxm=100,ry=0,ry=100]
rx, rxm = vertical rotation, min and max
ry, rym = horizontal rotation, min and max

If anyone wants to know more: Minecraft Wiki -> Commands

(And yeah, I've played a lot in the snapshots)

Edited by RodrickLord, 20 April 2015 - 06:30 PM.


#10 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 20 April 2015 - 06:31 PM

Then I would need to loop through all the rotations?

#11 Wojbie

  • Members
  • 630 posts
  • LocationKinda lost

Posted 20 April 2015 - 07:18 PM

Or define ranges that look at same character from player position and check into witch of those player is looking at the time. Hello Trigonometry!

#12 ry00000

  • Members
  • 244 posts
  • LocationComputer, Base, SwitchCraft, Cube-earth, Blockiverse, Computer

Posted 08 May 2015 - 02:08 PM

THis is cool, but try to make it touch!
//offtopic: ry = 3 That's my name!

#13 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,095 posts
  • LocationTasmania (AU)

Posted 08 May 2015 - 02:59 PM

The truth of the matter is that a touchscreen just isn't very useful if you can't read text on the display. ;)

Which I do plan to change, but command computer commands are currently bugged in such a way that they mess with the event queue - events randomly don't get through while commands are resolving. And to stop the computer-crashing amount-of-commands-running-at-the-same-time limit from being reached, this thing has to make sure the queue empties properly with every line you write...

Long story short, I'm unlikely to add anything to this so long as that bug's around, as it's currently not good for much other than drawing single pictures around your landscape. It'd still be pretty slow, anyway.

#14 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 12 October 2015 - 03:27 PM

Awesome! Just one thing, you could make the window also display on the terminal, then when you click in the terminal, it clicks in the world. Also, just imagining OneOS in the sky. :P

#15 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,095 posts
  • LocationTasmania (AU)

Posted 12 October 2015 - 10:01 PM

View PostLewisTehMinerz, on 12 October 2015 - 03:27 PM, said:

Just one thing, you could make the window also display on the terminal, then when you click in the terminal, it clicks in the world.

The Example code snippet up in the OP demonstrates how you might do that.

#16 Lego Stax

  • Members
  • 136 posts
  • LocationThe dark depths of the web

Posted 25 November 2015 - 10:58 PM

Here's a suggestion. Add the ability to customize the color palette. i.e. instead of having gray = gray wool, gray = stone bricks. In addition, add the ability to change the orientation. i.e. parallel to the ground, perpendicular to the ground, maybe even change direction: north, south, east, west. This way, builders could save time building things.

Just a thought. :)

#17 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,095 posts
  • LocationTasmania (AU)

Posted 26 November 2015 - 02:04 AM

It's already possible to pick a facing, but not an angle.

In regards to "building" things, I'd been considering a dedicated script for that purpose. You'd want the ability to pick materials on the fly. Catch is figuring out what materials are available; MoarPeripherals had an Item Dictionary block that would've been great for the purpose, but it was eventually disabled and I'm not aware of anything similar.

In regards to the palette for "drawing" things, I could indeed rig up an interface for using other blocks. I've been scratching my head over how to do it, though.

For example, this slide puzzle has somewhere over 100 colours available by way of different blocks. Not all of them work outside of hologram projectors (due to gravity suddenly kicking in against eg sand), but that's still a semi-decent count.

Catch is the system for drawing isn't easily made compatible with your regular ComputerCraft terminal command set, as you can't so readily apply the colours API to it.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users