Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, ChrstphFr), 875 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Using functions from a DLL (ChatScript in Lite-C) #433549
12/02/13 00:05
12/02/13 00:05
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Hello, everyone. For the past week I have been trying to use a dll in Lite-C but can't seem to get it to work.

I just need to be able to call 2 functions from the dll:
Code:
unsigned int InitSystem(int argc, char * argv[],char* unchangedPath = NULL,char* readonlyPath = NULL, char* writablePath = NULL);

void PerformChat(char* user, char* usee, char* incoming,char* ip,char* output);



Bruce Wilcox has been kind enough to make me a dll for his ChatScript, and has been helping me to get this to work in Lite-C but I don't know much about dll's and can't get this to work. I have used other dll's such as Anet, but all I had to do was dump the dll and .h file in my game's folder and include the .h in my code. I have never actually had to make a .h file myself for a dll.

Getting back to the basics I am not trying to include it in my own project, rather just made a new test project folder and dumped the dll file in there. My current "test.c" file looks like this:
Code:
#include <acknex.h>
#include <windows.h>

unsigned int WINAPI InitSystem(int argc, char** argv,char* unchangedPathL,char* readonlyPath, char* writablePath);
void WINAPI PerformChat(char* user, char* usee, char* incoming,char* ip,char* output);
long ChatScript_h;
STRING* chatscript_answer;

void main()
{
	fps_max=60;
	level_load(NULL);
	
	//while(!GetModuleHandle("ChatScript.DLL")){wait(1);}
	
	ChatScript_h = LoadLibrary("ChatScript.DLL");
	InitSystem = GetProcAddress(ChatScript_h,"InitSystem");
	PerformChat = GetProcAddress(ChatScript_h,"PerformChat");
   
   chatscript_answer=str_create("#128");
	InitSystem(0,NULL,NULL,NULL,NULL);
	PerformChat(_chr("Carlos"),_chr("Harry"),_chr("Hello"),NULL,_chr(chatscript_answer));
	
	while(1)
	{
		wait(1);
	}
}



Can anyone help me spot what I am doing wrong? When I try to run the code I get an Error E1513 Script Crash in Main.

I have commented out "while(!GetModuleHandle("ChatScript.DLL")){wait(1);}" because it always returns 0 and gets stuck there.

It seems the dll is never loading? Do I have to use any other function before all that to open the dll?

Here is the relevant contents of my acklog.txt
Quote:
Mouse found
Altavoces (Dispositivo de High Definition Audio) opened
NVIDIA GeForce GT 610 pure T&L device 1ff9 detected
D3D device NVIDIA GeForce GT 610 1ff9 selected.
ackAR.dll opened
acknet.dll opened
ackoal.dll opened
ackphysx.dll opened
ackwii.dll opened
Compiling TEST2.C - [Esc] to abort.....
InitSystem: function not found
PerformChat: function not found.... 0.302 sec
Running TEST2.C.
2 objects
Main started at 1.400 in debug mode
D3D_Init Window: 800x600 -> Window: 1x800x600x32
Video memory found: 3787 MB
LevelInit at 1.434 0 lmaps 0 textures...ok
LevelReady at 1.438
Error E1513: Script crash in main:
Main loop at 2.899....
1st frame with 3787 MB. at 2.903
Normal exit at 4.385
Close level,DLL,objects


I don't see "ChatScript.DLL" in that acklog either... I guess it is not opening the dll... (both "test.c" and "ChatScript.DLL" are in the same folder).
Any help with this would be great

EDIT: If anyone would like to see the original conversation with Bruce you can find it at the chatscript forums here:
http://www.chatbots.org/ai_zone/viewthread/1552/P15/

Last edited by Carlos3DGS; 12/02/13 00:13. Reason: link

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Using functions from a DLL (ChatScript in Lite-C) [Re: Carlos3DGS] #433551
12/02/13 06:51
12/02/13 06:51
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

First, only plugins appear in the log and at engine startup.

It seems that you are using a simple C DLL. for that you need to see DLLs and APIs

Re: Using functions from a DLL (ChatScript in Lite-C) [Re: 3dgs_snake] #433554
12/02/13 10:02
12/02/13 10:02
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Originally Posted By: 3dgs_snake
only plugins appear in the log and at engine startup.

Would this dll be considered a plugin?

Originally Posted By: 3dgs_snake
It seems that you are using a simple C DLL. for that you need to see DLLs and APIs

I think chatscript was written in c++... Would that be a problem?

Thanks for the link, when trying to write the header I did come across that page from the manual and am trying to understand it.
I can sort of understand the section titled "Declaring a DLL or Windows API Function" but the when it comes to the other one "Using C++ classes and the COM model" I am completely lost. Do I need to understand that part? I am afraid I am way out of my league there.


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1