Home   Help Search Login Register  

Author Topic: "If not" wont work  (Read 2624 times)

0 Members and 1 Guest are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
"If not" wont work
« on: 21 Jan 2006, 21:33:06 »
I bet this is something stupid i wont see in my script, but for some reason the "If not" statement is ignored in the script.

Here's the script

Code: [Select]
#player1
?! (alive s1): goto "player2"
titleText [format["East Officer \n%1", name s1], "PLAIN DOWN"]
~5

#player2
?! (alive s2): goto "player3"
titleText [format["East Soldier One \n%1", name s2], "PLAIN DOWN"]
~5

#player3
?! (alive s3): goto "player4"
titleText [format["East Soldier Two \n%1", name s3], "PLAIN DOWN"]
~5

#player4
?! (alive s4): goto "player5"
titleText [format["East Soldier Three \n%1", name s4], "PLAIN DOWN"]
~5

#player5
?! (alive s5): goto "player6"
titleText [format["East Soldier Four \n%1", name s5], "PLAIN DOWN"]
~5

#player6
?! (alive s6): goto "end"
titleText [format["East Soldier Five \n%1", name s6], "PLAIN DOWN"]
~5

#end
titleText ["End", "PLAIN DOWN"]
~5
exit

As you see it is for a intro sequence. Units s1 - s6 are editor placed, playable units. Basically it should show Credits like in movies the "Actors". I don't care if AI units are shown but if a unit is just not present it should skip this part.

I hope you get what i try to do. Simply, if Unit is not present, don't show it in credits.

Thx for help


Myke

note: already tried these variations:

Code: [Select]
? (! (alive s1)): goto "player2"
Code: [Select]
? (not (alive s1)): goto "player2"
Code: [Select]
?! (! alive s1): goto "player2"
Didn't worked

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:"If not" wont work
« Reply #1 on: 21 Jan 2006, 22:07:42 »
This is for multiplayer so this should be in the Editing/Scripting: Multiplayer board. Moderators will move this thread there.

Your script works fine if tested in single player with a player as group leader s1 and others as AI units. So the syntax of your alive test is ok. There is something else which needs to be done differently. Get this thread moved to multiplayer editing board and you will get it solved. For starters, you could test what you can get out of your variables with hint format:

Code: [Select]
hint format ["%1",s2]
etc...

So that you will see do you really have those variables s1...s6 pointing at the units, on all computers in the session. The problem might be related to something like where the variables have been defined, and where do you execute this script.




Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:"If not" wont work
« Reply #2 on: 21 Jan 2006, 22:21:33 »
Sorry about the wrong board...thought something basically simple would fit the "General" board.

Just to clearify what the script in Editor preview does and what not.

For player1 it shows correctly my name (Editor placed Unit, name "s1")
For player2 it shows the name of the AI, what is so far correct (Editor placed unit, name "s2")
Then it shows player 3 to player 6 which arent present at the moment (didn't put them on map to verify if script will skip these lines as it was meant to).

Offline XCess

  • Former Staff
  • ****
Re:"If not" wont work
« Reply #3 on: 22 Jan 2006, 11:52:40 »
I'm not entirely sure how ofp handles whitespace. But i believe the if and not handlers have to be seperated. Everytime I've done an alive check it has been as follows:

? !(alive unit)

hope that helps.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:"If not" wont work
« Reply #4 on: 22 Jan 2006, 13:40:50 »
@XCess

thx for your input, mate. Sadly it didn't solved the problem. It still shows me the credits for non-present units.

Any other ideas?

Offline XCess

  • Former Staff
  • ****
Re:"If not" wont work
« Reply #5 on: 22 Jan 2006, 14:11:42 »
Could try a whole map trigger and check thisList. Completely confused as to why !(alive) isn't working.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:"If not" wont work
« Reply #6 on: 22 Jan 2006, 14:30:15 »
Found a workaround which isn't really smooth but it works.

First, in init.sqs, i predefined some variables:

Code: [Select]
s1alive = 0
s2alive = 0
..
..

then i made a little checkalive script:

Code: [Select]
?(alive s1): s1alive = 1
?(alive s2): s2alive = 1
?(alive s3): s3alive = 1
?(alive s4): s4alive = 1
?(alive s5): s5alive = 1
?(alive s6): s6alive = 1
exit

then i compared just this value in the intro.sqs:

Code: [Select]
..
...
?(s1alive == 0): goto "player2"
...
..

Might not to be the best way to do it, but it works. If someone has another idea, every comment is welcome.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:"If not" wont work
« Reply #7 on: 23 Jan 2006, 07:31:51 »
Hmmm... that is very odd. There is absolutely, positively nothing wrong with your syntax there, at all. The original version should work.

The only things I can think of that might cause a problem, plainly aren't causing it here.

A couple of debugging checks that I'd do.

1.) rewrite that initial script to give you a little info at the beginning:

Code: [Select]
hint format["S1 alive: %1 S2 alive: %2 S3 alive: %3 S4 alive: %4",alive s1,alive s2, alive s3, alive s4]

#player1
?! (alive s1): goto "player2"
titleText [format["East Officer \n%1", name s1], "PLAIN DOWN"]
~5

#player2
?! (alive s2): goto "player3"
titleText [format["East Soldier One \n%1", name s2], "PLAIN DOWN"]
~5

#player3
?! (alive s3): goto "player4"
titleText [format["East Soldier Two \n%1", name s3], "PLAIN DOWN"]
~5

#player4
?! (alive s4): goto "player5"
titleText [format["East Soldier Three \n%1", name s4], "PLAIN DOWN"]
~5

#player5
?! (alive s5): goto "player6"
titleText [format["East Soldier Four \n%1", name s5], "PLAIN DOWN"]
~5

#player6
?! (alive s6): goto "end"
titleText [format["East Soldier Five \n%1", name s6], "PLAIN DOWN"]
~5

#end
titleText ["End", "PLAIN DOWN"]
~5
exit

2.) Are your titlecuts working? Check to see if the flow of control is getting to each of those labels... if they are, then the titlecut might be badly formed. From memory, titlecut won't work if you don't pass it a valid string (and an error message might not appear).

Code: [Select]
#player1
hint "I am at 1"
?! (alive s1): goto "player2"
titleText [format["East Officer \n%1", name s1], "PLAIN DOWN"]
~5

#player2
hint "I am at 2"
?! (alive s2): goto "player3"
titleText [format["East Soldier One \n%1", name s2], "PLAIN DOWN"]
~5

...

exit

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re:"If not" wont work
« Reply #8 on: 26 Jan 2006, 20:08:38 »
am i completely stupid?

Code: [Select]
..
...
#unit1
?!(alive myunit1): goto "unit2"
titletext ["Unit 1 is alive", "PLAIN"]
~5

#unit2
?!(alive myunit2): goto "unit3"
titletext ["Unit 2 is alive", "PLAIN"]
~5
...
..

correct me if i'm wrong: the above example should check if a unit is alive (or present, which is what i want) and then show the titletext.

If a unit is not present (since it has no player and AI is off) it should skip to the marker after the goto command.

I tried this to get the alive value:

Code: [Select]
titletext [format ["Unit X is alive %1", alive unitX], "PLAIN"]

At units not present i get this result:

Unit X is alive bool

Now my question:
Is it possible the check with alive wont work if the unit never was present?

Hope someone has a solution or a workaround, since my workaround doesn't work by server/client use.

Thx to all

Myke


:edit:
i checked several times if the names of the units are correct
« Last Edit: 26 Jan 2006, 20:10:04 by myke13021 »

Offline benreeper

  • Members
  • *
  • I'm a llama!
Re:"If not" wont work
« Reply #9 on: 28 Jan 2006, 01:04:01 »
I think if the unit never existed it is null.  It should throw an error,

#unit1
Try if !(isnull myunit1) then {if (alive myunit1) then {titletext ["Unit 1 is alive", "PLAIN"]}}
~5

#unit2

--Ben

Offline Silola

  • Members
  • *
Re: "If not" wont work
« Reply #10 on: 27 May 2006, 14:32:36 »
hi,

you can try this also as follows...

Quote
#player1
?(format["%1",s1] == "scalar bool array string 0xfcffffef"): goto "player2"
titleText [format["East Officer \n%1", name s1], "PLAIN DOWN"]
~5

#player2
?(format["%1",s2] == "scalar bool array string 0xfcffffef"): goto "player3"
titleText [format["East Soldier One \n%1", name s2], "PLAIN DOWN"]
~5

#player3
?(format["%1",s3] == "scalar bool array string 0xfcffffef"): goto "player4"
titleText [format["East Soldier Two \n%1", name s3], "PLAIN DOWN"]
~5

#player4
?(format["%1",s4] == "scalar bool array string 0xfcffffef"): goto "player5"
titleText [format["East Soldier Three \n%1", name s4], "PLAIN DOWN"]

...

bye
silola