Run the project, now the string is returned from the plugin, Yay$=mp.MyFunction("AppGameKit", "Would you like to learn more?") SideNote, there is a full function wrapper attached to this post, I am showing it this way so you understand what's going on in the code. Yay=mp.MyFunction("AppGameKit", "Would you like to learn more?")Īnd there you have it, sending and receiving data to/from a pluginįloats and Integers can be returned directly but we have to handle strings a little different.įor this we head back into PureBasic and the ReceiveAGKPtr function, we need to import some string functions, for this we use the _GetAGKFunction prototype we setup earlier Now go back to the PureBasic file and change the function to: If we had 2 string and an integer we would stack them like so: MyFunction,0, SSI,MyFunction,0,0,0,0,0 This tells AppGameKit we want to send 1 string argument to the pkugin (S=String, I= Integer, F = Float) Ok so now lets send in some arguments, go back to the Commands.txt fileĬhange : MyFunction,0,0,MyFunction,0,0,0,0,0 Now hit run, you should see a dialog box with a message "Hello from a PB plugin"Ĭongrats you have made your first Plugin. UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices SetVirtualResolution( 1024, 768 ) // doesn't have to match the window SetWindowAllowResize( 1 ) // allow the user to resize the window When AppGameKit loads the plugin it looks for a function 'ReceiveAGKPtr', this function is called by the runtime and sends the full set of function pointers to the plugin, we will setup this function but not use it yet, this function must exist for the plugin to work so we set this us with a C prototype If everything is good, we can add some code, if something went wrong, check each step and try again. You can add both if you want to compile for both systems but set your preferred as default (I set classic) (checkbox at bottom of compile targets list) and set the other 'Studio' Enable in build all targets, now we can compile our plugin for both Classic and Studio at a single button click, handy stuffĬlick OK in the dialog, you are now greeted with an empty code page, first lets test our compile targets to make sure we got it right, go to the main menu, click Compiler>Build All Targets, a dialog will appear and tell you what's going on, when its done you should now have a new DLL in the plugin folder (you will need to launch PureBasic with admin rights to compile to the Program Files folder) Studio: C:\Program Files (x86)\The Game Creators\AppGameKit Studio\Plugins\myPlugin\Windows.dll Set the input file to the main.pb file that was created with the project and set the output executable to :Ĭlassic: C:\Program Files (x86)\The Game Creators\AGK2\Tier 1\Compiler\Plugins\myPlugin\Windows.dll Now we need to set the compile targets, in the 'Project Targets' list, right click 'Default Target' and click 'Edit Target', this opens the project compiler options. Use the project creation dialog to add a file, call it main.pb and click the 'Create Project' button, this will open the project overview tab. Now, Open PureBasic (x86 - 32 Bit, we will deal with 64 bit later) and create a project, again call it myPlugin and save it where ever you save your PB stuff, We will worry about what this content means in a bit, lets get something working first. #CommandName,ReturnType,ParameterTypes,Windows,Linux,Mac,Android,iOS,Windows64
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |