[SOLVED] Open another file on exiting AGS?

Started by johanvepa, Sat 14/11/2015 17:34:50

Previous topic - Next topic

johanvepa

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...?

Ghost

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.

johanvepa

Thank you for the quick answer. Good to know that road's closed.

Khris

#3
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);

johanvepa

#4
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.

Khris

Try this:

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


(and don't quote the entire previous post)

Monsieur OUXX

Alternatively you can try the Lua plugin, since I'm 110% sure that Lua has libraries to interface with the OS.
 

johanvepa

Thank you for helping with the ShellExecute command. Sorry for the quote.

johanvepa

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

Just remove the path.

Code: ags
  ShellExecute("", "letter.pdf", "");

johanvepa

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.

johanvepa

Success, my collegaues love it :-D

Thank you for your help.

declerfayt

#12
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
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 :)
Lancelot's Hangover : A whole life to find the Holy Grail. One alcohol night to lose it.

Play free beta // Video trailer // Website

Khris

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.

johanvepa

This is the kind of thnig that makes me go all fanboy just like Syndrome. This is so COOL  (laugh)

declerfayt

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

declerfayt

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
ShellExecute("", "rename audiovox.001 audio.vox", "");


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


Code: ags
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

The first version you tried should work but you probably have to do this:
Code: ags
  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.

declerfayt

Lancelot's Hangover : A whole life to find the Holy Grail. One alcohol night to lose it.

Play free beta // Video trailer // Website

johanvepa

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?

SMF spam blocked by CleanTalk