Thread Tools Display Modes
05-25-11, 03:04 PM   #1
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
Small help with string -> function

*Edit*
Nevermind, for future reference what works is:
frame:SetScript("OnEvent", assert(loadstring(luacodestring)))
Moderator can delete thread if you like.

For example, I got a string that contains LUA code and I wish to run that code inside a OnEvent script, like this:
Code:
frame:SetScript("OnEvent", function(...)
  assert(loadstring(stringluacode))()
end)
Problem is I read you can't pass the "..." down like:
Code:
frame:SetScript("OnEvent", function(...)
  assert(loadstring(stringluacode))(...)
end)
So my question now is, anyone got any ideas how I could do this? I was thinking maybe I have to do something like this:
Code:
stringluacode = "local arg = {"..arg1..","..arg2..","..arg3.."}"..stringluacode
But I gotta escape the code and I can't pass down tables like this, kind of messy...

Last edited by Vlad : 05-25-11 at 03:19 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Small help with string -> function


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off