Jump to content

Helpful API to aid scripting and make it easier.


Cory

Recommended Posts

Wrote a small API and any methods i used or needed i added to it, built up a collection, I start university on monday so figured i would release it it for you lot to use/learn from etc.

 

Javadocs:

http://novumscripts.com/api/

 

Src:

https://github.com/NovumScripts/CoryAPI

 

Jar:

https://www.dropbox.com/s/6z7nbjjnd19yu5i/API.jar

 

Src Download:

https://www.dropbox.com/s/4c6wyxa6vcg72fp/osbot.zip

 

Thanks are appreciated, any suggestions or changes, or additions you feel should be added, let me know.

 

P.S: I'm not saying its immaculately programmed, or that I've used the best techniques etc, just a collection of handy methods for you to use.

 

 

  • Like 5
Link to comment
Share on other sites

LinkedList<NPC> valid = new LinkedList<NPC>();

just a few tips

you should use an ArrayList for this, LinkedLists use up too much memory, and it should be used if you were going to add and remove (LinkedLists are faster than ArrayLists for removing), in this case you were only adding.

 

But ArrayList#add is O(n) worst case (when it has to resize) and LinkedList is constant time for adding.

 

However if you're going to critique his List implementation of choice I think a far better suggestion would be for him to program to the interface not the implementation.

 

@Cory, MethodContext should extend MethodProvider not Script (a MethodContext is not a script)

 

By making the fields public in your MethodContext you have made your API brittle. What if you decide to make MethodContext thread-safe or perform additional checks before returning a field? You can't without breaking people's code. This is why encapsulation is important.

 

I'm not sure why you named your package impl - what is it an implementation of?

 

I would suggest documenting all your classes - I'm not sure what the ObstacleListener's purpose is.

 

Those are my suggestions from a brief look. Hope it helps.

Link to comment
Share on other sites

 

LinkedList<NPC> valid = new LinkedList<NPC>();

just a few tips

you should use an ArrayList for this, LinkedLists use up too much memory, and it should be used if you were going to add and remove (LinkedLists are faster than ArrayLists for removing), in this case you were only adding.

 

But ArrayList#add is O(n) worst case (when it has to resize) and LinkedList is constant time for adding.

 

However if you're going to critique his List implementation of choice I think a far better suggestion would be for him to program to the interface not the implementation.

 

@Cory, MethodContext should extend MethodProvider not Script (

 

I would suggest documenting all your classes - I'm not sure what the ObstacleListener's purpose is.

 

Those are my suggestions from a brief look. Hope it helps.

 

 

Thanks, a lot of this I already knew and was aware off. A lot of the code released was simply quick fixes or methods i wrote and never really adapted. My intentions were to get them working, regardless of whether i was using best practices as i do most of my programming on scripts late at night, when im tired at like 6am before i go to sleep. I do plan to go over everything and fix all the issues that im aware off with the way i have done certain things, but atm im getting ready for 2nd year of university etc so working on a scripting api isn't high on my priority list :D

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...