hello,I believe I got it working; I just wrote get/set methods for the variables, wihch I can eval. This allows me to control what gets changed via eval, as well. I have one more question; is there a way to do something like an array of function pointers in c++, or the equiv of a delegate in .net, so I can use hooks? The functions will have something like the following prototype:
void hook(void* data) That's my c implamentation, but it would be similar.On another note, thanks for the help, both jamal and brandon. Haven't heard from you in forever, hows things going?
Thanks, Tyler Littlefield Web: tysdomain.com email: tyler@xxxxxxxxxxxxx My programs don't have bugs, they're called randomly added features.----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <program-l@xxxxxxxxxxxxx> Sent: Tuesday, March 24, 2009 9:08 AM Subject: [program-l] Re: quick python question
You can use the eval function to evaluate an expression, or in your example, the exec statement to execute a statement (Python draws a distinction between an expression and a statement). Note that use of such techniques can risk security if there is a way for arbitrary code to be injected from an external source. Jamal On Mon, 23 Mar 2009, Tyler Littlefield wrote:Date: Mon, 23 Mar 2009 21:57:49 -0600 From: Tyler Littlefield <tyler@xxxxxxxxxxxxx> Reply-To: program-l@xxxxxxxxxxxxx To: program-l@xxxxxxxxxxxxx Subject: [program-l] quick python question Hello list,I'm working on a mud that uses python as it's scripting language, and had a quick question.Is it possible to evaluate python code? Like, from within the mud I'd like to do something like: eval (find_char("azar")).level=100 and have azar's level be set to 100. Thanks, Tyler Littlefield Web: tysdomain.com email: tyler@xxxxxxxxxxxxx My programs don't have bugs, they're called randomly added features.** To leave the list, click on the immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe] ** If this link doesn't work then send a message to: ** program-l-request@xxxxxxxxxxxxx ** and in the Subject line type ** unsubscribe ** For other list commands such as vacation mode, click on the ** immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq] ** or send a message, to** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe] ** If this link doesn't work then send a message to: ** program-l-request@xxxxxxxxxxxxx ** and in the Subject line type ** unsubscribe ** For other list commands such as vacation mode, click on the ** immediately-following link:- ** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq] ** or send a message, to ** program-l-request@xxxxxxxxxxxxx with the Subject:- faq