Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Invoking WME script compiler from a .NET application  (Read 7582 times)

0 Members and 1 Guest are viewing this topic.

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Invoking WME script compiler from a .NET application
« on: December 28, 2003, 12:05:26 AM »

Since there are people working on external WME script editors, I decided to release a .NET wrapper for WME I'm working on. It may be helpful for invoking the script compiler for checking the script syntax.

Please note that the wrapper is very raw and unfinished!


The below package includes two .NET assemblies (WMESupport.dll and WMEWrapper.dll) and a sample application, calling the WME script compiler. The application is written in C#, but it should be easy to adapt it to VB.NET.

The .NET wrapper relies on two WME DLL libraries: wmelib.dll and dcscomp.dll. Those libraries are part of the WME distribution package and they MUST be available for the wrapper to work (the easiest way is to have thhose dlls and the .NET application in the same folder).

Steps to make the WME wrapper in your .NET application:

1) add a reference to the WMEWrapper.dll assembly
2) use the proper namespace: using DeadCode.WMEWrapper;
3) create an instance of a WGame class
4) initialize the WME game object (WGame.InitializeSimple)

The WGame class provides a CompileScript method. This method uses a callback to report back any compile time error.
See the eclosed package for a detailed example of the above steps.

If you have any questions/problems please ask here in this thread.


http://dead-code.org/download/WMEdotNET.zip
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SANNOI

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 22
  • mmmmm...
    • View Profile
    • ModelArt Software
Re:Invoking WME script compiler from a .NET application
« Reply #1 on: December 29, 2003, 02:41:02 AM »

Wonderful!!  :)

This .NET wrapper for WME is a great idea! I've downloaded it and i've tried to convert the sample project to VB .NET and I've obtained it, but when I run the application it returns me the same error: "Line 1: Error opening include file scripts\base.inc". I've tested this scripts with WME Project Manager and the syntax is correct. I believe that I'm writting the project root path of the InitializeSimple function bad. There's my VB .NET code:

Code: [Select]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Game As New WGame
        Game.InitializeSimple("C:\Proyectos\WME\Prueba")

        If Game.CompilerAvailable Then
            Dim ScriptCallBack As New WGame.ScriptCompilerCallback(AddressOf CompilerCallback)
            Dim CallBackData As IntPtr = IntPtr.Zero
            Game.SetCompilerCallback(ScriptCallBack, CallBackData)

            Dim Size As Integer = 0
            If (Game.CompileScript("C:\Proyectos\WME\Prueba\data\scripts\game.script", True, Size).ToInt32 <> 0) Then
                MessageBox.Show(Size.ToString())
                Game.EmptyScriptCache()
            End If
        Else
            MessageBox.Show("Compiler is not available")
        End If
    End Sub

    Public Sub CompilerCallback(ByVal Line As Integer, ByVal Text As String, ByVal Data As IntPtr)
        MessageBox.Show("Line " + Line.ToString() + ": " + Text)
    End Sub

Mnemonic, I need your help!!!  ???

Regards,

SANNOI
Logged

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re:Invoking WME script compiler from a .NET application
« Reply #2 on: December 29, 2003, 01:36:54 PM »

returns me the same error: "Line 1: Error opening include file scripts\base.inc". I've
Code: [Select]
If (Game.CompileScript("C:\Proyectos\WME\Prueba\data\scripts\game.script", True, Size).ToInt32 <> 0) Then

I guess you have to change your work dir to the project folder ("c:\Proyectos\WME\Prueba\data") before calling this function ?
Logged
Mooh!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re:Invoking WME script compiler from a .NET application
« Reply #3 on: December 30, 2003, 10:23:40 PM »

I will look into it.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.021 seconds with 24 queries.