Calling scripting engine from within script

Posted by Poromenos on Fri 06 Jun 2003 02:10 PM — 9 posts, 25,114 views.

Greece #0
OK, this is a bit wild, but i see no reason why it wouldn't be possible.
Is it possible to encode a string in Base64, include it in a plugin, and then create an instance of the scripting engine, and have it call the decrypted code?
It won't be able to use MUClient functions, will it?
I mean something like this:
Set myScripting = CreateObject("Scripting.FileSystemObject")
myScripting.Execute(Base64Decrypt("<Base64ed code here>"))

Will it be able to decrypt newlines correctly? And will it be able to use MUClient functions?
Australia Forum Administrator #1
I doubt that will work insofar as it won't know about the world object, as that is done by passing a reference to the scripting engine of the world (although you could get that, the word "world" being such a reference).

However if you simply Exec the string it would create new things (eg. subs) in the existing script space, which might be good enough.
Australia Forum Administrator #2
The Base64Decode will decrypt newlines correctly, yes, however it won't handle the NULL character (0x00) which probably won't matter in this case. It handles the 0x00 in a sense, but as the strings are stored internally as null-terminated you won't get back the bit past the null.
Greece #3
OK, good enough. I won't be needing the null character anyway, and if i ever do, i could just use vbnull or something...
Greece #4
Oh hmm, that means i won't be able to call GetPluginInfo though... Can you give me an example of passing the "World" reference to the scripting engine, if it's possible?
Australia Forum Administrator #5
If a plugin does that I don't see why it couldn't.

I don't know how a script would make a whole new script engine and I don't propose to try.

However the idea of simply decoding and then doing an "exec" should fit most of what you are trying to do, whatever that is.
Greece #6
Oh, you mean using the internal World.Execute? Isn't that dependant on the current script char? I.e. if the script char is "//", "/world.note" will not work.
I was thinking of linking the Microsoft Script Control through COM and then manipulating it, much like VB programs do... It would be nice if there was a world.exec function that just executed something as if it was scripted. "Why would you want scripts to script?" That way, the player could execute commands taken from triggers... I'll go check the online helpfile, see if anything like that exists.
Australia Forum Administrator #7
No, I mean the ability of VBscript to execute arbitrary code supplied in a string. See this posting for an example:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1297
Greece #8
God, this just keeps getting better and better... I love MUClient...