Author Topic: Can model animations be triggered by Sexp?  (Read 2514 times)

0 Members and 1 Guest are viewing this topic.

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Can model animations be triggered by Sexp?
Well, can they? I know they can be scripted, but I don't know any LUA at all, and for a few meshes I have planned a sexp based implementation would be immensely useful (And don't tell me to learn LUA, my brain isn't set up to program and I really don't have the time).
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: Can model animations be triggered by Sexp?
You can adjust rotating subsystems.  Start them, stop them and adjust their speed and direction (clockwise, counter-clockwise).  That may be it, though.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Can model animations be triggered by Sexp?
i think you can trigger one of the tabled animations with a sexp, if you can get the system to work that is. i usually just cheat and use scripting to change a submodel's orientation matrix.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Re: Can model animations be triggered by Sexp?
You can trigger a tabled animation, yes. Unfortunately, you can't (yet) choose which one: every such animation the ship has will be triggered.

The Lua code to do it is as simple as this:
Code: [Select]
shiphandle:triggerAnimation("scripted", 0, true)Use false instead of true if you want to play the animation(s) backwards.

The animation tabling needs these:
Code: [Select]
  $animation:                 triggered
  $type:                      scripted

And the subobject needs to have these props:
Code: [Select]
$special=subsystem
$triggered:

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: Can model animations be triggered by Sexp?
You can trigger a tabled animation, yes. Unfortunately, you can't (yet) choose which one: every such animation the ship has will be triggered.

The Lua code to do it is as simple as this:
Code: [Select]
shiphandle:triggerAnimation("scripted", 0, true)Use false instead of true if you want to play the animation(s) backwards.

The animation tabling needs these:
Code: [Select]
  $animation:                 triggered
  $type:                      scripted

And the subobject needs to have these props:
Code: [Select]
$special=subsystem
$triggered:

Triggering everything isn't ideal, but it shouldn't be a gamebreaker either.

This part:
Code: [Select]
shiphandle:triggerAnimation("scripted", 0, true)
I'm assuming goes into scripting.tbl, somehow? Or can it be done directly with script-eval?

Complete scripting novice here - I've only ever used it for gravity and that's about it.  :nervous:
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Re: Can model animations be triggered by Sexp?
This part:
Code: [Select]
shiphandle:triggerAnimation("scripted", 0, true)
I'm assuming goes into scripting.tbl, somehow? Or can it be done directly with script-eval?

Complete scripting novice here - I've only ever used it for gravity and that's about it.  :nervous:

Yes, you can use script-eval, and probably what you should do if you're not comfortable with scripting.

Use this as your scripting.tbl, or as whatever-sct.tbm, or just add everything except the first and last line to an existing file:
Code: [Select]
#Conditional Hooks

$Application: FS2_Open

$On Game Init: [

    trigger_anim = function(shipname)
        mn.Ships[shipname]:triggerAnimation("scripted", 0, true)
    end
   
    trigger_anim_reverse = function(shipname)
        mn.Ships[shipname]:triggerAnimation("scripted", 0, false)
    end

]

#End

Then, you can call those functions with script-eval like this:
Code: [Select]
( script-eval "trigger_anim('Alpha 1')" )
Yes, the argument to give is literally "trigger_anim('Alpha 1')". It's a bit of a hassle, since if you don't want to hardcode the ship name in every call, you'll have to concatenate the argument string from "trigger_anim('", the ship's name and "')". I'm sure you can also pass the boolean value as a second argument instead of defining two functions somehow, but I haven't tested that.

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: Can model animations be triggered by Sexp?
Awesome. I will have a use for this very soon. Thanks heaps. :)
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Can model animations be triggered by Sexp?
you should probably idiotproof those functions though. like make sure the ship handles are valid. this is why i really wish we could embed scripts in missions, so you could distribute scripted missions without needing any tables or mod directories.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: Can model animations be triggered by Sexp?
this is why i really wish we could embed scripts in missions, so you could distribute scripted missions without needing any tables or mod directories.

:yes: from me

  
Re: Can model animations be triggered by Sexp?
Would be amazing to see this being improved, though great that the current method's already posted. All I need now is a carrier with animated opening/closing doors and cutscenes will look much better to me. ;)
I'm all about getting the most out of games, so whenever I discover something very strange or push the limits, I upload them here:

http://www.youtube.com/user/JCDentonCZ

-----------------

The End of History has come and gone.