Jump to content




Block API v0.7

api peripheral

13 replies to this topic

#1 OmegaVest

  • Members
  • 436 posts

Posted 28 February 2013 - 08:38 AM

Hello, and thank you for your interest in OmegasTech's new promotional product, the Block API.

This revolutionary program can turn any block into a peripheral! Wrap it like any other peripheral, and change its settings, or gather its data.

Contact your local OmegasTech representative for a FREE copy of our promotional material.[/salespitch]


Yep, this silly little API can wrap any adjacent block.

Doc:
Spoiler

This is mostly just a silly thing that has, at times, helped me with larger projects. It turned 10 lines into 5 in one section, for instance.

Anyway, if you find this useful, please do not hesitate to pastebin this code, or download it below.

pastebin get nwf10MdP
or
Download


Changelog:
v0.7: Added .call to the
v0.6: Added .pulse to the function list.
v0.51: Fixed 1 error (Thanks Eric)
v0.5: Initial release.

Planned Features (if I find the time):
-- Fix .call (There's some issues I'm working out, but it should work normally anyway)
-- events (coroutines are kicking me you know where)
-- installer (Probably in 1.0)
-- blockPulse(int) Got it!
-- setPower(int) and getPower()


Happy Coding!

PS. All you potential naysayers: I thought it was funny.

#2 Eric

  • Members
  • 92 posts
  • LocationUK

Posted 28 February 2013 - 08:47 AM

I think you're missing a "return bobble" in there somewhere

#3 OmegaVest

  • Members
  • 436 posts

Posted 28 February 2013 - 08:54 AM

...Possibly. Fixing.


EDIT: Fixed. Download locatons didn't change.

#4 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 28 February 2013 - 09:13 PM

Hmmm... Interesting concept of 'wrapping' you got there. Still, not a bad idea though.
At first glance I thought you could detect the id of the block or what ever.

#5 robhol

  • Members
  • 182 posts

Posted 01 March 2013 - 01:45 AM

What would this be used for?

#6 OmegaVest

  • Members
  • 436 posts

Posted 01 March 2013 - 07:50 AM

Well, I used it for an RP2 disco-lights setup, but I'm certain there is a better use for it than that. And probably a less seizure-inducing one.

#7 Minesoft

  • Members
  • 25 posts
  • LocationBelarus, Mogilev

Posted 03 March 2013 - 04:40 AM

Good!

#8 OmegaVest

  • Members
  • 436 posts

Posted 13 March 2013 - 04:15 AM

Small Update: Added .pulse, which will pulse the blocks signal a number of times equal to its first parameter, and will sleep for a number of seconds equivalent to the second parameter, if you choose to provide one. If you do not provide it, the pulse will sleep for .25 seconds.

This update has been applied to the DB link and the pastebin. If you want a pervious version (why, exactly? This didn't break anything, I don't think) PM me and I will send you a link to it.

#9 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 16 March 2013 - 11:23 PM

I think there should be peripheral functions for the block object, such as isPresent(), getType(), getMethods(), call() and wrap()
Also compare, dig, place, attack if the computer is a turtle :)

#10 OmegaVest

  • Members
  • 436 posts

Posted 17 March 2013 - 08:37 AM

Hmm. I'll have to go look at those.

Just out of curiosity, what do you mean by call()?

Also, I should mention that, should I continue to update this (I mean, come on! It's the redstone API with a shell around it!) I'm gonna first work on analog for 1.5. MOAR DISCO LIGHTS!

#11 Jan

  • Members
  • 141 posts
  • Locationthe Netherlands

Posted 17 March 2013 - 08:44 AM

 OmegaVest, on 17 March 2013 - 08:37 AM, said:

Just out of curiosity, what do you mean by call()?
It's a function in the peripheral API. for example to write hello on a screen: peripheral.call("left","write","hello")

#12 OmegaVest

  • Members
  • 436 posts

Posted 17 March 2013 - 08:51 AM

Ah. Maybe.

#13 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 18 March 2013 - 08:49 PM

 OmegaVest, on 17 March 2013 - 08:37 AM, said:

Just out of curiosity, what do you mean by call()?
It's what people used before we had this newfangled peripheral.wrap function.

#14 OmegaVest

  • Members
  • 436 posts

Posted 19 March 2013 - 10:17 AM

Oooookay! So, after this little discussion, and the inspiration for all this condescends in my thread, I add .call(side, func, params[not a table, working on it]). There's a surprise in there, even. No changes in location, previous versions still available.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users