Mythruna

Modder's Workbench => Scripting => Topic started by: Michael on July 03, 2013, 03:52:47 PM



Title: Pre-Alpha API
Post by: Michael on July 03, 2013, 03:52:47 PM
Mythruna Pre-Alpha API

This is a documented API I have created for the convenience of having it for everyone, until the new API Paul is working on comes out. This is practically to get everyone started with modding Mythruna, and will be continued until Paul releases his own.

Find the API examples on Github:
Java (https://github.com/Shzylo/Mythruna-API/tree/master/examples/java)
Groovy (https://github.com/Shzylo/Mythruna-API/tree/master/examples/groovy)

If you would like to help with the API, you can via Github!



Title: Re: Pre-Alpha API
Post by: nh_99 on July 03, 2013, 07:10:59 PM
As a comment on you saying to leave that null on the command, that is FULL command description I think so you can set it to a map(String[] advancedHelp = new String[] { "Hello world!" };) that has that in it.


Title: Re: Pre-Alpha API
Post by: Michael on July 03, 2013, 07:24:36 PM
Hmm, this is a rough draft that a grabbed by looking at the first 2 tutorials that paul gave, and looking at some of his default scripts generated by the server, I am basing everything practically off of mods that people make and the examples Paul has gave. Thanks for the info!


Title: Re: Pre-Alpha API
Post by: pspeed on July 03, 2013, 08:04:57 PM
Yeah, the last argument is the "help" that gets printed when you do "help command" in the console.  It's a String[] basically.

This part of the API will definitely be tightened up soon.  I've learned a lot more about groovy integration since then.


Title: Re: Pre-Alpha API
Post by: Michael on July 03, 2013, 08:09:33 PM
Yeah, the last argument is the "help" that gets printed when you do "help command" in the console.  It's a String[] basically.

This part of the API will definitely be tightened up soon.  I've learned a lot more about groovy integration since then.

Oh, thank you for the help, and by the way, I pulled out 24 groovy scripts from your Mythruna-Core.jar because I remembered when I went looking onto that when I was completely lost about groovy, including when I looked into one of gara's mod and I saw an import I didn't recognize, or a method or something in his code I never saw posted before, and went diggin to all those scripts.


Title: Re: Pre-Alpha API
Post by: pspeed on July 03, 2013, 09:17:57 PM
Yeah, the last argument is the "help" that gets printed when you do "help command" in the console.  It's a String[] basically.

This part of the API will definitely be tightened up soon.  I've learned a lot more about groovy integration since then.

Oh, thank you for the help, and by the way, I pulled out 24 groovy scripts from your Mythruna-Core.jar because I remembered when I went looking onto that when I was completely lost about groovy, including when I looked into one of gara's mod and I saw an import I didn't recognize, or a method or something in his code I never saw posted before, and went diggin to all those scripts.

It's fine to look at these for learning... just remember, I don't always do things the best way in the heat of the moment. :)

I know most of these scripts will get replaced so sometimes I don't bother to clean them up properly.  As APIs evolved, some scripts still do things the old ways.  Still can be useful in lieu of docs, though.


Title: Re: Pre-Alpha API
Post by: Michael on July 03, 2013, 09:24:02 PM
Ahah, I went to look up how to make javadocs, and then I figured it out! I sat down for a couple seconds like "umm.. wait.., I don't have the source code.." do I need the actual source code of Mythruna to make actual JavaDocs?


Title: Re: Pre-Alpha API
Post by: pspeed on July 03, 2013, 10:17:16 PM
Ahah, I went to look up how to make javadocs, and then I figured it out! I sat down for a couple seconds like "umm.. wait.., I don't have the source code.." do I need the actual source code of Mythruna to make actual JavaDocs?

Pretty much.  Using the javap command you can find out what methods certain classes have but really the farther you stray from what is already called by my scripts the worse off you will be.  Those scripts are already going to change significantly but the Java code is nearly 100% different.


Title: Re: Pre-Alpha API
Post by: Michael on July 03, 2013, 10:24:03 PM
I have started a repository on GitHub for tutorials, ect about this API I got going :)
https://github.com/Shzylo/Mythruna-Pre-Alpha-API/

Now its midnight, I need to go to bed (but I don't wanna!).


Title: Re: Pre-Alpha API
Post by: nh_99 on July 04, 2013, 01:39:12 PM
You need to change the helpInfo thing to String[] helpinfo. String arrays and Strings are 2 different things. Sorry to be a stickler about it, I just want people who are looking at this API stuff to have the right info.


Title: Re: Pre-Alpha API
Post by: Michael on July 04, 2013, 01:54:29 PM
You need to change the helpInfo thing to String[] helpinfo. String arrays and Strings are 2 different things. Sorry to be a stickler about it, I just want people who are looking at this API stuff to have the right info.
I did that, but I found that it bugged for me, I even went too groovy codehaus to make sure I was doing it right. I went and looked into one of Paul's groovy files and this is basically how he had it:

Code:
def help = """\
        This is the help info
        Here is more help info
        """

addShellCommand(shell, "Hello", "Justa test", help) {
    console.echo("Hello World!");
}

I will be doing some other testing after 7, because my grandma has OG&E smart hours, and between hours 2pm - 7pm, its called peak hour in which electricity consumption costs more (today its $0.05 per Kilowatt).


Title: Re: Pre-Alpha API
Post by: Sean on July 04, 2013, 06:46:19 PM
Nice job on the API!


Title: Re: Pre-Alpha API
Post by: Michael on July 04, 2013, 07:49:40 PM
Updated with a fix to one of the examples on github and added correct imports for the methods.


Title: Re: Pre-Alpha API
Post by: pspeed on July 04, 2013, 10:22:31 PM
Now that I think about it, I think the help is just a string and then I split it up on newlines.  The API is defined in one of the groovy files embedded in the game jar so it would be easy to confirm the exact signature of the method.


Title: Re: Pre-Alpha API
Post by: Endimmion on July 05, 2013, 02:06:31 AM
With this API, would it possible to add a sort of "query answer" plugin? You query the server with a certain command/string and the plugin return you the number of players connected, the version of the server....

It could be very usefull for my list (http://mythruna-servers.com/).


Title: Re: Pre-Alpha API
Post by: pspeed on July 05, 2013, 02:19:43 AM
With this API, would it possible to add a sort of "query answer" plugin? You query the server with a certain command/string and the plugin return you the number of players connected, the version of the server....

It could be very usefull for my list (http://mythruna-servers.com/).

This is the API for game plugins, server or client.  You could write a plugin that wrote that information to a file (that's what my server status page does) or whatever.  It's not the game server's job to handle these sorts of requests really as its better handled externally.  The hooks let you catch and write the latest data, though.


Title: Re: Pre-Alpha API
Post by: Endimmion on July 05, 2013, 03:25:18 AM
This is the API for game plugins, server or client.  You could write a plugin that wrote that information to a file (that's what my server status page does) or whatever.  It's not the game server's job to handle these sorts of requests really as its better handled externally.  The hooks let you catch and write the latest data, though.


This solution is only valid if you host your server and the status page on the same server. If someone register his server on the list, he need to give me access to his file system to be able to know how many players are on his server. That's not imaginable.

So in the future, server owner will have to use such a complicated method just to be able to get something so simple as the number of players connected?


Every game with a server for the past years has a query protocol. I don't really understand the problem you have with that.



Title: Re: Pre-Alpha API
Post by: pspeed on July 05, 2013, 11:51:05 AM
This is the API for game plugins, server or client.  You could write a plugin that wrote that information to a file (that's what my server status page does) or whatever.  It's not the game server's job to handle these sorts of requests really as its better handled externally.  The hooks let you catch and write the latest data, though.


This solution is only valid if you host your server and the status page on the same server. If someone register his server on the list, he need to give me access to his file system to be able to know how many players are on his server. That's not imaginable.

My server and status page are on two different servers and I transfer the status page over to the web server as part of the update.  It was the easiest way for me to get it working.

So in the future, server owner will have to use such a complicated method just to be able to get something so simple as the number of players connected?

Every game with a server for the past years has a query protocol. I don't really understand the problem you have with that.

Anyone can add this as a mod.  However, in general it's the single easiest way to DoS a server, too and a pretty large time sink on my part to get it "right".  I have other parts of the game to worry about at the moment.

A server list service could also support a REST API that the server could call to update it with recent info periodically.  There are a variety of ways to implement this feature and nothing stops a modder from doing it themselves.

However, the API discussed in this thread is for mods to access.  It's part of what a "server status mod" would use to do its job but it is not remotely query-able info on its own.  A mod that wanted this support would have to add it... and it's a completely different network connection type than the normal game connection.


Title: Re: Pre-Alpha API
Post by: Michael on July 05, 2013, 12:00:13 PM
I actually went ahead and added Paul's Mythruna-Core.jar to my build path on eclipse. :P
Later (or alpha) I may mess with the Mythruna-Client.jar to change up some of the client designs :)


Title: Re: Pre-Alpha API
Post by: Michael on July 24, 2013, 07:20:38 AM
I would like to note that if anyone would like to help to make this pre-alpha api and contribute to it, visit the github repo @ https://github.com/Shzylo/Mythruna-Pre-Alpha-API.. (https://github.com/Shzylo/Mythruna-Pre-Alpha-API/tree/master/examples) and add a new file, edit one, ect. Thank you if you decide to help :)


Title: Re: Pre-Alpha API
Post by: Michael on September 14, 2013, 08:35:17 AM
I have started to write the API in java as well, and all I have to show are examples on github now. If you don't like just having the examples, please give me some feedback about it, and if you guys know about any good free websites with rich-text editors it would be nice for you to inform me, ESCPECIALLY if it has a code block thing ;)