[Ipe-discuss] "loadstring" in ipelets

Otfried Cheong otfried at ipe.airpost.net
Sat Oct 24 21:22:43 CEST 2009


Jan Hlavacek wrote:
> I was wondering if somebody familiar with lua could help me with this:
> 
> I am just learning lua, and I am trying to write an ipelet in which I need to
> execute a user supplied piece of lua code. I am trying to use "loadstring", but
> I always get an error: 
> 
> attempt to call global 'loadstring' (a nil value)

This looks like an interesting ipelet when it's finished :-)

 From the documentation:

The "global" environment of the ipelet is a private environment for this
ipelet only, so there is no need to fear polluting the global namespace
- you can use names here freely. The commonly used names have been
imported from Ipe's global namespace already, and you can access any
others you may need through _G.

So what you need to do is to simply put:

loadstring = _G.loadstring

at the top of your ipelet (or write "_G.loadstring" instead of 
"loadstring" in your code).

Cheers,
   Otfried






More information about the Ipe-discuss mailing list