I'll make stuff clearer, here's an example and I will run it with both AppGameKit Studio and AGK2.
// Project: FileExploreExample
// Created: 22-09-04
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "FileExploreExample" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
#import_plugin FileExplore as FE
global debugText as integer
global filenameList as string[]
do
if GetRawKeyReleased(27) then exit
if GetRawKeyReleased(32) then GetFilenames()
print("Press Space to open File Dialog")
ShowFilenames()
Sync()
loop
function GetFilenames()
local fileTypes as string = "*.jpg;*.png"
local filenameCount as integer
local filename as string
local filenames as string
local fullPath as string
filenameList.length = -1
filenames = FE.ChooseFileDialog("GetSomeFiles", fileTypes, 1)
fileNameCount = CountStringTokens(filenames, "|")
for i = 0 to filenameCount
filename = GetStringToken(filenames, "|", i)
fullPath = "raw:" + GetStringToken(filenames, "|", 1) + filename
if i >= 2 and filename <> ""
filenameList.insert(fullPath)
endif
next i
endfunction
function ShowFilenames()
ClearDebugText()
SetDebugTextPos(10, 100)
AddDebugTextLine("")
AddDebugTextLine("Filename Count: " + str(filenameList.length))
AddDebugTextLine("")
if filenameList.length >= 0
for i = 0 to filenameList.length
AddDebugTextLine(filenameList[i])
next i
endif
endfunction
function AddDebugTextLine(text as string)
local newText as string
if not GetTextExists(debugText) then debugText = CreateText("")
newText = GetTextString(debugText) + chr(10) + text
SetTextSize(debugText, 18)
SetTextLineSpacing(debugText, -6)
SetTextString(debugText, newText)
SetTextVisible(debugText, 1)
SetTextDepth(debugText, 0)
endfunction
function ClearDebugText()
if GetTextExists(debugText) then SetTextString(debugText, "")
endfunction
function SetDebugTextPos(x as float, y as float)
if not GetTextExists(debugText) then debugText = CreateText("")
SetTextPosition(debugText, x, y)
endfunction
AGK2 shows the plugin commands in the IntelliSense dialog:
But fails to compile:
AGK Studio fails to show the plugin commands in the IntelliSense dialog:
But runs the code fine: