Author Topic: Conditionals within arguments (Thinking caps on)  (Read 5308 times)

0 Members and 1 Guest are viewing this topic.

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Conditionals within arguments (Thinking caps on)
A discussion about Mantis 1878 has shown me that a rethink of how conditionals within other conditionals are handled is needed. This is likely to get technical so if you don't already know what when-argument is or how it works, you're going to need to do some reading up first.

The problem occurs when you have a conditional that can have more than one valid argument at a time  (i.e any-of, every-of, number-of but not in-sequence, random-of or random-multiple-of) and affects the action SEXPs that are evaluated.

First let's start with an example of how things currently work

When-argument
-every-of 
--Ship 1
--Ship 2
--Ship 3
-trigger
-Send-message  <---------------Evaluated only once. Only one message is sent
--#Command
--etc
-self destruct  <------------------Evaluated once for every ship on the argument list. Three ships are destroyed.
--<argument>

The way that the game works out what to do is it checks if the SEXP (and any of it's children) have <argument> in them anywhere. This works perfectly well about 95% of the time. The problem really started once I fixed it so that you could use when inside when-argument and visa versa. That makes it possible to do this

When-argument
-every-of 
--Ship 1
--Ship 2
--Ship 3
-trigger
-when   <-----------------So how many times should this be evaluated?
--2nd trigger
--do-something

Now we have a problem. How many times should that when be evaulated? Once? Once for each argument? Once for each argument but only if the when includes <argument> somewhere in it?

The last one of these is what does actually happen and I tend to feel it is the best solution. But it does leave a problem. What happens if you want something to happen mutiple times. What if you wanted 3 messages sent in the first example? More importantly, what if you are using nested arguments. Take a look at this.

When-argument
-every-of 
--Ship 1
--Ship 2
--Ship 3
-trigger
-when-argument <---------------- Definitely should only trigger once (Currently bugged but will be fixed to do so)
--random-of
---Ship 4
---Ship 5
---Ship 6
--trigger 2
--send-message
---<argument>
---high
---message

Problem is, what if you had a different inner when-argument that you did want to evaluate multiple times? You can hack it by having a pointless SEXP calling <argument> just to make it happen multiple times but that's ugly and difficult to understand when you later look at the mission.

Basically the only solution I can currently see to this is to have a Do-for-Every-Valid-Argument SEXP. This would be inserted into the tree like this

When-argument
-every-of 
--Ship 1
--Ship 2
--Ship 3
-trigger
-do-for-every-valid-argumnent  <--------------------  Makes everything below it get evaluated 3 times.
--when-argument
---random-of
----Ship 4
----Ship 5
----Ship 6
---trigger 2
---send-message
----<argument>
----high
---message

Problem with adding that SEXP is it's going to need heavy testing. So I want to see if anyone else had a sensible idea.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Conditionals within arguments (Thinking caps on)
What I can't quite grasp is why if you have the following:

When-argument
-any-of
--Ship 1
--Ship 2
--Ship 3
-has-arrived-delay
--0
--<argument>
-Send-message
--#Command
--etc
-self destruct 
--<argument>
-invalidate-argument
--<argument>

The message will be sent 3 times if the ships appear at 3 different times but only once if they all appear in the same second. 

I see that as doing this when the arguments occur at different times:

when
--has-arrived-delay
---0
---ship 1
--send-message

when
--has-arrived-delay
---0
---ship 2
--send-message

when
--has-arrived-delay
---0
---ship 3
--send-message


but it seems it actually does this when the 3 arguments happen in the same second:

when
--or
---has-arrived-delay
---0
---ship 1
---has-arrived-delay
---0
---ship 2
---has-arrived-delay
---0
---ship 3
--send-message

As far as this one:

Quote
When-argument
-every-of
--Ship 1
--Ship 2
--Ship 3
-trigger
-when   <-----------------So how many times should this be evaluated?
--2nd trigger
--do-something

I believe that when should be processed once for each time trigger can be true.  I've never used every-of but it seems like it only becomes true once all the items evaluate true so in you example the when would fire once.  In the case of any-of it should fire 3 times (if all 3 ships meet the trigger condition).    Again I haven't used number-of yet either and never even read the description of it so no idea how that should evaluate. 

Quote
When-argument
-every-of
--Ship 1
--Ship 2
--Ship 3
-trigger
-when-argument <---------------- Definitely should only trigger once (Currently bugged but will be fixed to do so)
--random-of
---Ship 4
---Ship 5
---Ship 6
--trigger 2
--send-message
---<argument>
---high
---message

Again I would agree the nested when-argument should only fire once for every-of but it should fire 3 times for in-sequence, random-multi-of and any-of.

Now the thing that's not really discussed here but what happens if you don't invalidate the arguments?

When-argument
-random-multi-of
--Ship 1
--Ship 2
--Ship 3
-true
-modify-variable
--arg1
--<argument>
-when-argument <---------------- Definitely should only trigger once (Currently bugged but will be fixed to do so)
--random-multi-of
---Ship 4
---Ship 5
---Ship 6
--true
--arg2
--<argument>
--send-message
---#command
---high
---(text $arg1 $arg2)

I would assume you would get a loop of something like:

Ship 2  Ship 4
Ship 2  Ship 6
Ship 2  Ship 4
Ship 3  Ship 5
Ship 3  Ship 5
Ship 3  Ship 6
Ship 2  Ship 4
Ship 2  Ship 5
Ship 2  Ship 5
Ship 2  Ship 6
Ship 2  Ship 4
Ship 2  Ship 3
Ship 1  Ship 5
Ship 1  Ship 5
Ship 1  Ship 6

All my cases assume repeating events with invalidate-argument except the last one. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Conditionals within arguments (Thinking caps on)
Hate to double post but something just hit me that I feel might be a solution.

I've been going under the assumption that invalidate-argument <argument> is only removing one argument.  What if I did this:

when-argument
--any-of
---ship 1
---ship 2
---ship 3
--has-arrived-delay
---0
---<argument>
--modify-variable
---arg
---<argument>
--send-message
---<text $arg has arrived>
--invalidate-argument
---arg ------------------------------ if this is even legal

Would that have the desired effect I am looking for?

I know it doesn't solve the overall issue of how things should work but it's the entire reason this came up. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Angelus

  • 210
  • The Angriest Angel
Re: Conditionals within arguments (Thinking caps on)
Hate to double post but something just hit me that I feel might be a solution.

I've been going under the assumption that invalidate-argument <argument> is only removing one argument.  What if I did this:

when-argument
--any-of
---ship 1
---ship 2
---ship 3
--has-arrived-delay
---0
---<argument>
--modify-variable
---arg
---<argument>
--send-message
---<text $arg has arrived>
--invalidate-argument
---arg ------------------------------ if this is even legal

Would that have the desired effect I am looking for?

I know it doesn't solve the overall issue of how things should work but it's the entire reason this came up. 

Hm, i always thought invalidate argument removes all arguments from the list.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Conditionals within arguments (Thinking caps on)
Nope it's only invalidates the argument you supplied. Which is why you almost always see it as

invalidate-argument
-<argument>

There is actually no reason that you couldn't call it as

invalidate-argument
-other argument from the list

Hate to double post but something just hit me that I feel might be a solution.

I've been going under the assumption that invalidate-argument <argument> is only removing one argument. 

Yeah. That's an incorrect assumption. You were using

Invalidate-argument
<argument>

Which means it would be evaluated for all three ships not just one.

Quote
What if I did this:

when-argument
--any-of
---ship 1
---ship 2
---ship 3
--has-arrived-delay
---0
---<argument>
--modify-variable
---arg
---<argument>
--send-message
---<text $arg has arrived>
--invalidate-argument
---arg ------------------------------ if this is even legal

Would that have the desired effect I am looking for?

Should work with that event. Be warned that you may get a few unintended consequences though.

1) The messages will be

Ship 3 has arrived
Ship 2 has arrived
Ship 1 has arrived

rather than the other way round as you might have expected. This is because the modify-variable sexp will be executed three times and then the send-message SEXP will executed. So the variable will have the value of the last ship on the list.

2) Remember that it will take 3 frames before you invalidate all 3 ships. If you add something else using <argument> to the event it will trigger multiple times. For instance if you also added this

--send-message
---<text $arg has arrived>
--self-destruct
---<argument>

--invalidate-argument
---arg

and then looked at the log you would see Ship 3 self destructed once, Ship 2 self destructed twice and ship 1 self destructed three times. :)

A slightly better solution therefore is to cause the modify-variable bit to execute 3 times. This is exactly what the proposed do-for-every-valid-argument SEXP is supposed to do.  For the example you gave here you can do this.

--has-arrived-delay
---0
---<argument>
-when
--true
--modify-variable
---arg
---<argument>
--send-message
---<text $arg has arrived>


Since the when contains a <argument> it will now be executed 3 times. For the mantis report you made you can't do this as you weren't using argument.  You can fake the same effect though with this


--has-arrived-delay
---0
---<argument>
-when
-string-greater-than
-<argument>
-- a
--modify-variable (do the +3 thing here)


This is what I meant when I said you could hack it by having a pointless SEXP calling <argument>. You know that the <argument> is always going to have a value higher than the letter a so it will always trigger the event three times. Like I also said though it's inelegant and also rather confusing. It's very easy to forget why you added that string comparison in there.


Okay. That's the second post dealt with. Now I'll go back and look at the first one. :D
« Last Edit: February 02, 2009, 03:19:33 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: Conditionals within arguments (Thinking caps on)
Problem with adding that SEXP is it's going to need heavy testing. So I want to see if anyone else had a sensible idea.
Unfortunately, your entire train of thought is based on a faulty premise. :)  The problems arise because the sexp system is being stretched farther than it had ever been designed or even intended to go.  When-argument is just something I came up with to use pseudo-variables in constrol structures.  I never intended it to be a loop construct (although it can be turned into a pretty useful loop) and I certainly never intended it to be nested. :p  If you wanted to nest multiple <argument> sexps, you'd probably be better off distinguishing them in some way: <argument a>, <argument b>, etc.

We are not going to be able to get full looping or control logic by hacking the sexp system to death.  The only way to do that would be to replace the current sexp system with a version of LISP. :D

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Conditionals within arguments (Thinking caps on)
Why am I suddenly thinking of Scotty saying "The engines can nay take it Captain!" :lol:

Actually it's nesting quite well now. As for distinguishing the arguments somehow, I simply said that an <argument> can't cross into the level of a second when-argument. If you need more than that you can pass the arguments down and up through nesting levels via a variable. I've tested the method and it works pretty well.

Having a method of distinguishing variables is much harder than simply nesting them and giving them an explicit scope. 

As for the Do-for-Every-Valid-Argument SEXP, I'm pretty sure that was asked for well before I bothered with nesting. It's actually a rather major flaw of the current implementation.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Conditionals within arguments (Thinking caps on)
Again I haven't used number-of yet either and never even read the description of it so no idea how that should evaluate.

Number-of will trigger when a certain number of arguments on the list meet the conditions of the trigger so

when-argument
-number-of
--2
--list of ships
-has-arrived
--<argument>

will trigger when two or more ships have arrived (and will evaluate for all the ships that meet the condition. Not just the first two.


Quote
As far as this one:

Quote
When-argument
-every-of
--Ship 1
--Ship 2
--Ship 3
-trigger
-when   <-----------------So how many times should this be evaluated?
--2nd trigger
--do-something

I believe that when should be processed once for each time trigger can be true.  In the case of any-of it should fire 3 times (if all 3 ships meet the trigger condition). 


There are a couple of reasons I'd prefer to leave it the way it is now. First, it allows the rules to be simpler. If you open that branch and it has a <argument> in it anywhere then it triggers once for each argument. If it doesn't it triggers once. IF I change the rules then it becomes if you open a branch it triggers once for every valid argument if that is in the branch OR if the branch has a when in it somewhere OR once if it hasn't got either.
 Second, it means I don't have to do anything. :p
 Third, there may be occasions when you want to have a when SEXP only occur once. And it is harder to hack it back to triggering only once than it is to hack it to triggering multiple times.

Quote
Now the thing that's not really discussed here but what happens if you don't invalidate the arguments?

When-argument
-random-multi-of
--Ship 1
--Ship 2
--Ship 3
-true
-modify-variable
--arg1
--<argument>
-when-argument <---------------- Definitely should only trigger once (Currently bugged but will be fixed to do so)
--random-multi-of
---Ship 4
---Ship 5
---Ship 6
--true
--arg2
--<argument>
--send-message
---#command
---high
---(text $arg1 $arg2)

I would assume you would get a loop of something like:

Ship 2  Ship 4
Ship 2  Ship 6
Ship 2  Ship 4
Ship 3  Ship 5
Ship 3  Ship 5
Ship 3  Ship 6
Ship 2  Ship 4
Ship 2  Ship 5
Ship 2  Ship 5
Ship 2  Ship 6
Ship 2  Ship 4
Ship 2  Ship 3
Ship 1  Ship 5
Ship 1  Ship 5
Ship 1  Ship 6

All my cases assume repeating events with invalidate-argument except the last one. 

That's what you would have got before I fixed the bug this afternoon or if the Do-for-Every-Valid-Argument SEXP existed and was inserted before the 2nd when argument. As it stands now both columns will change every time the event triggers.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Conditionals within arguments (Thinking caps on)
Well I really don't mind about the order it's processed in I just want it to process 3 times.  The actual event doesn't even (or won't once the test message is removed) send messages so the player should see nothing and I should get the correct values added to my variables.  So my events that started this whole
discussion have a possible solution at least. 


As for the nesting that does work quite well and I've been using it quite a bit.  Haven't even managed to break it once yet this week.  :pimp:  The biggest limitation with the whole thing now is the limit on the size if a single event.  (4096 characters in case your wondering)

Maybe we should discuss how each different type of when-argument/every-time-argument is currently being processed especially in a repeating event.  There do seem to be some key differences.   

Another idea would be one-of (or one-of-any) that does the same thing as any-of but only with one argument at a time.  Probably similar in concept (if not exact) to your Do-for-Every-Valid-Argument. 

We posted at the same time so I didn't read your reply yet.
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Conditionals within arguments (Thinking caps on)
That's what you would have got before I fixed the bug this afternoon or if the Do-for-Every-Valid-Argument SEXP existed and was inserted before the 2nd when argument. As it stands now both columns will change every time the event triggers.

See now to me that reads more like

when
--true
--when-argument
---ship 1
---ship 2
---ship 3
--true
--modify-variable
---arg1
---<argument>
--when-argument
---ship 4
---ship 5
---ship 6
--true
--modify-variable
---arg2
---<argument>
--send-message

then a when-argument nested under a when-argument.
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Conditionals within arguments (Thinking caps on)
Yeah. That's a by-product of having to follow the rule that a nested conditional only triggers more than once if it contains an <argument>.

Like I said though you can make it trigger more than once using a when string-greater-than SEXP hack. If if I fixed it the other way round though the hack to make it only execute once would be  much larger and more error prone.

The only way to remove the barrier would be to start naming conditionals so you could tell them apart like Goober mentioned. But at that point Scotty would get really cross. :p

Quote
Maybe we should discuss how each different type of when-argument/every-time-argument is currently being processed especially in a repeating event.  There do seem to be some key differences.

What's the problem?

Quote
Another idea would be one-of (or one-of-any) that does the same thing as any-of but only with one argument at a time.  Probably similar in concept (if not exact) to your Do-for-Every-Valid-Argument.

While it sounds like a nice idea due to the way the when-argument system works that's likely to be much, much harder to implement.
« Last Edit: February 02, 2009, 04:38:42 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Conditionals within arguments (Thinking caps on)
First the invalidate-argument arg workaround worked just fine.

There is nothing wrong with them there just seems to be differences in the way they work. 

For example with wing beta:

when-argument
--in-sequence
---beta 1
---beta 2
---beta 3

seems to process differently then

when-argument
--any-of
---beta 1
---beta 2
---beta 3

when wing beta arrives.  Just a little clarification on how each one processes might be useful. 

If they do process differently then wouldn't having the one-of do the individual processing of in-sequence but out of sequence (if that makes sense) a possibility?  Or is that what you are talking about requiring major code changes to do?


No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Conditionals within arguments (Thinking caps on)
There is nothing wrong with them there just seems to be differences in the way they work. 

For example with wing beta:

when-argument
--in-sequence
---beta 1
---beta 2
---beta 3

seems to process differently then

when-argument
--any-of
---beta 1
---beta 2
---beta 3

when wing beta arrives.  Just a little clarification on how each one processes might be useful. 

Yes. I would expect those two to act slightly differently. In-sequence, random-of and random-multiple-of can only be true for one argument on the list at a time. Only one item can be evaluated every time the event triggers. So if I had this.

when-argument
-in-sequence
--Ship 1
--Ship 2
--Ship 3
-true
-self-destruct
--<argument>
-invalidate-argument
--<argument>

The event would need to trigger 3 times before all three ships would be destroyed. You can easily see why this is true for random-of. If it wasn't you'd ask it to pick a random ship and they'd all blow up! :D

Any-of, every-of and number-of work in a different way. For them, multiple arguments can be true at the same time. The code goes through the list, tests the number that are true based on the trigger and sticks the names of all the ones that are true onto a new list.  Then it looks at the action part of the SEXP and processes each SEXP in order making it occur once for each argument if need be.

Internally all the argument SEXPs work the same. It just that with in-sequence and the random ones the list only ever has one item so they appear to work differently. :)

Quote
If they do process differently then wouldn't having the one-of do the individual processing of in-sequence but out of sequence (if that makes sense) a possibility?  Or is that what you are talking about requiring major code changes to do?

It's not actually that major a change. But it would involve changing the way the loops work and that could very easily add bugs. I might as well think my way through the code publicly as that might help you understand what's going on if you look at the code itself.

If you have this SEXP

When-argument  <--------------1)
-any-of               
--Ship 1
--Ship 2
--Ship 3
-has-arrived-delay
--0
-self destruct  <----------------2)
--<argument>
-Send-message  <-------------3)
--#Command
-invalidate-argument <-------4)
--<argument>

What happens is this. Enter eval_when() at point 1. Call eval_sexp() to check if the trigger is met and the event should fire. If it is we then loop through the action SEXPs. do_action_for_each_special_argument() is called for the self-destruct SEXP to blow up all 3 ships. Eval_sexp() is then called to send the single message, then finally do_action_for_each_special_argument() is called again to invalidate all three arguments.

Now to make the one-of-any SEXP work I'd have to rewrite the order that happens in. If you look at the code that means rewriting this loop

Code: [Select]
// loop through every action
while (actions != -1)


If I did that I could make all the conditionals work that way, thereby making the one-of-any SEXP unnecessary, However it would screw over any SEXP you were counting on to work the old way round. Modify-variable would be the biggest victim of this. The way the old loop worked you could modify a counter by +1 three times and then output it in a message. Changing the way things work would result in you modifying the variable once, outputting the message and then looping twice more to modify it again.

It's fixing that behaviour so that it remains consistent with what currently happens that would most likely cause bugs. It can be done but it makes things a lot more complicated because it means you have to make something happen the final time through a loop and not the first. And it still wouldn't solve the original problem. :D In fact it might actually make it harder to solve.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Conditionals within arguments (Thinking caps on)
Well one thing we definitely don't want to do is change it so that the existing uses are screwed up.  That's why I suggested a new operator that had the feature to process one at a time.

So in-sequence random-of and random-multi-of are the three that process one list item at a time.  The other process the whole list each time.  Any chance of adding that tidbit to the sexp description?  That or a good Wiki article about this when it's all figured out.  I'd do it but I'm terrible at explaining things.   

This is slightly off topic but something else I keep trying to do before I realize it's probably not possible.  An event something like this:

Say you have the same basic

when-argument
--any-of (in-sequence whatever)
---ship 1
---ship 2
---ship 3
--is-destroyed-delay
---<argument>

Is there any way to use that in an or statement:

Like

when
--or
---is-event-true
----win
--the above when argument


That's probably not the best example and for the life of me I can't think of a really good one right now even though I've run into it half a dozen times in the last week.  Best I can think of right now would be:

when
-- =
---number-of
----ship 1
----ship 2
----ship 3
---has-arrive-delay
----<argument>
---number-of
----ship 1
----ship 2
----ship 3
---is-destroyed-delay
----<argument>


Yes I know that is totally invalid but I keep thinking of things like that.  I never even thought of that one though until yesterday when you posted what number of did. 


No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Conditionals within arguments (Thinking caps on)
Well one thing we definitely don't want to do is change it so that the existing uses are screwed up.  That's why I suggested a new operator that had the feature to process one at a time.

If I did change it the result would be so subtle I doubt anyone would notice. In fact the main reason I'd want to changed things would be in preparation for the proposed Do-for-Every-Valid-Argument SEXP. It's only with this in place that you'd ever notice any difference.

Quote
So in-sequence random-of and random-multi-of are the three that process one list item at a time.  The other process the whole list each time.  Any chance of adding that tidbit to the sexp description?  That or a good Wiki article about this when it's all figured out.  I'd do it but I'm terrible at explaining things.

I don't mind writing one if I'm free. The problem is finding the time.

Quote
when
-- =
---number-of
----ship 1
----ship 2
----ship 3
---has-arrive-delay
----<argument>
---number-of
----ship 1
----ship 2
----ship 3
---is-destroyed-delay
----<argument>


Yes I know that is totally invalid but I keep thinking of things like that.  I never even thought of that one though until yesterday when you posted what number of did. 

Yeah, that's not possible. Conditionals don't return a value like that. Number-of does know how many wings actually arrived but there is no way to easily get at that number.

The fact that I've seen a few people struggle with this problem makes me thing I should just add get-percentage-ships-arrived/destroyed/departed SEXPs. Then all you'd need to do would be to do this

- =
--get-percentage-ships-arrived
---ship list
--get-percentage-ships-destroyed
---same ship list
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Conditionals within arguments (Thinking caps on)
Or just call it percent-ships-arrived.  Already have percent-ships-destroyed and percent-ships departed to compare it to. 

Would work for most people.  Of course you have the crazy ones like me that have variable ships arriving and then toss in random stuff on top of it.   :pimp:

No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Conditionals within arguments (Thinking caps on)
Or just call it percent-ships-arrived.  Already have percent-ships-destroyed and percent-ships departed to compare it to. 


Good point. But I suppose if I'm adding one for arrived ships I might plug the gaps in the line up anyway.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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