HOw to embed newLISP?
HOw to embed newLISP?
Hello,
I was wondering if I could (and how?) embed newLISP interpreter in another application (windows) just like other scripting languages like LUA, AngelScript, etc...
I'm creating a 3D game using 3D Game Studio, and since this is a particular game, I wanted to embed a scripting system. So I wanted to use newLISP for modding scripting.
3DGS let me manage standard DLLs.
1) Do you think it is feasible?
2) Is it difficult?
3) How could I enchange data between my game and scripting?
Thank you!
I was wondering if I could (and how?) embed newLISP interpreter in another application (windows) just like other scripting languages like LUA, AngelScript, etc...
I'm creating a 3D game using 3D Game Studio, and since this is a particular game, I wanted to embed a scripting system. So I wanted to use newLISP for modding scripting.
3DGS let me manage standard DLLs.
1) Do you think it is feasible?
2) Is it difficult?
3) How could I enchange data between my game and scripting?
Thank you!
--
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
He means me. ;-)
But you should search for newlisp.dll or look at
http://www.alh.net/newlisp/phpbb/viewto ... ewlisp+dll
So newlisp.dll is a standard windows dll and there is a function 'newlispEvalStr' exported.
This is what you call.
This function returen a PChar-string as result.
Of cource you can add other callbacks into you code from newlisp.
Therefore newlisp imports functions from your host-app.
I have used this from various plattforms:
neobook-plugin
delphi
powerbasic
There is also a demo for Excel here on the forum.
But you should search for newlisp.dll or look at
http://www.alh.net/newlisp/phpbb/viewto ... ewlisp+dll
So newlisp.dll is a standard windows dll and there is a function 'newlispEvalStr' exported.
This is what you call.
This function returen a PChar-string as result.
Of cource you can add other callbacks into you code from newlisp.
Therefore newlisp imports functions from your host-app.
I have used this from various plattforms:
neobook-plugin
delphi
powerbasic
There is also a demo for Excel here on the forum.
Hans-Peter
Thank you! This is a good starting point.
But it is not for me launching simple evals. I need to startup a kind of engine, and the script should be loaded then the functions should be recalled. Let's say that newLISP environment should be statefull, and I need to configure the environment (variables, user defined functions, etc...).
Look at the concept how LUA works (or even AngelScript, or other scripting languages "embedded" in other applications).
Basically, these steps should be followed:
1) start main application (my application)
2) start newLISP engine
3) load functions in newLISP, register variables, startup needed functions to make interaction between my application and newLISP.
4) The program now is running, and there is a complete interaction back and forth from my app and newlisp (and vice-versa).
Using only the dll (using only the eval), is not the way to fully embed a language inside another one.
However, I will study the link you sent me.
Thank you!
But it is not for me launching simple evals. I need to startup a kind of engine, and the script should be loaded then the functions should be recalled. Let's say that newLISP environment should be statefull, and I need to configure the environment (variables, user defined functions, etc...).
Look at the concept how LUA works (or even AngelScript, or other scripting languages "embedded" in other applications).
Basically, these steps should be followed:
1) start main application (my application)
2) start newLISP engine
3) load functions in newLISP, register variables, startup needed functions to make interaction between my application and newLISP.
4) The program now is running, and there is a complete interaction back and forth from my app and newlisp (and vice-versa).
Using only the dll (using only the eval), is not the way to fully embed a language inside another one.
However, I will study the link you sent me.
Thank you!
--
>1) start main application (my application)
No problem
>2) start newLISP engine
No problem
>3) load functions in newLISP, register variables, startup needed functions to make interaction between my application and newLISP.
Depends what you mean with interaction.
>4) The program now is running, and there is a complete interaction back and forth from my app and newlisp (and vice-versa).
There is always one leading site. There is running the main-loop of the app. And that is mostly the GUI part which is waiting for events.
No problem
>2) start newLISP engine
No problem
>3) load functions in newLISP, register variables, startup needed functions to make interaction between my application and newLISP.
Depends what you mean with interaction.
>4) The program now is running, and there is a complete interaction back and forth from my app and newlisp (and vice-versa).
There is always one leading site. There is running the main-loop of the app. And that is mostly the GUI part which is waiting for events.
Hans-Peter
>2) start newLIS
User (final game programmer) should be able to use newLISP to write A.I, write specific events to create a game scenario, etc...
(I don't know I if the concept is enough clear...).
Good news! Does it mean that, in this case, newLISP does NOT work as a CGI-like system (newLISP interpreter is executed->newLISP program is executed->interpreter is closed) but like a "server" (interpreter is executed and it is waiting for "commands"; it means if I set a global variable with a function, I will find that variable already set to the next function call).P engine
No problem
You are right. I want to startup newLISP environment like a "server". My application (the game) will "load" the scripts in newLISP environment, will setup needed variables, etc... (prepare the environment). Then my game will run, and will call newLISP specific functions to resolve A.I., vehicle movements, perform user specific activities, etc...>3) load functions in newLISP, register variables, startup needed functions to make interaction between my application and newLISP.
Depends what you mean with interaction.
There is always one leading site. There is running the main-loop of the app. And that is mostly the GUI part which is waiting for events.
User (final game programmer) should be able to use newLISP to write A.I, write specific events to create a game scenario, etc...
(I don't know I if the concept is enough clear...).
--
Yes, the DLL is loaded into the workspace of your host app and remains there until shutdown. It stores the state of all variables and symbols.interpreter is executed and it is waiting for "commands"; it means if I set a global variable with a function, I will find that variable already set to the next function call.
When I start with newlisp.dll a long time ago, my first use was to process the return value of 'newlispEvalStr'. Over time this I realize that this was limiting the possibilitys. So I exported a function interface from my host-app and import that functions from newlisp.
The scenario works like this:
A GUI event happens and it calls 'newlispEvalStr'.
Some lisp gets executed and it optionally calls direct functions via the imported functions.
Then it returns from the 'newlispEvalStr'and the main-app is back in the main-loop.
Links to samples for delphi and powerbasic:
http://www.alh.net/newlisp/phpbb/viewto ... ght=delphi
http://www.alh.net/newlisp/phpbb/viewto ... powerbasic
Of cource there is also the other concept from the newlisp-IDE.
The new java GUI and the old TCL-TK GUI works as 2 independent processes where a communication via TCP/IP is used.
You can see both processes in the tasklist.
Hans-Peter
There were other sample listed here:
http://www.newlisp.org/index.cgi?Code_Contributions
And importing a standard lib should be not difficult.
Maybe the C/C++ experts here can give a sample.
http://www.newlisp.org/index.cgi?Code_Contributions
And importing a standard lib should be not difficult.
Maybe the C/C++ experts here can give a sample.
Hans-Peter