Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: ReeNoiP on May 09, 2011, 10:52:47 am

Title: Using variables in messages and debriefings
Post by: ReeNoiP on May 09, 2011, 10:52:47 am
Can you do this?

A simple version of what I'm trying to do is this:
I have a variable score (default 0)

Player destroys a ship->message "Kill score +1"->message "Score is now 1"
Player destroys another ship->message "Kill score +1"->message "Score is now 2"
Player destroys 2 ships within a certain time->message "double kill score +5"->Message "score is now 5"

Say I have a number of ships in a wing: Ship1, ship2...

How would I set up a sexp which repeatedly checks each time a ship is destroyed and sends the correct message? And tjecks the two kill thing.

My guess was something like this:

Code: [Select]
Two variables: score(0) combo(0)
event1
when-argument
any-of
ship1,ship2....
is destroyed
modify variable score=score+1
modify variable combo=combo+1
training message "Kill! score+1)
Training message "Score is now {score}<-the variable

event2
when
is-event-true-delay
"some time"
event1
modify variable combo=0

event 3
when
combo>2
modify variable score=score+3
training message "Double kill score+5)

This way I would only need a few messages to make it work with any number of ships.
Title: Re: Using variables in messages and debriefings
Post by: General Battuta on May 09, 2011, 11:06:39 am
You can use a var in a message by typing $[yourvarname] in the message text (without the brackets).
Title: Re: Using variables in messages and debriefings
Post by: ReeNoiP on May 09, 2011, 11:19:20 am
You can use a var in a message by typing $[yourvarname] in the message text (without the brackets).

Excellent.
Title: Re: Using variables in messages and debriefings
Post by: General Battuta on May 09, 2011, 11:27:42 am
Unfortunately there is no way to reference vars in a debriefing without creating additional DB branches.
Title: Re: Using variables in messages and debriefings
Post by: karajorma on May 09, 2011, 11:44:36 pm
Eh?
Title: Re: Using variables in messages and debriefings
Post by: General Battuta on May 09, 2011, 11:46:10 pm
Eh?

Debriefs are totally static, yes? No colored text, no $varname. Correct?
Title: Re: Using variables in messages and debriefings
Post by: TopAce on May 10, 2011, 03:59:54 am
You can display variables in a debriefing.

(http://i1082.photobucket.com/albums/j367/TopAceHLP/Varindebrief.jpg)
Title: Re: Using variables in messages and debriefings
Post by: Colonol Dekker on May 10, 2011, 04:50:47 am
That's what i thought.  :nervous: Fred academy at next HLP London right? :yes:
Title: Re: Using variables in messages and debriefings
Post by: General Battuta on May 10, 2011, 07:24:33 am
Awesome.
Title: Re: Using variables in messages and debriefings
Post by: Goober5000 on May 17, 2011, 02:20:39 am
Last I recall, colored text is still not available in debriefings though.