topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 10:05 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: How to bundle a game's source file and its interpreter into a single EXE  (Read 19707 times)

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
I'll whip up those files for you now, Hollow.
« Last Edit: May 25, 2007, 04:04 PM by kyrathaba »

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Hollowlife, here is the dummy interpreter EXE and the text file similating a game file.  Unzip, then open folder and run the EXE.  You'll see my intentions.  If you can provide source code on wrapping these two inside an EXE, I'll have learned two useful things today :>

hollowlife1987

  • Honorary Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 92
    • View Profile
    • Donate to Member
Ok, just give me a few minutes

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Take your time, I'm on no timetable.  Besides, I'm at the mercy of your samaritanism ;>

hollowlife1987

  • Honorary Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 92
    • View Profile
    • Donate to Member
You have the source to the interpreter exe right?

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Yeah, I'll upload the entire dummy project.

hollowlife1987

  • Honorary Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 92
    • View Profile
    • Donate to Member
Ok, you have the code to compile an exe now all you need to do is add a the script to that exe as a resource.

Then when you run the newly created exe you use open the resource and run the script directly from memory

Here are some code snippets on how to do what I just explain (note I don't know much about compiling .net code from .net so your on your own on how to use a resource file when you compile it)

To make the .resources file that you compile into the newly created exe
Code: C# [Select]
  1. ResourceWriter rw = new ResourceWriter("app.resources");
  2. byte[] data = File.ReadAllBytes(scriptFile);
  3.  
  4. rw.AddResource("script", data);
  5. rw.Close();

And to read the resource and do something with it
Code: C# [Select]
  1. ResourceManager rm = new ResourceManager("app", Assembly.GetExecutingAssembly());
  2. byte[] data = (byte[])rm.GetObject("script");
  3.  
  4. UTF8Encoding encoder = new UTF8Encoding();
  5. string text = encoder.GetString(data);
  6.  
  7. Console.WriteLine(text);

Hope that is of some help if you still need help I'll write a sample program I couldn't do it tonight because something came up.

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Very helpful.  Thanks Hollowlife :>

hollowlife1987

  • Honorary Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 92
    • View Profile
    • Donate to Member
Your very welcome :)