Home   Help Search Login Register  

Author Topic: If...Then Help?  (Read 702 times)

0 Members and 1 Guest are viewing this topic.

schplurg

  • Guest
If...Then Help?
« on: 21 Jan 2003, 01:42:22 »
Shouldn't be too tuff a question. Been editing in OFP for a while, but haven't come across this problem yet.
I want this "If...Then" script (it works):

; eric
if (talkto==1) then {titletext ["\n\nNo thanks, maybe later.", "plain down"];ateric=false;play1 removeaction renteric;play1 removeaction renteric2;talkto=0;exit}

; svetlana
if (talkto==2) then {titletext ["\n\nGo to hell, bitch!", "plain down"];atsvetlana=false;play1 removeaction rentsvetlana;play1 removeaction rentsvetlana2;talkto=0;exit}


to look readable, like this (does not work):

; eric
if (talkto==1) then
{titletext ["\n\nNo thanks, maybe later.", "plain down"];
ateric=false;
play1 removeaction renteric;
play1 removeaction renteric2;
talkto=0;
exit}

; svetlana
if (talkto==2) then
{titletext ["\n\nGo to hell!", "plain down"];
atsvetlana=false;
play1 removeaction rentsvetlana;
play1 removeaction rentsvetlana2;
talkto=0;
exit}


So I can't figure out how to make these IF statements look more readable. Can someone help me out? I can program...I'm not great though. I've tried variations...adding more { }  or [ ] but I just get errors.

I've searched the forum, I've studied scripts and the ComReferences, now I turn to you! This isn't an emergency, but it would be a great help!

Thanks :)

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:If...Then Help?
« Reply #1 on: 21 Jan 2003, 21:27:17 »
Try these. YOu might have to have the "then" code all in one line.

Code: [Select]
; eric
if (talkto==1) then
{
          titletext ["\n\nNo thanks, maybe later.", "plain down"];
          ateric=false;
          play1 removeaction renteric;
          play1 removeaction renteric2;
          talkto=0;
          exit;
}


; svetlana
if (talkto==2) then
{
          titletext ["\n\nGo to hell, whine!", "plain down"];
          atsvetlana=false;
          play1 removeaction rentsvetlana;
          play1 removeaction rentsvetlana2;
          talkto=0;
          exit;
}
...
Code: [Select]
; eric
if (talkto==1) then
{
          titletext ["\n\nNo thanks, maybe later.", "plain down"];ateric=false;play1 removeaction renteric;play1 removeaction renteric2;talkto=0;exit;
}


; svetlana
if (talkto==2) then
{
          titletext ["\n\nGo to hell, whine!", "plain down"];atsvetlana=false;play1 removeaction rentsvetlana;play1 removeaction rentsvetlana2;talkto=0;exit;
}
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

schplurg

  • Guest
Re:If...Then Help?
« Reply #2 on: 21 Jan 2003, 23:21:18 »
Thanks for the response. I've alredy tried your first version of the code, and the method that works currently for me is the second example you posted basically. It's just messy and easy to miss a variable in the "single line" version, but I can live with it.

Anyone else?

Thanks again for the quick response :)

Liquid_Silence

  • Guest
Re:If...Then Help?
« Reply #3 on: 22 Jan 2003, 03:03:11 »
You can use Toadlife's first example, but only in a function, where a return is interpreted as a space character...

Because the then code is a string and the interpreter for .sqs files registers a return differently to a space character, you can't really use a return inside strings in an .sqs file...(I think: I haven't really played around with this at all...I just write it spread out then compress it to one line when it is finished).

EDIT:

Except that:
Code: [Select]
{
do this; do that;
}
should in theory be equivalent to:
Code: [Select]
"
do this; do that;
"
and the beginning and ending returns don't seem to affect anything...

Anyway...you could try:
Code: [Select]
{
do this
do that
}
as return seems to signify a ; in .sqs files,

If this doesn't work (and I have a feeling that it won't) I think the best way is to write it in the format of Toadlife's first example (so you can keep track of what you're writing easily), and then compress it into the format of his second, so that you can actually run the script...
« Last Edit: 22 Jan 2003, 03:16:27 by Liquid_Silence »

schplurg

  • Guest
Re:If...Then Help?
« Reply #4 on: 22 Jan 2003, 06:18:36 »
Ok, well that's pretty much what I did heh. I can live with that! I've tried everything else I could think of.

Thanks for the help :)