Need help with creating a Scripting engine?

Started by
13 comments, last by whimage13 22 years, 5 months ago
Python is yet another possibility. QUARK, the quake editor, uses it among others.
Advertisement
If you are only trying to not hardcode data into your application, scripting is not the way to go. Use text (or binary) files, to load the data into the application at run time. It will save you lots of time, and pain =).

Z.
______________"Evil is Loud"
i try use Python (for write script) embed in my RPG. But i difficult to find some Python/C tutorials, samples.
I Don''t know how to start It.

Could you give me some useful python website? Thanks.

Terence Mok



The Python site is here. I imagine that is where you got Python at though. On that site is a document called Extending and Embedding the Python Interpreter. It walks you through all the basics needed to get started. There is also another document called Python/C API Reference Manual. It gives you a more detailed explaination of the actual calls and data types.

Most likely you have aleady found all that. If so then I would say it is most likely your approach. Just jumping in and embedding it right off the bat is a bad idea. Rather you should play with it a bit. If you know OpenGL then try the PyOpenGL. I assume you know Windows so PythonWin would be another extension to play with. It takes a little searching but you can find quite a few interesting extensions. That gives you an idea of how your script interacts with an extension. Embedding Python is mainly about extending Python. You call a script and the script calls functions in your program. Extensions such as PythonWin are extremely complex so you get limited benefit from actually digging through it. Rather you use your knowledge of Windows or OpenGL to make sense of what is going on.

Once you have a handle on using Python and extensions for it work on create a small library of scripts. The user can''t tell the differance between calling another script and calling some function you wrote in C. There is more work involved in coding your function in C though. So you want to get the big picture first. Once you have a feel for the ins and outs of how you might call a function convert it to C as an extension. Embedding Python is mainly about extending it. The only real differance is that instead of the operating system invoking the interpreter you invoke it. Figuring out how to embed it effectively is a litle more involved. That is mainly an application design issue though.

Overall it takes time. If you have no related experience then it may take anywhere from a month to three months to get a handle on it. You won''t be an expert, but you will know more than most. You can certainly spin your wheels much longer if you don''t break it down into small steps that are each fairly simple. It would be like jumping into Windows and trying to figure out how to do inplace editing right off the bat instead of first learning how to create a window. It is simple once you have all the pre-requist knowledge. Once you know how to do it and do it a couple of times it takes no more than a day. Use cut and paste or a library and it can be minutes. That is what makes it a simple task. Learning how is not a simple task. The good thing is that once you do it with one scripting engine the next one is far easier. Instead of a month to three months it becomes a week to a month depending on how dramatic the differances.
Keys to success: Ability, ambition and opportunity.
Thank you suggestion. Then i discover very good sample about script engine of RPG (embed python) c program.

http://www.vex.net/parnassus/apyllo.py?i=580372690
thank author

but test.py need modify

from std import *
from pi import textbox
import system
from pi import party

This topic is closed to new replies.

Advertisement