Rick Posted December 9, 2009 Share Posted December 9, 2009 Just a small little demo of the early works of my lua scripting scene library. Basically it allows you to make complex "scenes" in your game through scripting and a few map elements. Here is the code to the scene. The scene library functions have the Do in front of them and the GetEntityByName() and RunScript(). In the beginning you can the pivots setup and in the code you can see I assign those to variables for easier access. The library currently has: DoWait() -- waits x ms before continuing on with the script. Note I said just the script because the entire game continues to play. Only the function you defined waits. This is the best part of this. Your function isn't blocking to the game. DoSound() -- waits to continue with your script until the sound is finished. All the sound you hear are wav files that I created DoMoveTo() -- waits to continue until one entity reaches a destination entity function MyScript(cr) local pivot1 = GetEntityByName("pivot1") local pivot2 = GetEntityByName("pivot2") local pivot3 = GetEntityByName("pivot3") local pivot4 = GetEntityByName("pivot4") local general = GetEntityByName("pivot_7") local generalModel = GetEntityByName("1_4") local soldier = GetEntityByName("pivot_5") local miscSoldier = GetEntityByName("1_42") local miscSoldierModel = GetEntityByName("1_6") local camera = fw.main.camera PositionEntity(camera, EntityPosition(pivot1)) PointEntity(camera, miscSoldier, 3, 1, 0) DoWait(cr, 2000) DoSound(cr, "abstract::hello1.wav") PositionEntity(camera, EntityPosition(pivot2)) PointEntity(camera, soldier, 3, 1, 0) DoSound(cr, "abstract::ripoff.wav") DoWait(cr, 500) PositionEntity(camera, EntityPosition(pivot3)) PointEntity(camera, general, 3, 1, 0) DoSound(cr, "abstract::whosaidthat.wav") DoWait(cr, 500) PositionEntity(camera, EntityPosition(pivot2)) PointEntity(camera, soldier, 3, 1, 0) DoSound(cr, "abstract::idid.wav") DoWait(cr, 1000) PositionEntity(camera, EntityPosition(pivot1)) PointEntity(camera, miscSoldier, 3, 1, 0) DoMoveTo(cr, generalModel, pivot4, .005, .5, miscSoldierModel) DoSound(cr, "abstract::private_joker.wav") DoWait(cr, 250) PositionEntity(camera, EntityPosition(pivot2)) PointEntity(camera, soldier, 3, 1, 0) DoSound(cr, "abstract::from.wav") DoWait(cr, 500) -- debugging, makese it easier to go back to starting point PositionEntity(camera, EntityPosition(pivot1)) PointEntity(camera, miscSoldier, 3, 1, 0) SetGlobalNumber("runGame", 2) end -- this kicks the script off RunScript(MyScript) There is a bug in the DoMoveTo() which you can see at the end. The "general" guy seems to be slowly moving upward as he moves. This scene took me about 20 mins to setup. This is pretty powerful because you can create very complex "scenes"/interactions in your game with very little effort and logical flow. I will release the lua code when I'm complete but if you are interested in how I did this you can look into lua's coroutines. 1 Quote Link to comment Share on other sites More sharing options...
TylerH Posted December 9, 2009 Share Posted December 9, 2009 Very nice. Once you release the source, if you didn't mind, I would love to add Catmull-Rom and Quaternion support to it. We could get a nice Cinematic toolkit together with this. Great project Rick! 1 Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Josh Posted December 9, 2009 Share Posted December 9, 2009 This is the first of many LULZ! Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Rick Posted December 12, 2009 Author Share Posted December 12, 2009 I added a little interactivity to the script. It asks you to press a number to tell private joker on how many laps to run. In this video I pressed 3, but it handles 0-9. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted December 12, 2009 Author Share Posted December 12, 2009 Now with animation! 1 Quote Link to comment Share on other sites More sharing options...
TylerH Posted December 13, 2009 Share Posted December 13, 2009 Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Josh Posted December 13, 2009 Share Posted December 13, 2009 You should write a script and have various people on the forum voice it. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
TylerH Posted December 13, 2009 Share Posted December 13, 2009 That would be fun. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Rick Posted December 13, 2009 Author Share Posted December 13, 2009 Good idea. I'll start up a thread. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.