H
heavydada
I'm writing a small game in python and I need to be able to run some
scripts inside the game. In the game I have these creatures each with
some attributes like name and weight and an action. Right now I'm
saving all this information in an XML file, which I parse whenever I
need it. I can handle the attributes like name and weight because these
are just values I can assign to a variable, but the action part is what
has me stumped. Each of the creatures has a different action() function
(as in, each does something different). I was wondering how I can read
commands from the XML file and then execute them in the game. I read a
document that talked about this, but it was written in Visual Basic and
used a method called callByName or something like that. It could call a
function simply by sending the name as a string parameter. I was
wondering if there was an equivalent in python. I just need some way of
being able to read from the file what function the program needs to
call next. Any help is appreciated.
scripts inside the game. In the game I have these creatures each with
some attributes like name and weight and an action. Right now I'm
saving all this information in an XML file, which I parse whenever I
need it. I can handle the attributes like name and weight because these
are just values I can assign to a variable, but the action part is what
has me stumped. Each of the creatures has a different action() function
(as in, each does something different). I was wondering how I can read
commands from the XML file and then execute them in the game. I read a
document that talked about this, but it was written in Visual Basic and
used a method called callByName or something like that. It could call a
function simply by sending the name as a string parameter. I was
wondering if there was an equivalent in python. I just need some way of
being able to read from the file what function the program needs to
call next. Any help is appreciated.