Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Running GiderosPlayer from batch file - Gideros Forum

Running GiderosPlayer from batch file

antixantix Member
edited November 2020 in General questions
After some messing about I can get a project running in the player using the command prompt by entering the following commands...
c:\gideros\tools\gdrbridge.exe setip 127.0.0.1
c:\gideros\giderosplayer.exe
c:\gideros\tools\gdrbridge.exe isconnected
c:\gideros\tools\gdrbridge.exe play c:\gideros\woah\woah.gproj
Now this works fine when I am typing manually the commands one by one at a command prompt. If however, I save the above commands as a .bat file, when I execute the bat file, it freezes directly after the player is started. On closing the player, the script continues and the other commands are executed.

The issue is that because the player is now closed... the project is not run.

Can anyone help me figure out why manually typing works, but the same stuff in a batch file does not?

Just FYI I'm messing about with this in the hope that I can ditch Zerobrane Studio and start using Visual Studio Code (VSC) as my code editor. If I can get the player running code from within VSC then I will also try to create a project editor to add files and such, and create (or hack) a language extension for VSC to have tasty code completion and stuff for Gideros.

Likes: MoKaLux

+1 -1 (+1 / -0 ) Share on Facebook
«13

Comments

  • keszeghkeszegh Member
    Accepted Answer
    your plans are tasty indeed.
    probably when run from batch file it runs too fast, i think in zerobrane gideros code there is a delay e.g. between the lines. there should be some nicer and more dependable solution, though.

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
  • hgy29hgy29 Maintainer
    edited November 2020 Accepted Answer
    Looks like the batch file waits for player termination to proceed, isn’t there a way to launch a task asynchronously on windows ? Same as having a & at the end of the command on Linux..

    Edit: seems like ‘start’ command is the answer

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
  • MoKaLuxMoKaLux Member
    edited November 2020
    funny enough I just wrote a batch script today :smile:

    rem note: replace the names below with your own..
    rem @echo off
    rem start "my title" /B "c:\program files\mycommand.exe"
    rem start notes.txt
    start "xxx" /B "C:\PORTABLES\tools\Clavier\Clavier.exe"
    start "yyy" /B "C:\PORTABLES\tools\SideSlide_v4.79_Portable\SideSlide\SideSlide.exe"
    rem @echo on

    note: rem is equivalent to --
    note2: "xxx" we need a title for the window
    note3: /B is for closing the terminal window

    Likes: antix

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 ) Share on Facebook
  • antixantix Member
    edited November 2020
    Thanks guys :)
    ECHO OFF
    c:\gideros\tools\gdrbridge.exe setip 127.0.0.1
    start c:\gideros\giderosplayer.exe
    timeout /T 2 /NOBREAK >nul
    c:\gideros\tools\gdrbridge.exe play c:\gideros\woah\woah.gproj
    Running the player using "start" and adding a delay has made it work... from the batch script its self at least :)

    Likes: MoKaLux

    +1 -1 (+1 / -0 ) Share on Facebook
  • antixantix Member
    edited November 2020
    I've updated my script which now finds the .gproj file in the current directory, so there is no hard coding involved.
    :: Lets see all of the gorey details
    ECHO ON
     
    :: Set the path of the gideros installation
    set giderospath=c:\gideros
     
    :: Launch the bridge
    %giderospath%\tools\gdrbridge.exe isconnected
     
    :: Launch the player in a separate process, thanks <a href="/profile/hgy29">@hgy29</a>
    start %giderospath%\giderosplayer.exe
     
    :: Output the .gproj filename to a text file
    dir /B *.gproj > temp.txt
     
    :: Load the gproj filename into a variable
    set /p project=<temp.txt
     
    :: Delete the temporary file
    del temp.txt
     
    :: Wait for 2 seconds, thanks <a href="/profile/keszegh">@keszegh</a>
    timeout /T 2 /NOBREAK >nul
     
    :: Launch the project inside the player
    %giderospath%\tools\gdrbridge.exe play %project%
     
    :: Unset the project variable
    set project=
    If anyone knows of a way to set a variable from the dir commands output without having to save it to a text file first, please let me know. I'm not very good with MSDOS language :D

    Likes: MoKaLux

    +1 -1 (+1 / -0 ) Share on Facebook
  • In my script I use the timeout command but when making launch scripts for Visual Studio Code, it does not allow any redirection and terminates the script.

    Hey would it be possible for gdrbridge.exe to have the ability to wait for a specified number of ms before performing the action you wanted it to?

    So the command "gdrbridge.exe delay 2000 isconnected" would wait for 2 seconds before performing the "isconnected" action.

    My current workaround is to have a separate dos command in the folder that gets called but that's kind of s**t ;)

    Likes: keszegh

    +1 -1 (+1 / -0 ) Share on Facebook
  • i'm happy with zbs, but would be quite interested in trying out vscode as a gideros editor.
  • hgy29hgy29 Maintainer
    @antix, I don’t know what you can do in VS code action scripts, but maybe you can set delays directly from JavaScript and call each command individually instead of relying on a batch script.
  • @hgy29 VSC is not able to actually run any code inside its launch scripts, that would really make it easy. If it can't be implemented in gdrbridge (which already has some code in there to sleep) I can just use my lame workaround :)

    Would you be able (if you know) to explain quicjly how debugging works in Gideros? For example when I print something in one of my apps... what happens? Does it get sent to some tcpip listener or something?

    @keszegh once you get use to the features of VSC like auto-filling for parenthesis and so forth in VSC, it's really hard to go back to ZBS :D
  • antix said:

    @keszegh once you get use to the features of VSC like auto-filling for parenthesis and so forth in VSC, it's really hard to go back to ZBS :D

    Yes but how do you add your pluggins then? Gideros studio for me even though VSC is the trend.
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • antixantix Member
    edited November 2020
    @Mokulax Well with Zerobrane Studio you still have to use Gideros Studio to manage your project (add assets and plugins). The gproj file format is quite basic so if I can get Gideros implemented inside VSC as a language and get basic debug output working... I'll have a go at creating a GUI inside VSC to manage Gideros projects.

    Likes: MoKaLux

    +1 -1 (+1 / -0 ) Share on Facebook
  • hgy29hgy29 Maintainer
    @antix, I'd like to work with you regarding VSCode<>Gideros integration, I just don't really know where to start. Do you have you can share already ?
  • hgy29hgy29 Maintainer
    antix said:


    Would you be able (if you know) to explain quicjly how debugging works in Gideros? For example when I print something in one of my apps... what happens? Does it get sent to some tcpip listener or something?

    The Studio connects to the Player through TCP (on port 15000 usually), then they both exchange packets whenever required. Each packet starts with a single byte (packet type), followed by a variable number of bytes depending on the type.
    Typical commands are:
    - Sending a file from the studio to the player
    - Running the game in the player
    - Sending 'print' data from the player to the studio

    They are not documented, so one must take a look at Gideros code to understand the format of the packets, but they are generally simple.
    I added definitions for the packet type last year here: https://github.com/gideros/gideros/blob/master/libnetwork/libnetwork.h#L11

    For actual implementations in Gideros, you should look at desktop player and studio code. For example https://github.com/gideros/gideros/blob/master/player/Sources/glcanvas.cpp#L200 for the function that sends lua 'print' to the studio

    Likes: MoKaLux, antix

    +1 -1 (+2 / -0 ) Share on Facebook
  • @hgy29 thanks for that valuable information. I'll have a look and see what I can see :)

    I don't have anything to share yet as I have just got my launch script working inside VSC. I am finding the task of creating anything for VSC rather challenging to say the least. Whilst there is a lot of documentation, it's really not geared towards a beginner. I'll keep trying for now and post whatever I come up with here :)

    Regarding the studio code.. there doesn't seem to be a folder for it as there is for player, gdrbridge, etc. Is the source for the studio just scattered throughout the repository?
  • hgy29hgy29 Maintainer
    antix said:


    Regarding the studio code.. there doesn't seem to be a folder for it as there is for player, gdrbridge, etc. Is the source for the studio just scattered throughout the repository?

    Look for the ui folder

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
  • @hgy29 thanks, I wondered where it was :)

    He While I was trying to decipher how debuggers work with VSC I installe heaps of LUA ones and came across one that already has Gideros support!

    https://github.com/devcat-studio/VSCodeLuaDebug

    I can;t get the actual debugger working but I can use it to launch a project, print stuff to the VSC debug console, and when an app crashes because of some syntax error or whatnot, it shows what line caused the problem.

    For me that is a pretty smart result s I never use real debugging and stepping through code, etc.

    I'm slowly getting to grips with language extensions, but just the very basic declarative type, not the full blown language server. If I can make the simple one work, I'll try for the more advanced (and better one).

    As it is right now I can actually use VSC for Gideros which is very cool!

    Likes: MoKaLux, hgy29

    +1 -1 (+2 / -0 ) Share on Facebook
  • Whilst looking at other Lua language extensions I discovered that one in particular (https://github.com/sumneko/lua-language-server) is very cool and is able to be modified to accommodate Gideros with relative ease.

    I tested with the Bitmap class and this is the format for adding things like that...
    ---<a href="/profile/meta">@meta</a>
     
    ---
    ---
    ---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bitmap"])
    ---
    ---<a href="/profile/class">@class</a> Bitmap*
    Bitmap = {}
     
    ---
    ---Creates a new Bitmap object.
    ---
    ---[View documents](command:extension.lua.doc?["en-us/54/gideros.html/pdf-Bitmap.new"])
    ---
    ---<a href="/profile/param">@param</a> texture TextureBase or TextureRegion
    function Bitmap.new(texture) end
     
     
    ---
    ---Returns the x and y coordinates of the anchor point.
    ---
    ---[View documents](command:extension.lua.doc?["en-us/54/gideros.html/pdf-Bitmap.getAnchorPoint"])
    ---
    ---<a href="/profile/param">@param</a> texture TextureBase or TextureRegion
    ---<a href="/profile/return">@return</a> number The x coordinate of the anchor point
    ---<a href="/profile/return">@return</a> number The y coordinate of the anchor point
    function Bitmap.getAnchorPoint() end
     
    ---
    ---Sets the anchor point of Bitmap object.
    ---
    ---[View documents](command:extension.lua.doc?["en-us/54/gideros.html/pdf-Bitmap.setAnchorPoint"])
    ---
    ---<a href="/profile/param">@param</a> x number The x coordinate of anchor point (between 0 and 1)
    ---<a href="/profile/param">@param</a> y number The y coordinate of anchor point (between 0 and 1)
    function Bitmap.setAnchorPoint(x, y) end
     
    ---
    ---Creates a new Bitmap object
    ---
    ---[View documents](command:extension.lua.doc?["en-us/54/gideros.html/pdf-Bitmap.setTexture"])
    ---
    ---<a href="/profile/param">@param</a> texture TextureBase
    function Bitmap.setTexture(textureBase) end
     
    ---
    ---Sets the texture of the Bitmap object
    ---
    ---[View documents](command:extension.lua.doc?["en-us/54/gideros.html/pdf-Bitmap.setTextureRegion"])
    ---
    ---<a href="/profile/param">@param</a> textureRegion TextureRegion
    function Bitmap.setTextureRegion(textureRegion) end
     
    return Bitmap
    Currently it's looking pretty promising. I'll work on adding the rest of Gideros to the extension over the next couple of days.

    Likes: keszegh, MoKaLux

    +1 -1 (+2 / -0 ) Share on Facebook
  • superb antix, you can export all gideros functions from the wiki to a txt file, but I think you already know that :p
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • antixantix Member
    edited December 2020
    @MoKaLux yep I was just looking at it now and trying to make a JavaScript app to scrape and convert them to the right format.

    @hgy29 I'm using http://wiki.giderosmobile.com/gidapiref.php to scrape the docs in JSON format but there is one anomaly that I've come across so far. Exported item 14 is the IO namespace but its interior arrays contain "TexturePack" objects, not "io" objects. Is this an error in the script?

    The above seems odd but I can work around it inside Javascript.
  • http://wiki.giderosmobile.com/gidapiref.php does not contain any information on what any given function returns either. This would be very helpful :)
  • MoKaLuxMoKaLux Member
    edited December 2020
    antix you have wrong url
    it's now: https://wiki.gideros.rocks/gidapi.php (attached to post)

    edit: http://wiki.gideros.rocks/gidapiref.php I forgot about this one it looks very nice too :)
    txt
    txt
    GiderosRocks-4antix.txt
    87K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • maybe this can help you?
    change from xml to txt because of the forum policy

    Likes: antix

    txt
    txt
    GiderosMobile-4antix_part1.txt
    2M
    txt
    txt
    GiderosMobile-4antix_part2.txt
    271K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 ) Share on Facebook
  • @MoKaLux Thanks :)

    http://wiki.gideros.rocks/gidapiref.php produces basically the same information as https://wiki.gideros.rocks/gidapi.php but it is in JSON format which is very easy to use.

    The XML file is to me pretty much unreadable and requires a LOT of processing to make use of, even though it contains the return values (which is all I'm missing).

    Did you use a URL to get the XML? For my purposes I need a URL (like https://wiki.gideros.rocks/gidapi.php) which can be used in an AJAX request to automatically retrieve the data from the wiki.
  • unfortunately not from a url :/
    but it took me something like 30secs to get it (including txt file splitting :) )

    I copied all class from top to bottom then pasted in wiki export.

    Likes: antix

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 ) Share on Facebook
  • @MoKaLux ahh that wouldn;t work for me then. Basically if it can;t be automated.. it's really not worth doing.

    Which brings me to say that there is no way to download the wiki (as fa as I know) to be used offline, as a folder of html files.

    I should really have a look at how the documents are structured and created I think :)
  • https://www.httrack.com/page/2/fr/index.html
    I used it to have the whole wiki on my hard drive :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • @MoKaLux interesting app :)

    I've looked at the Gideros Github repository and the XML files there contain the information I need to be able to generate proper documentation. It would be easier if these were JSON files but I can cope with parsing the XML :)

    I'm not having much luck right now getting my generated docs working with the Lua extension in VSC. I think there's something obvious that I'm not getting right now :D
  • hgy29hgy29 Maintainer
    antix said:


    I've looked at the Gideros Github repository and the XML files there contain the information I need to be able to generate proper documentation. It would be easier if these were JSON files but I can cope with parsing the XML :)

    Beware, the xml files there are old ones, merely an extract of the un maintained old docs.

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
  • @hgy29 Arghhh, I did not know that. I spent yesterday rewriting my codebase to use the XML files for the lua doc conversion.

    May I ask what documents am I supposed to use? The wiki ones (when exported using your script) contain parameters, but not returns.

    Also, if the XML ones on the repository are obsolete then maybe they could be moved to an "obsolete" folder, or removed.
  • hgy29hgy29 Maintainer
    Yes, repository needs a bit of tidying.
    The wiki is the master source for docs, so I’ll try to improve my script to extract return values description. By the way, what kind of output do you expect ?

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
Sign In or Register to comment.