Advertisement
AFRLme

start|stopAction (variable method) [VS] (works)

Nov 9th, 2012
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1. -- * notes * --
  2. -- some quick examples of startAction() | stopAction()
  3. -- start action has a return value so we'll do a version for that too!
  4. -- execute startAction in an object action like so: start_action(typ, "csname", "objname", "actname")
  5. -- execute stopAction in an object action like so: stop_action(typ, "csname", "objname", "actname")
  6.  
  7. -- * function variables * --
  8. -- typ = int{1,2 or 3} - (1[sceneAction], 2[scene > objectAction], 3[characterAction])
  9. -- csname = "string" (nil or character|scene name)
  10. -- objname = "string" (nil or scene object name)
  11. -- actname = "string" (action name)
  12.  
  13. -- * example * --
  14. -- start_action(3, "Robert", "nil", "play_sound") -- starts "play_sound" action via character Robert's action tab!
  15.  
  16. function start_action(typ, csname, objname, actname)
  17.  if typ == 1 then
  18.   local act = getObject('Scenes[' .. csname .. '].SceneActions[' .. actname .. ']')
  19.    if startAction(act) then print('SceneAction: ' .. csname .. ', ' .. actname .. ' has been started!') end
  20.  else
  21.  if typ == 2 then
  22.   local act = getObject('Scenes[' .. csname .. '].SceneObjects[' .. objname .. '].ObjectActions[' .. actname .. ']')
  23.    if startAction(act) then print('ObjectAction: ' .. csname .. ', ' .. objname .. ', ' .. actname .. ' has been started!') end
  24.  else
  25.  if typ == 3 then
  26.   local act = getObject('Characters[' .. csname .. '].CharacterActions[' .. actname .. ']')
  27.    if startAction(act) then print('CharacterAction: ' .. csname .. ', ' .. actname .. ' has been started!') end
  28.  end -- typ = 3
  29.  end -- typ = 2
  30.  end -- typ = 1
  31. end -- function
  32.  
  33. function stop_action(typ, csname, objname, actname)
  34.  if typ == 1 then
  35.   local act = getObject('Scenes[' .. csname .. '].SceneActions[' .. actname .. ']')
  36.    stopAction(act)
  37.     print('SceneAction: ' .. csname .. ', ' .. actname .. ' has been stopped!')
  38.  else
  39.  if typ == 2 then
  40.   local act = getObject('Scenes[' .. csname .. '].SceneObjects[' .. objname .. '].ObjectActions[' .. actname .. ']')
  41.    stopAction(act)
  42.     print('ObjectAction: ' .. csname .. ', ' .. objname .. ', ' .. actname .. ' has been stopped!')
  43.  else
  44.  if typ == 3 then
  45.   local act = getObject('Characters[' .. csname .. '].CharacterActions[' .. actname .. ']')
  46.    stopAction(act)
  47.     print('CharacterAction: ' .. csname .. ', ' .. actname .. ' has been stopped!')
  48.  end -- typ = 3
  49.  end -- typ = 2
  50.  end -- typ = 1
  51. end -- function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement