Home   Help Search Login Register  

Author Topic: script to choose ending gets error messages  (Read 1131 times)

0 Members and 1 Guest are viewing this topic.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
script to choose ending gets error messages
« on: 28 Nov 2005, 06:18:23 »
hello,

I have made a score script to choose which of the 5 endings to choose. Each mission objective based on its dificulty and importance I have selected a number for. completeing the objective will then set the corrisponding o# to true (ex: o3 = true) there are six o#'s, 1 for each objective. they have each a number from 1 to 10, I made a script that checks to see which o's were set to true (or which objectives were acomplished). the total o#'s are added up and the highest posible o-score is 37(or having completed every objective). the lowest is 0(or having completed no objectives. the script then looks at the total and selects 1 of 5 men to run through a trigger which ends the mission with the correct ending.

the problem is I get error messages and I dont know how to fix it.

Code: [Select]
_score = 0
if o1 then _score = _score + 10
if o2 then _score = _score + 9
if o3 then _score = _score + 5
if o4 then _score = _score + 4
if o5 then _score = _score + 3
if o6 then _score = _score + 6

if _score >= 30:sc1 domove sc1p
if _score >= 23 and if _score < 30: sc5 domove getpos sc5p
if _score >= 16 and if _score < 23: sc3 domove getpos sc3p
if _score >= 9 and if _score < 16: sc6 domove getpos sc6p
if _score <= 8 then sc2 domove getpos sc2p
hint format ["Your Score - %1", _score]  
exit

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re: script to choose ending gets error messages
« Reply #1 on: 28 Nov 2005, 06:59:25 »
ok, I think I have fixed some of the mistakes in this version but now im really stuck. I had to re write the entire thing

Code: [Select]
_score = 0
if o1 then _score == _score + 10
if o2 then _score == _score + 9
if o3 then _score == _score + 5
if o4 then _score == _score + 4
if o5 then _score == _score + 3
if o6 then _score == _score + 6


if _score == 37 then sc1 domove getpos sc1p
if _score == 36 then sc1 domove getpos sc1p
if _score == 35 then sc1 domove getpos sc1p
if _score == 34 then sc1 domove getpos sc1p
if _score == 33 then sc1 domove getpos sc1p
if _score == 32 then sc1 domove getpos sc1p
if _score == 31 then sc1 domove getpos sc1p
if _score == 30 then sc1 domove getpos sc1p

if _score == 29 then sc5 domove getpos sc5p
if _score == 27 then sc5 domove getpos sc5p
if _score == 26 then sc5 domove getpos sc5p
if _score == 25 then sc5 domove getpos sc5p
if _score == 24 then sc5 domove getpos sc5p
if _score == 23 then sc5 domove getpos sc5p

if _score == 22 then sc3 domove getpos sc3p
if _score == 21 then sc3 domove getpos sc3p
if _score == 20 then sc3 domove getpos sc3p
if _score == 19 then sc3 domove getpos sc3p
if _score == 18 then sc3 domove getpos sc3p
if _score == 17 then sc3 domove getpos sc3p
if _score == 16 then sc3 domove getpos sc3p

if _score == 15 then sc6 domove getpos sc6p
if _score == 14 then sc6 domove getpos sc6p
if _score == 13 then sc6 domove getpos sc6p
if _score == 12 then sc6 domove getpos sc6p
if _score == 11 then sc6 domove getpos sc6p
if _score == 10 then sc6 domove getpos sc6p
if _score == 9 then sc6 domove getpos sc6p

if _score == 8 then sc2 domove getpos sc2p
if _score == 7 then sc2 domove getpos sc2p
if _score == 6 then sc2 domove getpos sc2p
if _score == 5 then sc2 domove getpos sc2p
if _score == 4 then sc2 domove getpos sc2p
if _score == 3 then sc2 domove getpos sc2p
if _score == 2 then sc2 domove getpos sc2p
if _score == 1 then sc2 domove getpos sc2p
if _score == 0 then sc2 domove getpos sc2p
 
hint format ["Your Score - %1", _score]  
exit
if it helps im getting an error message that points to this line
Quote
if _score == 0 then sc2 domove getpos sc2p
the |#|  is here
Code: [Select]
if _score == |#|0 then sc2 domove getpos sc2p
and says somthing about type: number, expected: bool.
thanks

LoTekK

  • Guest
Re: script to choose ending gets error messages
« Reply #2 on: 28 Nov 2005, 10:51:24 »
With regards to your original code, shouldn't "and" be instead "&&"?

As for the error message, I'm not sure why it won't accept a zero value. Maybe you could try
Code: [Select]
if !(_score) then <yourcode>
Oops. Scratch that. The above code actually threw out the same error message that you had (number, expected bool), except my |#| was before "then". The following works, though, at least with my own test (I didn't try your exact code)
Code: [Select]
if !(_score > 0) then <your code>
« Last Edit: 28 Nov 2005, 11:02:36 by LoTekK »

Offline Trapper

  • Honoured Contributor
  • ***
  • I'm a llama!
Re: script to choose ending gets error messages
« Reply #3 on: 28 Nov 2005, 11:01:22 »
I'm writing if/then always like that:
if (_score == 37) then {sc1 domove getpos sc1p}

And you don't need soldiers to trigger the ends:
...then {"1" objstatus "DONE"; endmission1 = true; forceend; exit}
Afterwards write endmission1 in the condition of your end 1 trigger.

EDIT:
In this part you have to use = and not ==:
Code: [Select]
_score = 0
if o1 then _score == _score + 10
if o2 then _score == _score + 9
if o3 then _score == _score + 5
if o4 then _score == _score + 4
if o5 then _score == _score + 3
if o6 then _score == _score + 6


Oh and your shorter script lines are better:
if _score >= 23 and if _score < 30: sc5 domove getpos sc5p
if written correctly ;) :
if (_score >= 23 and _score < 30) then {sc5 domove getpos sc5p}
« Last Edit: 28 Nov 2005, 11:09:36 by Trapper »

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re: script to choose ending gets error messages
« Reply #4 on: 30 Nov 2005, 01:24:59 »
ok, Il try that as soon as I can

thanks

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re: script to choose ending gets error messages
« Reply #5 on: 01 Dec 2005, 02:30:03 »
ok, thank you trapper it seems to be working for now.

I need to do some more tests before I solve this one.