Author Topic: Re: Discussing scripting vs sexps in missions  (Read 1989 times)

0 Members and 1 Guest are viewing this topic.

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Discussing scripting vs sexps in missions
Scripts are good because they are very easy to call from multiple missions. Scripts are tricky because you can't customize their behavior on a per-mission/per-ship basis like you can with SEXP chains.

 

Offline StarSlayer

  • 211
  • Men Kaeshi Do
    • Steam
Re: Re: Discussing scripting vs sexps in missions
“Think lightly of yourself and deeply of the world”

 

Offline Axem

  • 211
Re: Re: Discussing scripting vs sexps in missions
Scripts are good because they are very easy to call from multiple missions. Scripts are tricky because you can't customize their behavior on a per-mission/per-ship basis like you can with SEXP chains.

I'd disagree with that. A script can be as simple or complex as you like it. If you construct it in a well thought out generic way it can be just as versatile as a sexp.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Re: Discussing scripting vs sexps in missions
It's hard to build a script that talks to SEXP logic. It's easy to use complex events to call scripts, but hard to build scripts that work with complex events, right?

I'm thinking about **** like "send a message from the most angry character if the mission time is between 30 and 90 seconds and ship B has been destroyed using gun X and then this ability is triggered." I know how to do that trivially with event logic. I feel like a script would be uselessly cluttered up by adding all those conditions.

In my head scripts are good because they're fast, general, and powerful.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: Re: Discussing scripting vs sexps in missions
SCRIPT ALL THE THINGS!

(Only event in .fs2 is script-eval "missiongo"
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Axem

  • 211
Re: Re: Discussing scripting vs sexps in missions
It really depends what you're trying to do. You could make (with a lot of effort) a procedural message system where your wingman will automatically report important ships dying, or how they just slagged Aries 4 with their Slammers.

The key I find when wondering if I should sexp or script it is ask, "Will it save me time in the future?".

mjn: That's basically what my Visual Novel missions look like in JAD now. :p

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Re: Discussing scripting vs sexps in missions
I'm thinking about **** like "send a message from the most angry character if the mission time is between 30 and 90 seconds and ship B has been destroyed using gun X and then this ability is triggered." I know how to do that trivially with event logic. I feel like a script would be uselessly cluttered up by adding all those conditions.
So do it in event logic; scripts can add functions that return numbers and then script-eval-num lets you insert them into your event conditionals; it's just a matter of making sure that you have good ways of communicating your state back to the SEXP engine.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline Axem

  • 211
Re: Discussing scripting vs sexps in missions
I split the topic since this is gone off into another direction!

 
Re: Re: Discussing scripting vs sexps in missions
I'm thinking about **** like "send a message from the most angry character if the mission time is between 30 and 90 seconds and ship B has been destroyed using gun X and then this ability is triggered." I know how to do that trivially with event logic. I feel like a script would be uselessly cluttered up by adding all those conditions.
You need a "rage" counter of some sort in both the sexp and scripted version, which could be an argument construction using sexps or a loop through some fixed lists in scripting. 30 - 90 seconds is a simple condition in both versions and the ship B destroyed by gun x seems also pretty similar (again some argument list stuff for sexps, an on hit check for gun x and a follow up check if target B is now dead for scripting). I feel like the effort is not that much different...
So most cases boil down to:
The key I find when wondering if I should sexp or script it is ask, "Will it save me time in the future?".
Or: Is it easier for me to sexp it or script it? And do I need a generic version for other missions where simple sexp copy/paste won't be possible?

Also for anything based on generic scripts sexp-variables can be easily used to transport information between sexps and scripts. They can trigger or modify scripts without actual script-eval calls or provide data that is needed in a sexp event.
Here goes scripting and copy paste coding
Freespace RTS Mod
Checkpoint/Shipsaveload script