Author Topic: [SOLVED] Open another file on exiting AGS?  (Read 2423 times)

[SOLVED] Open another file on exiting AGS?
« on: 14 Nov 2015, 17:34 »
Using AGS for a christmas surprise at work, I wonder if I can make AGS open a pdf file for the user?

I'm looking for a command that does something like opening the PDF file in the background, then quitting AGS so the PDF file is open and visible to the user when AGS closes.

Is this possible? I believe the function File.Open might not be what I'm looking for...?
« Last Edit: 14 Nov 2015, 17:51 by Nanuaraq »

Ghost

  • AGS Baker
  • Rottwheelers
  • Time to give up.
    • Ghost worked on one or more games that won an AGS Award!
    •  
    • Ghost worked on one or more games that was nominated for an AGS Award!
Re: Open another file on exiting AGS?
« Reply #1 on: 14 Nov 2015, 17:46 »
No, AGS takes some care in that respect. File.Open opens raw text/data, and you CAN run another AGS game from within another AGS game. PDF, though, is not possible.

Re: Open another file on exiting AGS?
« Reply #2 on: 14 Nov 2015, 17:51 »
Thank you for the quick answer. Good to know that road's closed.

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: [SOLVED] Open another file on exiting AGS?
« Reply #3 on: 15 Nov 2015, 20:58 »
Somebody once posted a small shell plugin that would allow you to run Windows commands from inside AGS.
https://www.dropbox.com/s/oskhhwrytwtfg1p/ags_shell.dll?dl=0

I don't remember what the AGSScript command was though.

Edit:
found it, it's

int ShellExecute(const string operation, const string file, const string parameters, ShowCommand showCommand = SW_SHOW);
« Last Edit: 21 Nov 2019, 14:09 by Khris »
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: [SOLVED] Open another file on exiting AGS?
« Reply #4 on: 15 Nov 2015, 21:42 »
Wow, thats really something.
I got it and added it to AGS, also right-clicked and chose "use this plugin". But I'm unsure how to use the command.

Edited by mod: Please don't quote the whole previous post.
« Last Edit: 16 Nov 2015, 02:19 by Gilbert »

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: [SOLVED] Open another file on exiting AGS?
« Reply #5 on: 15 Nov 2015, 23:57 »
Try this:

Code: [Select]
  ShellExecute("", "F:\\letters\\letter.pdf", "");
(and don't quote the entire previous post)
Fail at Floaty Rog' now!  still having to deal with what games are going through

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: [SOLVED] Open another file on exiting AGS?
« Reply #6 on: 16 Nov 2015, 08:02 »
Alternatively you can try the Lua plugin, since I'm 110% sure that Lua has libraries to interface with the OS.
 

Re: [SOLVED] Open another file on exiting AGS?
« Reply #7 on: 16 Nov 2015, 18:54 »
Thank you for helping with the ShellExecute command. Sorry for the quote.

Re: [SOLVED] Open another file on exiting AGS?
« Reply #8 on: 16 Nov 2015, 19:00 »
Oh wait, one more thing...

Can I specify the location of the PDF file I want to open relative to the game directory?

Rather than opening the letter.pdf at "c:\\letters\\letter.pdf", I'd like to do something like simply asking AGS to open "letter.pdf" in the same directory as the game files. This would allow me to bring the game with me on a memory stick without needing to edit what location the game should look for the pdf at.

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: [SOLVED] Open another file on exiting AGS?
« Reply #9 on: 16 Nov 2015, 19:59 »
Just remove the path.

Code: [Select]
  ShellExecute("", "letter.pdf", "");
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: [SOLVED] Open another file on exiting AGS?
« Reply #10 on: 16 Nov 2015, 21:02 »
I tried that and it didn't work.

Then I tried it again and it worked. I should have just tried it twice before asking :-[

Thank you again.

Re: [SOLVED] Open another file on exiting AGS?
« Reply #11 on: 17 Nov 2015, 21:19 »
Success, my collegaues love it :-D

Thank you for your help.

Re: Open another file on exiting AGS?
« Reply #12 on: 25 Nov 2015, 16:20 »
Hi everyone :)

you CAN run another AGS game from within another AGS game

Great! I was actualy looking to run a AGS game within another AGS game (like when you play Maniac Mansion within Day Of The Tentacle). Could someone tell me how to do it? Thanks a lot :)

PS: I've tried to execute an EXE file with the AGS Shell plugin:

Code: Adventure Game Studio
  1. ShellExecute("", ".\\OtherGame\\Game.exe", "");

I also tried with or without the EXE extension. Tried also ShellExecute("", ""start  .\\OtherGame\\Game.exe", ""); or going to the other game folder with "cd OtherGame" - but nothing worked (maybe I did something wrong :/)

Any help would be very welcomed :)

PPS: Perhaps I should have create a new thread? If so, feel free to tell me :)
« Last Edit: 25 Nov 2015, 17:01 by declerfayt »
Lancelot's Hangover : A whole life to find the Holy Grail. One alcohol night to lose it.

Play free beta // Video trailer // Website

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: [SOLVED] Open another file on exiting AGS?
« Reply #13 on: 25 Nov 2015, 22:15 »
There's a special command for that: RunAGSGame().
Note that the game should have the same basic settings as the main game (color depth and resolution, mostly), since the engine part of the first .exe will simply read the data part of the second one.
More details can be found in the manual entry for the command.
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: [SOLVED] Open another file on exiting AGS?
« Reply #14 on: 26 Nov 2015, 08:46 »
This is the kind of thnig that makes me go all fanboy just like Syndrome. This is so COOL  (laugh)

Re: [SOLVED] Open another file on exiting AGS?
« Reply #15 on: 26 Nov 2015, 19:06 »
Great! Thanks Khris for your help :) Just what I needed :)
Lancelot's Hangover : A whole life to find the Holy Grail. One alcohol night to lose it.

Play free beta // Video trailer // Website

Re: [SOLVED] Open another file on exiting AGS?
« Reply #16 on: 26 Nov 2015, 19:12 »
About the limitation of sharing common files (audio.vox, speech.vox, ...), I've tried changing the file names ("audio.vox" goes "audiovox.001" for instance, and the other one goes "audiovox.002"). Then, in AGS, using the SchellExecute command to change the files names before launching the other game.

I've tried :

Code: Adventure Game Studio
  1. ShellExecute("", "rename audiovox.001 audio.vox", "");

Code: Adventure Game Studio
  1. ShellExecute("rename", "audiovox.001 audio.vox", "");

Code: Adventure Game Studio
  1. ShellExecute("rename", "audiovox.001", "audio.vox");

But the file name doesn't change :-\

I don't wanna bother about this. It is actualy just curiosity - and I realise how I just suck with using ShellExecute function.

Anyway, any clue how to change a file name with ShellExecute?

Thanks so much! :)
Lancelot's Hangover : A whole life to find the Holy Grail. One alcohol night to lose it.

Play free beta // Video trailer // Website

Khris

  • partook in silencing a crtitc despite facts
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on one or more games that was nominated for an AGS Award!
Re: [SOLVED] Open another file on exiting AGS?
« Reply #17 on: 27 Nov 2015, 00:30 »
The first version you tried should work but you probably have to do this:
Code: [Select]
  ShellExecute("", "rename audio.vox audio.vox.001", "");  // move first game's file out of the way first
  ShellExecute("", "rename audio.vox.002 audio.vox", "");  // this should work now

since my guess is Windows won't let you rename file A to the current name of an existing file B.
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: [SOLVED] Open another file on exiting AGS?
« Reply #18 on: 27 Nov 2015, 17:33 »
Thanks again Khris :)
Lancelot's Hangover : A whole life to find the Holy Grail. One alcohol night to lose it.

Play free beta // Video trailer // Website

Re: [SOLVED] Open another file on exiting AGS?
« Reply #19 on: 27 Nov 2015, 20:30 »
Wait, one more :cheesy:

Can I insert a hyperlink into AGS?
I mean, can I make AGS open default browser and find a certain webpage?