Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Titan on February 22, 2008, 09:20:27 am
-
Ok, y'know how variable-changing SEXPs say
1. Variable to be changed
2. value to be set
does that mean it will be set to that value, or it will be changed by that value?
-
It will be set to that value. If you want to change by that value use
Modify-Variable
-Variable-Name
-+ (Or -, multiply, divide or whatever)
--Variable-Name
--Value
For instance this is a classic +1 counter.
(http://homepage.ntlworld.com/karajorma/FAQ/FAQ-Images/Fred-Tips/BasicVariables6.jpg)
-
Had one question. Could it be possible in the next build to have number variables to be "transplanted" into string variables? So if I had a ship named "Counter" with an Alt Name "0", and when something happens (like you destroy an enemy cruiser), the number variable goes to 1, which is copied to a string variable, which becomes the Alt Name of the ship "Counter?" (so whenever you destroy one of the specified cruisers, the ship Counter's Alt Name goes up by one)
Or is this already possible and I'm just too stupid to see?
-
It's not possible but IP Andrews has been asking for something of the sort for a while now. The problem is that it requires a proper String return type which the SEXP system currently doesn't support.
I think Goober and myself are going to have to play rock, paper, scissors one of these days over who has to do it. :D
-
I have an idea about how to add proper data type support to sexps, but it would involve about as much work as when-argument did. Since I don't have that much time nowadays, I'm hesitant to jump in. :D
-
Thanks Mobius! :D
Had one question. Could it be possible in the next build to have number variables to be "transplanted" into string variables? So if I had a ship named "Counter" with an Alt Name "0", and when something happens (like you destroy an enemy cruiser), the number variable goes to 1, which is copied to a string variable, which becomes the Alt Name of the ship "Counter?" (so whenever you destroy one of the specified cruisers, the ship Counter's Alt Name goes up by one)
Or is this already possible and I'm just too stupid to see?
why would you wanna do that? or can you not even answer because it would destroy plot? :D
-
I have an idea about how to add proper data type support to sexps, but it would involve about as much work as when-argument did. Since I don't have that much time nowadays, I'm hesitant to jump in. :D
How long did it take you to do that out of interest?
-
I honestly don't remember. But it was a solid weekend of coding, plus a few miscellaneous bugfixes after the initial commit.
I just realized though, Snail's request doesn't require special handling of data types, strictly speaking. All it needs is a copy-number-to-string-variable sexp, and (if necessary) an extension of change-alt-name to work for string variables.
-
Yeah but that strikes me as something of a hack. If someone wants to stick a number in a change-alt-name SEXP they should be able to do it without the need for an intermediate SEXP variable. All it should require is a reverse of the atoi SEXP I added.
Actually now that I think of it, it should be possible to do this without any changes. Use a repeated when-argument event using the in-sequence option (I knew I'd find uses for it once I added it! :D ). Here's how I'd do it for 4 ships.
when-argument
-in-sequence
--Two
--Three
--Four
-percentage-ships-destroyed
--TargetPercentage[25]
--Names of all 4 freighters
-Modify-variable
--TargetPercentage[25]
-- +
----TargetPercentage[25]
---- 25
-change-alt-name
--ShipName
--<Argument>
-invalidate argument
Give that a repeat count of 3.
Every time a ship is destroyed the percentage needed to trigger the event is bumped by 25% and the alt-name is changed to the next one on the list. You could probably use numbers instead of the written version I've used, I've not checked.
-
Cool. :)
-
Problem with having the SCP is that makes me lazy. When all I had was retail I'd have spent 10-15 minutes thinking my way around a problem like that but now I simply say it's not possible yet and say that code changes are needed. :D
-
beats being a whiny noob like me...
-
I'm amazed at how basically everything I've thought up of is already possible... Good jawb. :yes: