Scripting vs Event Driven system

Started by
0 comments, last by Cornutopia 19 years, 3 months ago
currently my event system looks like

	<Hub>
		<New name="dialogue" on="1">
			<Print str="Cloud : ... I don't know" />
			<MoveObject name="randomnpc" x="100" y="160" />
			<StartThread name="blankout" />
			<Print str="Random : ok, ok , ok" />
		</New>

		<New name="blankout">
			<Wait time="200" />
			<BlankOutScreen />
		</New>
	</Hub>
and im thinking about replacing it with a scripting language (i use Perl alot so that would be ideal), and have been looking at GDNet articles.

In the game engine Hub contains Threads (which have a list of various events which it runs through when the thread is triggered). There is also a lookup table where the thread on creating its list of events, passes the xml element to the table which parses it for the event name and passses this to the event (to initialize its variables), and returns the ready event to the thread.

So the on every game loop, the hub runs through every event, calling currthread->Run(), and inside the thread calls currevent->Run() ++currevent.

BTW ++currevent is only done once currevent returns OK (the other choice being WAIT - i.e if it was an event testing for a condition).

I want to know, would moving to a scripting language approach improve the ease of creating event structures? Would i need to make any serious changes to my event structure at the moment (could I tie events to function calls?)? What languages would you recommend (would Perl work?)?

Am i correct in thinking the above would become


	print("Cloud : ... I don't know");
	MoveObject("randomnpc",100,160);
	blankout();
	print("Random : ok, ok , ok");

	sub blankout()
	{
		wait(200);
		BlankScreen();
	}

How could I have the main code and blankout run at the same time (i.e wait and print happen in same loop)?

(im new to scripting languages integrated into compiled code)

Advertisement
Quote:
How could I have the main code and blankout run at the same time (i.e wait and print happen in same loop)?


I've written a couple of script languages but I've never tried multitasking one. I think you would have to make a class for the script (that contains the pointer to the current line, as well as the commands) and when you interpret your function call, create a new instance of the class, and copy the subroutine to it. Your main loop would need to search every active instance of the script class and interpret one command.

Mark
Cornutopia Games
http://www.cornutopia.net

This topic is closed to new replies.

Advertisement