OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: remcen 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.
_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])]
exitok, 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.
-
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.
-
yes, that's what i mean... ok, i'll check the count-command. thanks :)
-
this is the script as it is now:
_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.
-
Only had a quick scan but should:
#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:
#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
-
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.
-
Right .....I understand now ;D
Planck
-
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.
_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.
-
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
-
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.