Hello, everyone.
I am doing some searching and winding up a little bit confused. I have
a MUD client that I am writing using Python and wxWidgets, as some of
you may remember. What I am looking to do now, is add "trigger"
functionality to it. In essence, the application receives text from the
game, and if it is in any of the trigger definitions, it acts on it by
executing Python code that the user has associated with the action.
So, the question is, what is the safe way to do this? I have found the
'compile' function, which returns a code object(?) which I would want to
execute using 'exec'.
Here is a hypothetical example: I want to have a trigger that, when the
game sends the text "That really did HURT!", executes code to instruct
the character to ingest a potion to fix that problem.
In this situation, the user would provide 'That really did HURT!' as the
regular expression, which the game would examine, find that there are no
RE qualifiers in there (e.g., no $, ^, or similar to bind the string to
something else) and turn it into '.*(That really did HURT!).*' to match
it any time the game sends it (unless it breaks in the middle of a
transmission, which I wouldn't be quite sure how to handle, yet).
The associated code, let's say, would be something like:
========
Tmud.Send('quaf f red')
========
Which would send the text to the game.
Eventually, I would want to support complex things, like handling $1 or
$2 which might be associated with saved portions of the regex, but I
will get there later.
The question is really two-fold: How can I safely permit the user to
specify Python to be used as part of the game, and how can I create a
module that is used for the user's required functions (e.g., Tmud.Send,
as an example) without requiring each trigger to 'import' something?
I seem to be able to find tons of information on embedding Python in
C/C++/compiled language programs, but not much on safely executing it
within a Python program. What I really want to do is prevent them from
calling anything that would affect the game client's runtime environment
-- at least from a trigger. I want to later have some sort of "plug in"
mechanism that people could use to create graphs/charts/meters of
in-game events, but not yet, and that would be separate.
Any ideas? Thanks in advance!
-- Mike 0 975 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tubby Tudor |
last post by:
What is the best way to call one python script from within another
python script? For example:
one.py finishes succesfully and calls two.py which finishes OK and then
calls three.py
Thanks guys!
|
by: Andrew McCall |
last post by:
Hi Folks,
I am building an application under multiple OS's, and I wanted to give
my application
For example, the test application I am working on is a calculator and I
would like to have a menu in the GUI option to open a command line
where you can use Python commands to perfom the functions of the
application within the Python command line. For example, if I wanted
to clear the display or display the about screen I would be able type
|
by: André |
last post by:
First, an apology: I realise that I don't know enough about what I am
asking to make sure to use the proper language to phrase my question.
I would like to use a browser (e.g. Firefox) as a simple GUI
"framework". Note that this is to be done on a single user machine, so
the question of sandboxing is not really relevant here.
The simplest application I would like to start with would be one with
two "windows" (within a browser window)...
|
by: AndyL |
last post by:
Hi,
let me describe how I do that today. There is standard python taken from
python.org installed in a c:\python23 with at least dozen different
additional python packages (e.g. SOAPpy, Twisted, wx, many smaller ones
etc) included. Also python23.dll moved from c:\windows to c:\python23.
This is zipped and available as over 100MB file to anyone to manually
unzip on his/her PC. This is a one time step.
On top of that there is 30K lines...
|
by: jefishman |
last post by:
I have a Python (2.3.x) interpreter running embedded in a C++
application on a host machine. I would like to run a specific package
on that host machine (numpy). I have managed to compile
(cross-compile) the library, so that I have the python modules and the
compiled .so files. I am relatively sure that these would import
normally in a standard interpreter (they give bad magic on the build
machine).
However, I would like to be able...
| |
by: Simon Eves |
last post by:
I am trying to write a Python module to embed the functionality of
Maya (the 3D modelling and animation application from Autodesk,
formerly Alias) for doing scripted scene manipulation and rendering
processes in Python.
I am aware of the CGKit project, which does this and a lot more, but
it is over-complex for our needs, and also does not work in the
context of a pure command-line Python script, only as an alternative
scripting language...
|
by: Adam Atlas |
last post by:
Does anyone know if it would be possible to create a CPython extension
-- or use the ctypes module -- to access Python's own embedding API
(http://docs.python.org/api/initialization.html &c.)? Could a Python
program itself create a sub-interpreter, and work with it with all the
privileges and capabilities that an actual C program would have?
I realize that this may be a bit too... mystical? ... for a lot of
people's tastes, but I'm just...
|
by: iu2 |
last post by:
Hi
I'm trying to make a method call automatically to its super using this
syntax:
class A:
chained =
def pr(self):
print 'Hello from A'
|
by: Kurt Mueller |
last post by:
David,
Am 07.10.2008 um 01:25 schrieb Blubaugh, David A.:
As others mentioned before, python is not the right tool for "HARD
REAL TIME".
But: Maybe you can isolate the part of your application that needs
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |