Jump to content
  • Advertisement
Sign in to follow this  

Scripting vs Event Driven system

This topic is 5065 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

currently my event system looks like
		<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 name="blankout">
			<Wait time="200" />
			<BlankOutScreen />
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");
	print("Random : ok, ok , ok");

	sub blankout()

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)

Share this post

Link to post
Share on other sites

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.

Cornutopia Games

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!