Author Topic: SEXP Argument changes via mod.tbl  (Read 4333 times)

0 Members and 1 Guest are viewing this topic.

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
SEXP Argument changes via mod.tbl
Here's one that probably will only affect the more advanced FREDders amongst you. The big problem with the way the argument SEXPs work for many FREDders is that the inner and outer loops are the wrong way round. The game will execute each action SEXP for all the valid arguments first and then move on to the next one. Most users are expecting the exact opposite, All of the action SEXPs for each argument and then move on to the next argument.

This build uses a argument in the newly added mod.tbl to switch the loops around. Since this problem only affects the more advanced FREDders usually, here's a little test to show exactly what I mean.

When-argument
-any-of
--Ship 1
--Ship 2
--Ship 3
-true
-modify-variable
--StringVariableName
--<Argument>
-self-destruct
--StringVariableName

Which ship blows up?

Spoiler:
Normal builds will blow up Ship 3 because they loop through the modify variable SEXP 3 times and then move on. This build will modify the variable to Ship 1, blow it up and then modify the variable to Ship 2 and then Ship 3.


http://fs2downloads.com/Misc-Downloads/Builds/Mod_Table_SEXP_Build.7z

EDIT : At the moment, mod.tbl only contains a couple of features but the basic idea is to make it the place for all those settings you set once for a mod and then never want to change again.
« Last Edit: January 11, 2012, 08:06:16 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Anims: 420, Cutscenes: 10, Mainhalls: 7, Logos: 52
    • Steam
    • Twitter
    • Mix-Hai Productions
Re: SEXP Argument changes via mod.tbl
Seems to work as expected.
Cutscene Upgrade Project - Mainhall Remakes - MixaelANITools - Between the Ashes - MjnMixael's Render Boutique - Mix-Hai Productions
Youtube Channel - P3D Model Box - Photobucket Albums - Model Releases - Downloads
Between the Ashes is looking for committed testers, PM me for details.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: SEXP Argument changes via mod.tbl
Oh well done.  This will come in handy.

...On second thought, this would be better as an additional sexp.  There are rare instances where one needs the current behavior, and Scroll contains a few of them.  Yet the mod.tbl behavior is preferred in most cases.  Since mod.tbl would affect all sexps in the game without exceptions, could you make a new sexp so that we could have one or the other as needs demand?

Not sure what the new sexp should be called.  For-argument might be a good candidate.

 

Offline Fury

  • The Curmudgeon
  • 213
Re: SEXP Argument changes via mod.tbl
EDIT : At the moment, mod.tbl only contains a couple of features but the basic idea is to make it the place for all those settings you set once for a mod and then never want to change again.
Not in trunk yet apparently? Regardless, this has to be the best thing since porn.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP Argument changes via mod.tbl
Oh well done.  This will come in handy.

...On second thought, this would be better as an additional sexp.  There are rare instances where one needs the current behavior, and Scroll contains a few of them.  Yet the mod.tbl behavior is preferred in most cases.  Since mod.tbl would affect all sexps in the game without exceptions, could you make a new sexp so that we could have one or the other as needs demand?

Not sure what the new sexp should be called.  For-argument might be a good candidate.

No, this really shouldn't be a SEXP. If you turn on the feature every single SEXP in the mission will suddenly start being processed the other way. It would be horribly confusing.

Basically this was designed the exactly the way it was so that a FREDder could set it once for a mod and then forget about it forever. Since it's just there to fix a design flaw but maintain backwards compatibility there's no reason it should be swapped around.

But what the **** are you doing that actually needs the old way round to work?
« Last Edit: January 29, 2012, 10:02:07 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Tomo

  • 28
Re: SEXP Argument changes via mod.tbl
I think Goober means it ought to be a new SEXP that works the other way around, so existing missions that rely on the current functionality are unaffected.

I think "for-each-argument" is a better name than "for-argument", but either is good.

 

Offline The E

  • He's Ebeneezer Goode
  • Global Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: SEXP Argument changes via mod.tbl
Existing missions are unaffected as long as this mod.tbl flag is not set. Methinks you have not understood the problem.

If you are setting this flag, it is assumed that you do so while being aware of the consequences.
Let there be light
Let there be moon
Let there be stars and let there be you
Let there be monsters and let there be pain
Let us begin to feel again
--Devin Townsend, Genesis

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: SEXP Argument changes via mod.tbl
I think Goober meant that he could use both functionalities in Scrolls, and hence that the mod.tbl setup is inconvenient.

Which brings us back to square 1 : what are you doing in Scrolls that requires the old way around.
People are stupid, therefore anything popular is at best suspicious.

Homeworld: Blue Planet     -     Help us help you     -     FSO Installer     -     BP extras portal     -     My legacy

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grĂ¢ce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Re: SEXP Argument changes via mod.tbl
If you are setting this flag, it is assumed that you do so while being aware of the consequences.

Haha, no. Someone will want to play X mission with Y mods, they'll drop the X.fs2 file in the Y mod folder, and they'll create all kinds of havoc in the support board.

There should be two separate sexps: one that works the old way, and one that works the new way.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP Argument changes via mod.tbl
If you want two separate SEXPs I suggest you look at the code first and then refactor the entire SEXP argument code in order to allow it. Cause coding this at the SEXP level is not a trivial problem.

But this is not "an additional SEXP" This is making new versions of every single conditional SEXP from now on. Furthermore if you use one version of the conditional inside the other version, I have no idea what would happen. Probably a crash of some sort. The whole point of the mod.tbl entry is to avoid that kind of nonsense.

The FREDder decides at the start which version of the SEXPs he wants to use. It's basically a backwards compatibility thing to make sure the change doesn't break existing missions. Unreleased mods can go through and fix their missions to work correctly. New mods should always be setting that flag. Given that I still don't know why Scroll needs the old version it's hard to see why I should change things.

Haha, no. Someone will want to play X mission with Y mods, they'll drop the X.fs2 file in the Y mod folder, and they'll create all kinds of havoc in the support board.

How is that any different to most situations where you drop a mission into a mod it's not supposed to be part of. If you're doing that, you're an idiot or you're clueless enough about how to install a mission that you're going to be a support nightmare anyway.
« Last Edit: January 30, 2012, 08:24:22 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: SEXP Argument changes via mod.tbl
I don't want to trivialize this sexp because I definitely agree it requires careful work to recode.  I'd like to take a look at the patch though.  My first impression is that you could find a way to toggle between breadth-first and depth-first iteration, but I've been bitten by hidden sexp complexities before.

In most cases, I agree that you'd just set one flag in mod.tbl and then forget about it entirely.  But in the rare case where you'd need at least one of each type of iteration, you'd be stuck because mod.tbl affects every sexp in the campaign.  Either they'd all iterate one way or they'd all iterate the other way.

Now I could have sworn that Scroll depended on the old way of iteration but I just searched the missions for *-argument sexps and I don't see a case where it's required.  So this may not actually be a problem.

Here's one consideration I'm interested in though.  What do you do for sexp trees that mix nodes that contain <argument> and nodes that don't?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP Argument changes via mod.tbl
Here's one consideration I'm interested in though.  What do you do for sexp trees that mix nodes that contain <argument> and nodes that don't?

I'm not sure what the problem would be there, you can already do that with the current implimentation.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: SEXP Argument changes via mod.tbl
Yeah, but now the iteration order is different.  Let me use an example sexp:

Code: [Select]
$Formula: ( when-argument
   ( any-of "SFr Molech" "SFr Ba'al" )
   ( <
      ( distance "Alpha 1" "<argument>" )
      1300
   )
   ( ship-visible "<argument>" )
   ( change-iff "Hostile" "<argument>" )
   ( turret-lock-all "<argument>" )
   ( send-message-list
      "Alpha 3"
      "High"
      "contact confirmed"
      100
   )
   ( ship-invulnerable "Narandum" )
   ( set-object-facing-object
      "Narandum"
      "Departure path:1"
   )
)
+Name: Freighter reveal
+Repeat Count: 1
+Interval: 1

Hypothetically, if Alpha 1 were to be within range of both ships at precisely the same time, then ship-visible would execute twice, followed by change-iff twice, turret-lock-all twice, send-message-list once, and ship-invulnerable once.

Now suppose we use mod.tbl.  Would it be ship-visible, change-iff, turret-lock-all, send-message-list, ship-invulnerable, ship-visible, change-iff, turret-lock-all?  Or would the send-message-list and ship-invulnerable execute twice?  Would it be any different if ship-invulnerable came immediately after ship-visible?

  

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP Argument changes via mod.tbl
Oh, I see the issue but I'd already considered it.

 
Hypothetically, if Alpha 1 were to be within range of both ships at precisely the same time, then ship-visible would execute twice, followed by change-iff twice, turret-lock-all twice, send-message-list once, and ship-invulnerable once.

Now you'd get then ship-visible, followed by change-iff, turret-lock-all, send-message-list, and ship-invulnerable. Then ship-visible, followed by change-iff, turret-lock-all and ship-invulnerable with the other ship as the argument. You'll only get the message sent once since that SEXP contains no use of the <argument> option. If you need the message twice you should use do-valid-argument-times same as you would without the mod.tbl flag since that's what it was created for.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: SEXP Argument changes via mod.tbl
I was expecting that I'd only get send-message once, and I hoped that would still be the case.  But I was also wondering at what point send-message would be invoked.  If it's only on the first iteration through the list of arguments then that answers my question.

(Also, ship-invulnerable doesn't contain <argument> either, so I'm guessing you just misread the sexp.)

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP Argument changes via mod.tbl
Yeah, I wasn't looking carefully and assumed that was why you asked about swapping those two round. :)

To be honest the main time you're really going to see much of a difference is in cases like the example at the top of the page. Anything to do with variables is going to have a different result. But that's kinda the point of the change. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: SEXP Argument changes via mod.tbl
Cool. :)

I'm going to tentatively assume this won't be a problem for Scroll, and if any problems come up in the future I'll just find a way to work around them.  I'd like to take a look at your patch before you commit it though.