Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: [1] 2  All

Author Topic: Possible to open a file from the inside of a game?  (Read 12344 times)

0 Members and 1 Guest are viewing this topic.

Blue_D

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
  • I'm a llama!
    • View Profile
Possible to open a file from the inside of a game?
« on: November 25, 2003, 03:27:29 PM »

Is possible to call for another program from inside the game? Something like "read the book" and suddenly Adobe PDF reader starts and opens a pdf document?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Possible to open a file from the inside of a game?
« Reply #1 on: November 25, 2003, 08:00:39 PM »

Yes, it's possible using WME's ability to call external DLL functions.

Just add the following function to your script:
Code: [Select]
external "shell32.dll" int ShellExecuteA(int hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
function RunDocument(var Filename)
{
   ShellExecuteA(0, "open", Filename, "", "", 3);
}

Now, when you want to open the document, just call:
Code: [Select]
RunDocument("C:\Path\MyDocument.pdf");

It will work for any document type registered in Windows, not just PDF's.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Possible to open a file from the inside of a game?
« Reply #2 on: November 25, 2003, 08:05:21 PM »

Oh, and it will also work for URLs:

Code: [Select]
RunDocument("http://dead-code.org");
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re:Possible to open a file from the inside of a game?
« Reply #3 on: November 29, 2003, 02:21:33 AM »

And by the way: welcome Blue_D and good luck for your final study!

You live quite exactly in the center of the active members here (we found out when thinking about a meeting  ;) !).

Logged
Mooh!

Blue_D

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
  • I'm a llama!
    • View Profile
Re:Possible to open a file from the inside of a game?
« Reply #4 on: February 04, 2004, 12:49:04 PM »

Quote
And by the way: welcome Blue_D and good luck for your final study!

You live quite exactly in the center of the active members here (we found out when thinking about a meeting   !).

Good. So if you want to meet here in Italy, I would be glad to organize something for the enjoyment of the group! I live in a zone worldwide known for the quality of it's wines...
Logged

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re:Possible to open a file from the inside of a game?
« Reply #5 on: February 04, 2004, 03:25:35 PM »

Good. So if you want to meet here in Italy, I would be glad to organize something for the enjoyment of the group! I live in a zone worldwide known for the quality of it's wines...

That "wine" word is very important.... I think that we should seriously add Italy to our blurry schedule for meetings :-)
Logged
fl*p

Blue_D

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
  • I'm a llama!
    • View Profile
Re:Possible to open a file from the inside of a game?
« Reply #6 on: February 11, 2004, 06:40:07 PM »

Quote
Just add the following function to your script:
Code:

external "shell32.dll" int ShellExecuteA(int hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
function RunDocument(var Filename)
{
   ShellExecuteA(0, "open", Filename, "", "", 3);
}
 
 


Now, when you want to open the document, just call:
Code:

RunDocument("C:\Path\MyDocument.pdf");
 
 


It will work for any document type registered in Windows, not just PDF's.


where this code has to go?

In the scene script or in another?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Possible to open a file from the inside of a game?
« Reply #7 on: February 11, 2004, 09:29:11 PM »

Put the function to the script from which you want to call the document.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Blue_D

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
  • I'm a llama!
    • View Profile
Re:Possible to open a file from the inside of a game?
« Reply #8 on: February 11, 2004, 09:55:26 PM »

Quote
Put the function to the script from which you want to call the document.

since the function "RunDocument" is an integral part of my interface, is there a form to declare it so I can use it without writing all the declaration again and again?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Possible to open a file from the inside of a game?
« Reply #9 on: February 11, 2004, 10:06:48 PM »

Yes, definitely. But you must convert it to a method.

external "shell32.dll" int ShellExecuteA(int hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);

method RunDocument(var Filename)
{
   ShellExecuteA(0, "open", Filename, "", "", 3);
}


Put the above code to "game script". Now whenever you need to run the document, call:

Game.RunDocument("C:\Path\MyDocument.pdf");
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re:Possible to open a file from the inside of a game?
« Reply #10 on: February 12, 2004, 03:27:23 PM »

I LOVE the new scripting functions, really!
Logged

Click here to sign my sig!

Blue_D

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
  • I'm a llama!
    • View Profile
Re:Possible to open a file from the inside of a game?
« Reply #11 on: March 03, 2004, 05:20:44 PM »

Quote
It will work for any document type registered in Windows, not just PDF's.

I've tried this, works good with urls but doesn't works with pdf...

I have the reader properly installed and when I double click a pdf file it opens correctly.

What's wrong now? The game log says nothing is wrong.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Possible to open a file from the inside of a game?
« Reply #12 on: March 03, 2004, 06:22:31 PM »

I tried that with pdf and it works fine. I'm using Acrobat Reader 6.0.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Blue_D

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
  • I'm a llama!
    • View Profile
Re:Possible to open a file from the inside of a game?
« Reply #13 on: March 03, 2004, 08:26:20 PM »

Quote
I tried that with pdf and it works fine. I'm using Acrobat Reader 6.0.

Any idea? I don't understand what's wrong...
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Possible to open a file from the inside of a game?
« Reply #14 on: March 03, 2004, 09:17:21 PM »

Did you try other file? Is the path correct?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
Pages: [1] 2  All
 

Page created in 0.04 seconds with 24 queries.