[w]tech combines next generation technologies like full dynamic lighting, voxel based terrain and bullet physics, which are brought to you via a self-explanatory user interface. We are thinking in innovative ways to combine the available technologies and ideas to an edgeless package. Visit wtechportal.com to get more information about the newest features integrated into [w]tech!

Report content RSS feed [w]tech – Scripting Support

Now the shooting, killing, racing, jumping and running can finally begin.

Posted by on

How can we force something to move or interact with the player? Since we can't just say it out, we have to tell the computer what it has to do on other ways. That it is: We have to write a script. Therefore we decided to use AngelScript as language because of the great support and a c++-like structure.


Scripts come in two forms

One is the GlobalScript, and the other one is the ContentMark-Script.The difference between them is that while ContentMark-Scripts are linked to a ContentMark on which they operate, GlobalScripts haven't such an anchor.
GlobalScripts are meant to be used as scripts which operate on the whole level, or to control the players. You can, though, build the same functionality of a ContentMark-Script into a Global-Script, but this leads to trouble: You'd have to register every single new instance there. This makes the script unusable for other levels and also it leads to much more complicated code than simply using a ContentMark-Script. As said above, ContentMark -Scripts are linked to a ContentMark after placing and can be accessed from inside. This way the same script can be used over and over again.


Getting something done

Now we want to show you, how you could implement a simple CM-Script which just rotates the given ContentMark. To do that, we have to create a new script-file in our browser:

ScriptingNews_1

That done, we can double-click our new file and the (rather simple) code-editor will pop up, waiting for us to get filled with code:

#include "EngineScripts.wpk\ContentMark.ws"
 
class SimpleRotation : ContentMark
{
                // Variables and Methods go here!
};

This is the basic layout of every Script-File:

  • the #include directive to the parent-class
  • the class definition which has to match the filename
  • definition of variables and methods

Since we already called that script "SimpleRotation" we want it to do exactly that.
We'll surely need the Tick() -Function, so here we go:

#include "EngineScripts.wpk\ContentMark.ws"
 
class SimpleRotation : ContentMark
{
     void Tick(float DeltaTime)
     {
                               
     }
};

As always, Tick() is getting called every frame of the engine when wanted. Makes it just perfect to animate stuff fluently. I also have to mention, that we are running the script-engine on it's completely own thread. That means that rendering-speed and script-speed aren't the same!
Back to our script now. We want our thing to rotate.To do this, we need to get access to the ContentMark we are linked to. This is done via the "GetCM()"-Function.
The call might look like this:

#include "EngineScripts.wpk\ContentMark.ws"
 
class SimpleRotation : ContentMark
{
      void Tick(float DeltaTime)
      {
           GetCM().AddRotation(0, DeltaTime, 0);
      }
};

And hey! Our script is ready to get compiled and linked!

Scripts in [w]tech


ScriptingNews_1


Comments
Kamikazi[Uk]
Kamikazi[Uk]

Nice :D, i'm going to try to incorporate lua into my engine at some point.

Reply Good karma Bad karma+1 vote
[WuTz]! Creator
[WuTz]!

I was thinking about using Lua in [w]tech at first as well. But then it turned out I don't like it that much. So I did some research and found AngelScript as the better alternative for us.

Btw: I didn't know that you are the guy who made Bounce! Nice work! :)

Reply Good karma+1 vote
blackmodeler
blackmodeler

This engine looks better every time i see it! Awesome sauce, having said that AngelScript seems like a good choice

Reply Good karma Bad karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Platforms
Windows
Company
[w]tech team
Contact
Send Message
Release date
Engine watch
Start tracking
News
Browse
News
Share
Related Engines
[w]tech
[w]tech Creative Commons
Related Groups
[w]tech team
[w]tech team Developer