ForWhatIsThis?

In last times in my Polish Click Community became popular talking about updates of own games etc. initiated by misieksamgame application Map of Polish Clickers, next Zetcom course from Slime e-zin number 5 April-May and RomanX application.. And for what is this.. so thanks to such update from Internet users of our applications don't need to go to webpages and download games but they're downloading them automatically.


Needed elements?

Extensions:
http://fabrykagier.phpnet.us/kursy/22/nobu_http.zip NOBU http

http://fabrykagier.phpnet.us/kursy/22/gfUnzipit.zip Unzip Object

http://fabrykagier.phpnet.us/kursy/22/gffile.zip File Object

File:
http://fabrykagier.phpnet.us/kursy/22/Start.zip Start.zip


Why 3 extensions and not one NOBU http? Like I mentioned in title this is update with smaller file size. Which we obtain in very easy way packing our file to *.zip format!! It is so banal but also briliant because I don't find any game using this type of update and with some kinds of files their size is smaller few times (!!) and it impact on faster download and comfort of using. And file Start.zip will be in this article a application to which we've got update (text in it is in Polish because it's article orginally for Polish clickers)


So go on

So we start with updates.

If you want update from your server upload a file called new.txt and in it as a string only number 2 and file new.zip in which will be update and in folder in which is our update downloader and project create file act.txt with as a string only number 1

Create new project in TGF and in first level set extension NOBU http and 2 edit boxes, text with string 'There is a new version. Do you want to download it? Press Y if you agree and N if don't want to update.'. Edit boxes and NOBU http object place out of play area

Now start events:

Create 2 groups 'com' and 'act'

1] Start of level -> Special Conditions Deactive group
com ; Deactive group act ; There is a new version.. Erase text

On the beginning we deactivate 2 groups.

2] Timer equals 00''-50 -> NOBU http DownBuf = 1024x1 ;
URL http://fabrykagier.phpnet.us/kursy/22/new.txt -> new.txt
When timer equals half of second set Download bufor to 1024x1 and give link to file on server and name in which it should be saved on HD. Why half of second and not start of level? Sometimes during start of level game exploits or we see empty level so it's some debug

3] Only one action when event loops NOBU http: Download
Complate -> Special conditions Active group com ; Edit Box Load file new.txt ; Edit Box 2 Load file act.txt

Now we activate group com which compare if there is a new version from loaded numbers of versions from text files new.txt (new version) and act.txt (actual version)

4] Group com
5] Run this event once Edit Value (Edit Box)> Edit Value (Edit Box 2) -> Special conditions Active group act ; Deactive group com ; There is a new version.. Display paragraph 1 at (250, 150)
6] Run this event once Edit Value (Edit Box)<= Edit Value (Edit Box 2) -> Special conditions Execute external program Start.exe ; Storyboard controls End Game

Here in com group we compare values in event 5] we check if value downloaded from file new.txt is bigger from file act.txt if yes we go to next group. And in event 6] We've got cause when value from new.txt is smaller or equal this from file act.txt so then we close updater and run correct application.

8] Group act
9] Upon pressing T ->; Storyboard controls Next level
9] Upon pressing N ->; Special conditions Execute external program Start.exe ; Storyboard controls End Game


Now we create next level and in it we place extensions
NOBU http, Unzip Object and File object and also counter go to events.

1] Timer equals 00''-50 -> NOBU http DownBuf = 1024x1 ;
URL http://fabrykagier.phpnet.us/kursy/22/new.zip -> new.zip

When timer equals half of second set Download bufor to 1024x1 and give link to file on server and name in which it should be saved on HD. Why half of second and not start of level? Sometimes during start of level game exploits or we see empty level so it's some debug

2] Only one action when event loops NOBU http: Download Complate -> Unzip Object Set zip archive to new.zip ; Set destination directory to
; Unzip *.*

We unzip files to folder in which is updater (it should be in folder with our work)

3] Always -> Counter Set Counter to downper (NOBU http) / 10

Counter how many percents we downloaded..

4] Unzip Object Unzip it, OK? -> Special conditions Execute external program Start.exe ; Storyboard controls End Game; File Object Delete the file act.txt ; Rename the new.txt as act.txt ; Delete the file new.zip

If all ended ok, close updater run correct application, delete old version number, change new number on actual number (txt file name) and delete downloaded zip file.


Summing up

Like we see after short modification (add 1 event)we can save little place and time... It's my version of updater and big thanks to MSG for helping with this extensions


Author: Fanotherpg
20 VIII 2006 - 17:57