Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: johanvepa on Sat 14/11/2015 17:34:50

Title: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Sat 14/11/2015 17:34:50
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...?
Title: Re: Open another file on exiting AGS?
Post by: Ghost on Sat 14/11/2015 17:46:23
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.
Title: Re: Open another file on exiting AGS?
Post by: johanvepa on Sat 14/11/2015 17:51:06
Thank you for the quick answer. Good to know that road's closed.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: Khris on Sun 15/11/2015 20:58:06
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);
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Sun 15/11/2015 21:42:01
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.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: Khris on Sun 15/11/2015 23:57:42
Try this:

  ShellExecute("", "F:\\letters\\letter.pdf", "");

(and don't quote the entire previous post)
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: Monsieur OUXX on Mon 16/11/2015 08:02:45
Alternatively you can try the Lua plugin, since I'm 110% sure that Lua has libraries to interface with the OS.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Mon 16/11/2015 18:54:42
Thank you for helping with the ShellExecute command. Sorry for the quote.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Mon 16/11/2015 19:00:03
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.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: Khris on Mon 16/11/2015 19:59:06
Just remove the path.

  ShellExecute("", "letter.pdf", "");
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Mon 16/11/2015 21:02:35
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.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Tue 17/11/2015 21:19:12
Success, my collegaues love it :-D

Thank you for your help.
Title: Re: Open another file on exiting AGS?
Post by: declerfayt on Wed 25/11/2015 16:20:28
Hi everyone :)

Quote from: Ghost on Sat 14/11/2015 17:46:23
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 (ags) Select
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 :)
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: Khris on Wed 25/11/2015 22:15:24
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.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Thu 26/11/2015 08:46:36
This is the kind of thnig that makes me go all fanboy just like Syndrome. This is so COOL  (laugh)
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: declerfayt on Thu 26/11/2015 19:06:21
Great! Thanks Khris for your help :) Just what I needed :)
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: declerfayt on Thu 26/11/2015 19:12:07
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 (ags) Select
ShellExecute("", "rename audiovox.001 audio.vox", "");

Code (ags) Select
ShellExecute("rename", "audiovox.001 audio.vox", "");

Code (ags) Select
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! :)
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: Khris on Fri 27/11/2015 00:30:55
The first version you tried should work but you probably have to do this:
  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.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: declerfayt on Fri 27/11/2015 17:33:58
Thanks again Khris :)
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Fri 27/11/2015 20:30:35
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?
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: Khris on Fri 27/11/2015 20:42:47
Fun fact: that's why the plugin was written in the first place, afaik.

  ShellExecute("", "http://google.com", "");
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Fri 27/11/2015 20:55:31
This engine is the coolest (laugh)

Thank you, Khris, you're always there to help me out of little fixes like this. I really appreciate it.
Title: Re: [SOLVED] Open another file on exiting AGS?
Post by: johanvepa on Sat 28/11/2015 01:09:21
Hm, doesn't work for me. Dunno what I'm doing wrong.

I can make simple commands work, like the Display command, so it's not the GUI not being clickable or something like that, but the ShellExecute command wont work for me (wtf)