Jump to content

My scene scripting library


Rick
 Share

Recommended Posts

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.

  • Upvote 1
Link to comment
Share on other sites

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!

  • Upvote 1

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...