Home   Help Search Login Register  

Author Topic: script not working  (Read 897 times)

0 Members and 1 Guest are viewing this topic.

Offline remcen

  • Contributing Member
  • **
  • a.k.a. hottentotten_mike
    • IM:UC
script not working
« on: 16 Apr 2005, 23:07:20 »
ok, i'm no scripting guru, but i actually thought this numbers-on-tank script would be easy enough for me. well, i was wrong:
error messages: zero divisor in row 5 if no fifth value and
"picture imuc_datx/bmd" with an OK-button and no texture appearing.
Code: [Select]
_bmd = _this select 0
_1st = _this select 1
_2nd = _this select 2
_3rd = _this select 3
_colour = _this select 4

_arr_nums = ["0","1","2","3","4","5","6","7","8","9"]


#start
?(!(_1st in _arr_nums)): goto "random_white_numbers"

?(_colour == red): goto "red_numbers"


#white_numbers

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1.paa",_1st])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1.paa",_2nd])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1.paa",_3rd])]
exit


#red_numbers

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1r.paa",_1st])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1r.paa",_2nd])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1r.paa",_3rd])]
exit


#random_white_numbers
_r1 = random 10
_r2 = random 10
_r3 = random 10

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1.paa",_r1])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1.paa",_r2])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1.paa",_r3])]

exit
ok, the question: 1. how can i check if there is any fifth value and 2. is there a way to do this with the format command. would be a lot more elegant than to check the numbers one by one.
edit: 1. yes, the selections are defined in the cfgmodels selection and the hiddenselections of the cfgvehicles-
2. @ mods: please don't shift this thread to addon editing. it is about an addon, but the scripting side of it.
« Last Edit: 16 Apr 2005, 23:11:46 by remcen »
we're looking for members: IM:UC MOD

bluehand

  • Guest
Re:script not working
« Reply #1 on: 16 Apr 2005, 23:56:45 »
when you say "fifth value" do you mean the colour selection?  If so, I think you can do count _this to find out how many arguments were supplied in the array.

Offline remcen

  • Contributing Member
  • **
  • a.k.a. hottentotten_mike
    • IM:UC
Re:script not working
« Reply #2 on: 17 Apr 2005, 00:06:46 »
yes, that's what i mean... ok, i'll check the count-command. thanks   :)
« Last Edit: 17 Apr 2005, 00:15:35 by remcen »
we're looking for members: IM:UC MOD

Offline remcen

  • Contributing Member
  • **
  • a.k.a. hottentotten_mike
    • IM:UC
Re:script not working
« Reply #3 on: 17 Apr 2005, 18:30:57 »
this is the script as it is now:
Code: [Select]
_bmd = _this select 0
_1st = _this select 1
_2nd = _this select 2
_3rd = _this select 3
_colour = _this select 4


#start
_values = count _this
?(_values == 5) : goto "colours"
?(_values == 4) : goto "white_numbers"
?(_values == 1) : goto "random_white_numbers"


#colours
?(_colour == red): goto "red_numbers"
?(_colour == white): goto "white_numbers"

#white_numbers

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1.paa",_1st])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1.paa",_2nd])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1.paa",_3rd])]
exit

#red_numbers

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1r.paa",_1st])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1r.paa",_2nd])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1r.paa",_3rd])]
exit

#random_white_numbers
_r1 = random 10
_r2 = random 10
_r3 = random 10

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1.paa",_r1])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1.paa",_r2])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1.paa",_r3])]
exit
[this] exec "\imuc_bmd\numbers.sqs" -> error message "zero divisor" in_colour = _this etc. should be random white numbers.
[this,3,3,3] exec "\imuc_bmd\numbers.sqs" -> white numbers, scipt works
[this,3,3,3,red] exec "\imuc_bmd\numbers.sqs" -> white numbers, should be red ones. redirection doesn't seem to work.
« Last Edit: 17 Apr 2005, 18:31:22 by remcen »
we're looking for members: IM:UC MOD

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:script not working
« Reply #4 on: 17 Apr 2005, 18:42:24 »
Only had a quick scan but should:

Code: [Select]
#red_numbers

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1r.paa",_1st])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1r.paa",_2nd])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1r.paa",_3rd])]
exit

Maybe be:

Code: [Select]
#red_numbers

_bmd setobjecttexture [0,(format ["\imuc_datx\bmd\n\%1r.paa",_colour])]
_bmd setobjecttexture [1,(format ["\imuc_datx\bmd\n\%1r.paa",_colour])]
_bmd setobjecttexture [2,(format ["\imuc_datx\bmd\n\%1r.paa",_colour])]
exit


If not just ignore me.    ::)


Planck
I know a little about a lot, and a lot about a little.

Offline remcen

  • Contributing Member
  • **
  • a.k.a. hottentotten_mike
    • IM:UC
Re:script not working
« Reply #5 on: 17 Apr 2005, 19:21:32 »
ah, no... the colour is indicated by the "r"-suffix of the texture. the _1st, 2nd and _3rd variables are the three numbers to be displayed if the user wants custom numbering of his units.
if the script is only executed with [this] etc. there should be random numbers.
we're looking for members: IM:UC MOD

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:script not working
« Reply #6 on: 17 Apr 2005, 19:50:18 »
Right .....I understand now   ;D


Planck
I know a little about a lot, and a lot about a little.

Offline remcen

  • Contributing Member
  • **
  • a.k.a. hottentotten_mike
    • IM:UC
Re:script not working
« Reply #7 on: 22 Apr 2005, 21:41:12 »
i ironed out some bugs and rewrote the script- this is the part that still does not work- forwarding to the named paragraphs does not work in the queries and i don't know why.
btw the hint format etc. line returns the correct values, all paragraph names are also correct.
Code: [Select]
_bmd = _this select 0

#start
_values = count _this
hint format ["values: %1",_values]
?(_values == 1) : goto "random_white_numbers"
?(_values == 2) : goto "colours-2"
?(_values == 4) : goto "white_numbers"
?(_values == 5) : goto "colours-5"


#colours-5

?(_this select 5 == red): goto "red_numbers"
?(_this select 5 == green): goto "green_numbers"
?(_this select 5 == white): goto "white_numbers"


#colours-2
?(_this select 1 == red): goto "random_red_numbers"
?(_this select 1 == white): goto "random_white_numbers"
?(_this select 1 == green): goto "random_green_numbers"
the reason for this values query being able to handle the script flexible.
executing it with:
[this] -> random numbers, white as default colour
[this, colour ] -> random red, green or white numbers
[this,number, number, number ] -> custom numbers, white as default colour
[this,number, number, number, colour ] -> custom numbers and colours.
we're looking for members: IM:UC MOD

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:script not working
« Reply #8 on: 22 Apr 2005, 22:34:55 »
Hello.....me again.

Just a quick query.

If the format for the colours-5 paragraph is:

[this,number, number, number, colour ] -> custom numbers and colours.

Then, should it not be:

?(_this select 4 == red): goto "red_numbers"


I'm just too tired right now to think too deeply about this one.
I may take a gander at it again tomorrow.


Planck
I know a little about a lot, and a lot about a little.

Offline remcen

  • Contributing Member
  • **
  • a.k.a. hottentotten_mike
    • IM:UC
Re:script not working
« Reply #9 on: 22 Apr 2005, 23:26:19 »
oh you're so right. - i'm also damn tired i didn't see that.
btw. the colour values must be in quotes as i found out.
we're looking for members: IM:UC MOD