Author Topic: next/incremental arguments?  (Read 4209 times)

0 Members and 2 Guests are viewing this topic.

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Steam
next/incremental arguments?
Oh great great fred wizzards, is there a way to use an <argument> from a list of arguments that's +1 from the original triggering <argument>?

eg:

-everytime-argument
--any-of
----<arg1>
----<arg2>
----<arg3>
--is-destroyed-delay
----0
----<arg>
--send-message
----<arg>+1
----High
----Stop Blowing up!


of course, intended behaviour is: if arg1 dies arg2 will curse him to hell and so forth.
el hombre vicio...

 

Offline Axem

  • 211
Re: next/incremental arguments?
Yeah, you could use a nested when argument with in-sequence that's sort of offset by 1 and save it to a variable so you can use it where you need to.

(Also really watch it with everytime sexps, its best to stick with when arguments! Even if you have to tack on a large repeat count)

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Steam
Re: next/incremental arguments?
Nice, gotta test it out. Thanks Axem.
el hombre vicio...

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: next/incremental arguments?
You could also index into a variable array using both a number and the number + 1.  But that would be trickier to pull off than in-sequence, if in-sequence works.

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Steam
Re: next/incremental arguments?
I tried using variable-array sexp, but got nowhere near to understand how to implement it from the description.
If I'm not mistaken, I'm supposed to "create" a new variable array with variable-array-set and retrieve the value with variable-array-get where I need it right?

edit: I cannot even find where is variable-array-get supposed to be usable, it's always grayed out on fred :S
« Last Edit: September 22, 2013, 06:38:56 pm by Rodo »
el hombre vicio...

  

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: next/incremental arguments?
Create a bunch of variables, then look in the mission file.  The index that FRED assigns them will be the index by which they can be accessed in variable-array-get/set.  (Note that FRED will alphabetize them before saving the mission.)

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: next/incremental arguments?
I almost got this to work using string-get-substring and string-concatenate, but the method falls down due to the lack of a "String-to-int" sexp to complement the "int-to-string" one we already have - there's no way to increment the number once you get it. :(

EDIT - actually, depending on how many ships you have, it may prove practical to do a buttload of nested if-then-else events.

When
 - Is-event-true
 - - - Your when-argument sexp
 - - - If-then-else
 - - - - is-destroyed-delay
 - - - - - Ship 1
 - - - - send-message
 - - - - - Ship 2
 - - - - If-then-else
 - - - - - is-destroyed-delay
 - - - - - - Ship 2
 - - - - - send-message
 - - - - - - Ship 3
 - - - - - If-then-else
 - - - - - - is-destroyed-delay
 - - - - - - - Ship 3
 - - - - - - send-message
 - - - - - - - Ship 4
etc. etc.
« Last Edit: September 22, 2013, 10:15:04 pm by Black Wolf »
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Steam
Re: next/incremental arguments?
Well, to be honest the only reason why I was trying to use arguments was to get a tidier one-sexp version.
What I need to do can be pulled off with just a bunch of sexps triggering in sequence, my only problem now is that I can only make that sequence trigger just once, the hole chain cannot be repeated because the sexps that trigger the different "stages" are already evaluated as true.
I'll be working on it during the week, when my brains are not completely melted down  :mad:
el hombre vicio...

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: next/incremental arguments?
I almost got this to work using string-get-substring and string-concatenate, but the method falls down due to the lack of a "String-to-int" sexp to complement the "int-to-string" one we already have

Of course there's a "String-to-int" sexp.  It's called string-to-int. :p  It's in the Status category, under Variables.

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: next/incremental arguments?
Huh, so there is. Well, having found that, I spent the last hour or so trying to make this work. I can make it loop if you shoot the ships in order, but out of order and I don't think it can be made to work.

If your mission is set up in such a way that the ships in question can only explode in order, then try this:

http://pastebin.com/uY0X4vNp

Otherwise, you'll need a much more complicated set of single use sexps that check the status of the other ships in the group each time one (specific to each sexp) dies. With nested if-then-else, this shouldn't be so hard.
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Axem

  • 211
Re: next/incremental arguments?
I think you guys are overthinking this a little bit...

http://pastebin.com/sjtRSM0L

One event, but only works if you destroy them in order (which I guess IS the requirement). Like I said, nested when-argument with an offset in-sequence. :p

I almost got another event working where it works out of order, but I need to leave for work soon... Maybe I'll give it a try afterwards.

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: next/incremental arguments?
I think you guys are overthinking this a little bit...

Well, no, not if you're allowed to destroy them out of order. :p

It turns out that one of my assumptions is wrong: there isn't a way to access a variable array string value. :sigh:  I'll have to make a version of variable-array-get that will do this.

Here is my suggestion, assuming the new version of variable-array-get:
Code: [Select]
( when-argument
   ( any-of
      0
      1
      2
      3
      [etc.]
   )
   ( and
      ( perform-actions
         ( true )
         ( variable-array-get
            "<argument>"
            @ShipNameA[""]
         )
         ( variable-get-by-index
            ( mod
               ( +
                  "<argument>"
                  1
               )
               [number of ships]
            )
            @ShipNameB[""]
         )
      )
      ( is-destroyed-delay 0 @ShipNameA[""] )
   )
   ( invalidate-argument "<argument>" )
   ( send-message
      @ShipNameB[""]
      "High"
      "OHNOES"
   )
)
+Name: Out of Order
+Repeat Count: -1
+Trigger Count: 999999
+Interval: 0

Of course, with this sexp you still need to ensure that the ship sending the message hasn't already died himself.

 

Offline Axem

  • 211
Re: next/incremental arguments?
Okay, so mine might be a little too rigid, but I still think there's an easier way than inputting every single ship in a bunch of variables or having 6 events keep track of everything.

For example going string-to-int on the ship name (which supposedly takes just the number from a string), adding one to that, int-to-string back, string concat to the known wing name and send your message from him.

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: next/incremental arguments?
And that would work, but what happens if the ships aren't in a wing?  Or if you want messages from more than one wing?

 

Offline Axem

  • 211
Re: next/incremental arguments?
Yeah I was thinking about that. I tried some other things and they don't work.

It's just so bothersome that something that looks like it should be so easy to do is so complicated to implement with sexps.

Even having some sort of modifier to an <argument> parameter where you could do something silly like

arg-offset
<argument>
1

gives you the argument after the current one would be so nice for this...

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Steam
Re: next/incremental arguments?
Would be better if we could just use operators on the arguments just like we do with variables, after all arguments are variables of some kind.
Still, I'm glad to see that me having problems getting around it wasn't because of my low IQ  :p
el hombre vicio...

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: next/incremental arguments?
For example going string-to-int on the ship name (which supposedly takes just the number from a string), adding one to that, int-to-string back, string concat to the known wing name and send your message from him.

That's exactly what my mission does...
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Axem

  • 211
Re: next/incremental arguments?
Almost, I wouldn't use the get-substring sexp though, using the string-to-int sexp gives me a number no matter where it is in the name.

Sorry if it looked like I was completely dismissing yours and Goober's attempts. :( I feel bad about my overthinking comment now.

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: next/incremental arguments?
Ah, didn't know that about string-to-int.

I was thinking though, one way to do it out of order (although still very variable intensive) would be to assign a variable to each ship with the same number as that ship. I.e. @Cargo-1 = 1, @cargo-2 = 2, etc. You then need a series of sexps that alter the vars arbitrarily highly when the corresponding ship is destroyed, I.e. When cargo 1 is destroyed, @cargo-1 would be modified to equal 100000.

You can then use the same sexp setup as my previous mission (modified with Axem's point about string-to-int), but alter the incrementing sexp to pick the lowest number (using the min sexp, obviously) from the series of variables and insert that in to be concatenated. If you wanted to give some degree of semi- randomness to the system, you could have the sexps then add a rand-multiple to the successful sexp, so that now @cargo-2, for example, might equal 5 or 6, excluding it from sending any more messages for a little while.
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Axem

  • 211
Re: next/incremental arguments?
Yeah, I was thinking about something like that too. I've been using a system of using the simulated hits of a ship as a special ship-unique variable, but you can't use that here because when a ship dies, you can't check the sim hits!

Could almost do something if you could bit-shift, but that's not an available sexp!