Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dave Gilbert on Mon 16/04/2007 18:33:06

Title: Accessing the internet from within AGS
Post by: Dave Gilbert on Mon 16/04/2007 18:33:06
In talking to various portals about distributing Blackwell, the main concern is the download size.  180MB is a bit too heavy for the casual market, and the agreement was to nix the voice pack (which takes up 140MB) but make it a seperate download. 

I thought it would be nice for the player to be able to click a button within the game labelled "Download Voice Pack" and then have the game access the internet and grab the file.  Is this possible to do? 

-Dave
Title: Re: Accessing the internet from within AGS
Post by: Gregjazz on Mon 16/04/2007 18:59:09
If someone was able to make a plugin that returns PHP output from the internet, I don't think it would be a stretch to return data into a file. Problem is, 140MB is a while for the game to download--you'd think people would want to just be able to download it off the web using download accelerators or whatnot.
Title: Re: Accessing the internet from within AGS
Post by: scotch on Mon 16/04/2007 19:01:02
Only if someone can write the plugin for you. Perhaps you can find someone to that.

How is your speech 140mb? that's something like 6 hours of decent quality ogg, are you using too high a bitrate? Speech doesn't need to be as high as music.
Title: Re: Accessing the internet from within AGS
Post by: GarageGothic on Mon 16/04/2007 19:01:11
It might be possible using a plugin, but wouldn't it be far easier to create a launcher program where this is an option? The game won't recognize the addition of a voicepack anyway without restarting.
Title: Re: Accessing the internet from within AGS
Post by: scotch on Mon 16/04/2007 19:02:05
I don't think writing a launcher program is easier than writing a plugin, it'd be much the same code.
Probably right about the voice not being noticed before an update though, so it's a good idea.
Title: Re: Accessing the internet from within AGS
Post by: GarageGothic on Mon 16/04/2007 19:08:32
A launcher program coded in Visual Basic or similar could just open the standard webbrowser and direct it to the right web address. It doesn't have to be a stand-alone download manager, but of course then you would need to tell the user where to save the file to. For the casual games market that may be a bit too demanding.

Edit: You could even customize the launcher for each distributor with their logo (change a resource file and recompile, takes 2 seconds in VB), I'm sure they'd love that.
Title: Re: Accessing the internet from within AGS
Post by: Dave Gilbert on Mon 16/04/2007 19:11:37
I'm basing this model on Aveyond, which downloaded with a midi soundtrack but you had the option of downloading a full orchestral score.

The file you downloaded was an installer program, which automatically searched for the game folder.  I'd do the same thing with the speech.vox.
Title: Re: Accessing the internet from within AGS
Post by: Dave Gilbert on Tue 17/04/2007 19:41:32
Hm.  In talking with others about this, it seems people might be misunderstanding my problem.  Maybe so, maybe not, but here's a simplified version.

Basically, all I want is to create a link button within my game. 

Hopefully that clears things up.  Any advice is appreciated. :-D

-Dave
Title: Re: Accessing the internet from within AGS
Post by: scotch on Tue 17/04/2007 19:52:33
So you want someone to be able to press a button in the game, the game to load an address in the user's web browser, and minimize or lose focus?
It could confuse some people I think, especially if they are running full screen, and as GarageGothic pointed out, even if they download the installer and install, then go back to the game, the sound won't work until they quit the game and start again.

I suppose the sensible way would be something like having a button that opens the installer link, and quits the game, and then add a checkbox (perhaps on by default) at the end of the installer process to run the game again.

That shouldn't be too difficult, as long as your installer software allows it, and it seems like most have something like that. It would need a pluign made but it'd be very basic.
Title: Re: Accessing the internet from within AGS
Post by: GarageGothic on Tue 17/04/2007 19:57:49
You could even make a autosave right before quitting and restore the game when the game restarts (but probably a good idea to ask the user whether they want to resume the game first).

Edit: If you follow scotch's method, it would probably be better if the downloader doesn't  access the internet until the game is definitely closed. Otherwise the user's firewall program might come up with a warning, minimizing the AGS window and thus preventing the script to proceed.
Title: Re: Accessing the internet from within AGS
Post by: Menaze on Wed 18/04/2007 16:50:58
hi,

i'd try making a batch file. (read a batch tutorial first, to learn how to code it -it's easy)

-always start agsgame with this batch
_______________________
in ags:
-press download button
-save a variable xy to some .txt file
-ags_quit
_______________________

in .bat:
-check variable xy in .txt file
-if xy is != 0 then
-start download manager (check settings for your dm to access your website etc.)
________________________
in download manager (thats a part i don't know much about):
-maybe your download manager tells you when it has downloaded the file, use this information to return to the batch file (this might be difficult)
-if so start an install or patch maker from within the batch file.
-if not, try to start it from within the dm
________________________
a patchmaker (www.clickteam.com -it's freeware) should do the rest. (it's easy too...)



additional:
-hide ags.exe in windows, to make sure every user opens the batch
-use an batch_to_exe_tool to make your .bat file an .exe, you can also make an icon for it.
       


also, in ags you can use dorcan's filenet plugin, to download/upload SMALL files from/to
a website:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28261.0

*menaze*
Title: Re: Accessing the internet from within AGS
Post by: AGD2 on Thu 19/04/2007 23:54:16
Seems that most people would probably look in a menu launcher for such a feature, rather than in the in-game options.

There's a menu creation program called "Auto Play Menu Studio" by Indigo Rose. Unfortunately, it's not free. But it's useful if you want to include a 'download file' option like this on your menu launcher. You can set your game (or menu) up so that a registry key is created if you install the version of the game which doesn't include the voice pack.

Whenever the launcher is loaded, it'll first check the system for the existence of this registry key. If it exists, then the launcher would show a new button saying "Download speech pack". (You'd point the button's scripting code at a specific URL where your speech pack resides).  Once the speech pack has been successfully installed, you'd have its installer delete the registry key, so that the next time the launcher menu is loaded, it'll know not to display the "download music" button again. (You'd have to remember to make the main game's un-installer be set up to remove the registry key too, if it exists, regardless of whether the speech pack was installed or not.)

If you don't want to mess with the Windows registry, I think the program also allows you to do the same thing by dumping a .dat file to the directory.

I'm not sure if there are any freeware menu building programs around that do the same thing, but I've used this one, so I can vouch that it works pretty well for this purpose.
Title: Re: Accessing the internet from within AGS
Post by: SupSuper on Fri 20/04/2007 00:15:05
You can also just add the option on the installer, since most have built-in support to download files.
Title: Re: Accessing the internet from within AGS
Post by: GarageGothic on Fri 20/04/2007 10:44:55
Quote from: AGD2 on Thu 19/04/2007 23:54:16If you don't want to mess with the Windows registry, I think the program also allows you to do the same thing by dumping a .dat file to the directory.

Or just check for the speech.vox file in the game dir instead.
Title: Re: Accessing the internet from within AGS
Post by: voh on Sat 21/04/2007 00:00:55
I was going to post the same as what AGD2 posted. I would opt for a game launcher as well, which could link to start game, setup, download voice pack, website, quit.

That would work best. I concur with the notion that doing it from the game would be a bad choice, as most people will run it full-screen (what with the high resolutions, and mucking about with configs concerning graphics filters isn't everyone's cup of tea) and it'd cause them to lose focus.
Title: Re: Accessing the internet from within AGS
Post by: Dave Gilbert on Wed 25/04/2007 20:40:40
Hi all,

Thanks for all the tips!  Still, while accessing the internet from the game itself might not be applicable to this particular problem, it still needs to be done for other reasons.  Mainly, one portal wants the game to open a browser window to the game's product page when the demo/trial version is complete. 

There's nothing equivilent to an OpenURL("www.blah.com") command?
Title: Re: Accessing the internet from within AGS
Post by: Nikolas on Wed 25/04/2007 20:53:09
heh...

www.blah.com is an actual site for S. America ;D
Title: Re: Accessing the internet from within AGS
Post by: radiowaves on Wed 25/04/2007 21:12:58
I'd still suggest you try cutting the size down a bit. If AGS can support mp3's, you could try vbr conversion. Just convert it to lowest quality of vbr and you can see what miracle the filesize is with same good quality. You can do this via lame + razorlame for easier use.
Title: Re: Accessing the internet from within AGS
Post by: GarageGothic on Wed 25/04/2007 22:28:45
Quote from: Dave Gilbert on Wed 25/04/2007 20:40:40There's nothing equivilent to an OpenURL("www.blah.com") command?

Once again a launcher program is probably your best bet, since AGS script can only run other AGS games. The launcher would start  the game, then remain resident until the game exits and open the URL in a web browser when the game closes. Try asking someone who codes Visual Basic or similar, this shouldn't be difficult stuff. I'm myself learning bits of VB Express to make my own laucher program, and just after half an hour playing around with it, I can do about half of what you would need - sadly not enough to help you out, yet.
Title: Re: Accessing the internet from within AGS
Post by: scotch on Wed 25/04/2007 23:15:26
I made this in 4 minutes: http://www.caverider.com/temp/ags_shell.dll if you choose to do it from AGS. It lets you use the windows ShellExecute function. For example to open google.com:

ShellExecute("open", "rundll32.exe", "url.dll,FileProtocolHandler http://www.google.com")

anyway, I think a launcher is a good idea too, if you can find someone to make one.

I also think radiowaves is right... using low bitrage vbr ogg would be your best bet. I expect you could divide the filesize by three without anyone noticing the compression.
Title: Re: Accessing the internet from within AGS
Post by: RickJ on Fri 24/10/2008 20:14:19
Scotch,

Can your plug-in be used to run something from a command line like a batch file or
console program such as 7zip command line version?

For example can your plugin execute this  and if so how?

"7z -t7z c:\\Ags\\3.20\\Archive\\MyGame-V0000-003.7z  c:\\Ags\\3.20\\MyGame\\";
Title: Re: Accessing the internet from within AGS
Post by: Moox on Mon 26/04/2010 17:12:43
My sincerest apologies for the bump, however, I was wondering if it is possible to populate fields from within the shell function?

For instance, if I wanted a GUI to craft invoices to be emailed to my clients I can currently get the mail application open with the mailto: function, however, I would have to manually fill in all the fields making it nothing more than a worthless launcher application. After realizing that there is no print functionality this was my fall back plan before loading up c++ and relearning that.
Title: Re: Accessing the internet from within AGS
Post by: Moox on Mon 26/04/2010 17:16:38
Edit: Figured it out

Mailto allows for population through a body= code and a subject= code
Title: Re: Accessing the internet from within AGS
Post by: ------- on Fri 07/05/2010 03:50:15
Quote from: Dave Gilbert on Mon 16/04/2007 18:33:06
180MB is a bit too heavy for the casual market, and the agreement was to nix the voice pack (which takes up 140MB) but make it a seperate download.  
-Dave


I bought Empire Total War and got that of the internet.
The download was 11,5 GB and took three days to complete with internet install.
I then had a std. 2 Mb ADSL connection.

Now I work from home and run fiberlan 100Mbps.

A 180 Mb dl would take me approx. 2-3 minutes.
I doubt personally you have a reason to worry.

But then again, if you can direct me to a good reference on writing plugins I can probably create something like that given a little time to learn this editor thing.

On a personal note using mailto: hrefs is never a good way to do anything email related.
To many prefer using hotmail or gmail accounts without a proper defined email application and then the link invocation fails by default as no defined settings exist and you end up loosing clients.
Title: Re: Accessing the internet from within AGS
Post by: Dave Gilbert on Fri 07/05/2010 12:10:31
You'd be surprised 10e12!  A big chunk of users are still on dial-up, and the portals that wanted to sell the game are very concerned about bandwidth usage.  An average game of theirs is around 40-50 MB max.  An 180 MB game was way too high. 

And wow, this thread is old.
Title: Re: Accessing the internet from within AGS
Post by: Calin Leafshade on Fri 07/05/2010 12:16:22
Yea, you have to remember Dave's primary audience are the casuals.. not gamers.
Title: Re: Accessing the internet from within AGS
Post by: Dave Gilbert on Fri 07/05/2010 12:24:28
It's funny that this thread resurfaces now, because the other day I unearthed it myself to make the Puzzle Bots demo.  It now has a sweet "BUY NOW!" button that takes you to the purchase page.
Title: Re: Accessing the internet from within AGS
Post by: Calin Leafshade on Fri 07/05/2010 12:25:55
You capitalist, you.
Title: Re: Accessing the internet from within AGS
Post by: magintz on Fri 07/05/2010 22:22:28
I've used the TCP/IP plugin before to retrieve web pages in game and I believe scotch or SSH made a IRC client with it, I'm not sure if this could do the trick.
Title: Re: Accessing the internet from within AGS
Post by: suicidal pencil on Fri 14/05/2010 14:08:29
what if instead of retrieving web pages, but a plugin that gets data from a database? It could be pretty useful. High scores, for example.
Title: Re: Accessing the internet from within AGS
Post by: eri0o on Fri 27/04/2018 11:26:07
hey, does someone have any idea on how to port this plugin to Linux ?

edit: I found a source here: https://bitbucket.org/monkey0506/ags_shell/src/6516d82861c2?at=master

But I am not sure on how to start.

edit2: I started a repo here: https://github.com/ericoporto/agsshell

Trying to find the equivalent command for Linux to be able to port it...
Title: Re: Accessing the internet from within AGS
Post by: eri0o on Sat 28/04/2018 20:52:47
🚨hey, if you are looking for my plugin below, please try instead AgsAppOpenURL plugin here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=60640.0🚨

It worked!

binary release (https://github.com/ericoporto/agsshell/releases/tag/0.1.0) | github repo (https://github.com/ericoporto/agsshell)

Use this like below:
Code (ags) Select
  if( System.OperatingSystem == eOSWindows ){
    ShellExecute("open", "rundll32.exe", "url.dll,FileProtocolHandler http://www.google.com");
  } else if( System.OperatingSystem == eOSLinux ){
    ShellExecute("", "", "xdg-open http://www.google.com");
  }

Right click, save link as... libagsshell.so (https://github.com/ericoporto/agsshell/releases/download/0.1.0/libagsshell.so)

Right click, save link as... agsshell.dll (https://github.com/ericoporto/agsshell/releases/download/0.1.0/agsshell.dll)

I actually didn't generate the above .dll but if someone with Windows could confirm the above code works. I based on monkey0506 code linked above.
Title: Re: Accessing the internet from within AGS
Post by: selmiak on Sat 21/05/2022 00:01:23
linking a website works on windows, but when compiling I get this:

https://i.imgur.com/C40m3nR.png

even though the required file is in the AGS install directory. But not in the plugin part of the game project tree...
Title: Re: Accessing the internet from within AGS
Post by: eri0o on Sat 21/05/2022 01:15:53
Linux plugins need to be built twice, once for 32bit and once for 64bit, and then place into the specific directories in the Editor Linux directory.

I don't recommend using AGS shell plugin at all though, it essentially let's the game do whatever it pleases in the computer, I usually delete it when I see in a game. If this is for opening a link, we could add something for this directly in ags4 since it's a function that is in SDL2 itself since 2.0.14, probably adding some restrictions so it only uses http urls or something.
Title: Re: Accessing the internet from within AGS
Post by: Crimson Wizard on Sat 21/05/2022 06:21:22
Quote from: selmiak on Sat 21/05/2022 00:01:23
linking a website works on windows, but when compiling I get this:

https://i.imgur.com/C40m3nR.png

even though the required file is in the AGS install directory. But not in the plugin part of the game project tree...

Everything is mentioned in the manual:
https://github.com/adventuregamestudio/ags-manual/wiki/Plugins