Jump to content
Sign in to follow this  
The_Captain

Str. manipulation - subtracting strings (no cmd!)

Recommended Posts

All right, in my mod, I need to allow the player to interact through the map via dialogs.

I have two options that I can think of so far:

1) The Onmapsingleclick way: Popping up a dialog when the player views the map screen during tactical battles as well as showing the map screen (not forcing it) when the player must use onmapsingleclick

(This way isn't really possible yet because forcemap does not allow a clickable map, and shownmap and showmap control the availability of the map, not its display)

OR

2) The Grid Coord way: Using forcemap in combination with the dialogs. When the player must interact with the map, he enters in a 4 character grid coord into a box, bypassing the need to display a clickable map and allowing the dialog to stay on the screen.

Ok, the problem I'm having is with the second:

I need to take the 4 character string and turn it into two smaller strings for the purpose of determining the X and Y coordinates of the action. Since it isn't possible to subtract string values (which would solve the ENTIRE PROBLEM), I have thought up this (and I haven't written the code yet)

If string subtraction were possible, I could simply subtract all numeric values from the string for the letter part of the coord, and vice versa for the number part.

The string is stored in a temporary variable. The script then adds together values from array1 and array 2 (below) one at a time, and compares it to the original string. When a match is made, the script does some math dancing (which I can reverse engineer from current pos scripts), and an x and y coordinate for the center of the grid square is reached.

The caveat for this method is that the script has to check most of the rough total of 10000 combinations... every time it wants to grab a coordinate, since you currently cannot subtract a string value from another.

A simpler way would be to have a separate X and Y coordinate box... but I'm frustrated and I want to be able to maniulate strings... and I'm not sure how much 67600 script checks would slow down a system wink.gif

Here's the code I'm reverse engineering: As you can see, the problem I'm having is with that format command at the bottom.. because I can't do the reverse. tounge.gif

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;improved and much more smaller position-script by Softegg, softegg.ofp@gmx.de

;

;inspired by Fishion, Jerommeke and toadlife

;

;syntax: [(x-coordinates),(y-coordinates)] exec "(scriptname)"

_xpos = _this select 0

_ypos = _this select 1

_letters = ["Aa","Ab","Ac","Ad","Ae","Af","Ag","Ah","Ai","Aj", "Ba","Bb","Bc","Bd","Be","Bf","Bg","Bh","Bi","Bj","Ca","Cb","Cc","Cd","Ce","Cf","Cg","Ch","Ci","Cj", "Da","Db","Dc","Dd","De","Df","Dg","Dh","Di","Dj", "Ea","Eb","Ec","Ed","Ee","Ef","Eg","Eh","Ei","Ej", "Fa","Fb","Fc","Fd","Fe","Ff","Fg","Fh","Fi","Fj", "Ga","Gb","Gc","Gd","Ge","Gf","Gg","Gh","Gi","Gj","Ha","Hb","Hc","Hd","He","Hf","Hg","Hh","Hi","Hj", "Ia","Ib","Ic","Id","Ie","If","Ig","Ih","Ii","Ij", "Ja","Jb","Jc","Jd","Je","Jf","Jg","Jh","Ji","Jj"]

_numbers = ["99","98","97","96","95","94","93","92","91","90", "89","88","87","86","85","84","83","82","81","80", "79","78","77","76","75","74","73","72","71","70", "69","68","67","66","65","64","63","62","61","60", "59","58","57","56","55","54","53","52","51","50", "49","48","47","46","45","44","43","42","41","40", "39","38","37","36","35","34","33","32","31","30", "29","28","27","26","25","24","23","22","21","20", "19","18","17","16","15","14","13","12","11", "10","09","08","07","06","05","04","03","02","01","00"]

?_xpos<0 or _xpos>12800:_xcoor="??";goto "Ycoor"

_xcoor = _letters select ((_xpos-64)/128)

#Ycoor

?_ypos<0 or _ypos>12800:_ycoor="??";goto "ShowXYcoor"

_ycoor = _numbers select ((_ypos-64)/128)

#ShowXYcoor

hint format ["%1%2", _xcoor, _ycoor]

exit

<span id='postcolor'>

Share this post


Link to post
Share on other sites

1) do the one, second not good cause very slow and hard to use...

2) A tip for convert string to num :

TheTimeForWait = -1

("TheTimeForWait = " + TheTimeForWaitString ) ForEach [0]

work with 1291, but not with 1a291...

3) A quick script for install combos with coord type Aaa921

ArrayMajuscForGrid = ["A","B","C","D","E","F",&quot

;

;

;G","H","I","J"]

ArrayMinusForGrid = ["a","b","c","d","e","f",&quot

;

;

;g","h","i","j"]

_i =0

#Installid6001

_index = lbAdd [6001, ArrayMajuscForGrid select _i]

? _i< count ArrayMajuscForGrid : _i = _i +1; goto "Installid6001"

_i =0

#Installid6002

_index = lbAdd [6002, ArrayMinusForGrid select _i]

? _i< count ArrayMinusForGrid : _i = _i +1; goto "Installid6002"

_i =0

#Installid6003

_index = lbAdd [6003, ArrayMinusForGrid select _i]

? _i< count ArrayMinusForGrid : _i = _i +1; goto "Installid6003"

_i =0

#Installid6004

_index = lbAdd [6004, format ["%1", _i]]

? _i< 9 : _i = _i +1; goto "Installid6004"

_i =0

#Installid6005

_index = lbAdd [6005, format ["%1", _i]]

? _i< 9 : _i = _i +1; goto "Installid6005"

_i =0

#Installid6006

_index = lbAdd [6006, format ["%1", _i]]

? _i< 9 : _i = _i +1; goto "Installid6006"

4) a script for show pos player in coord Aaa000

_Pos = getpos (leader (arrayofgroup select _whocall))

_HMajusc = ((_Pos select 0) - ((_Pos select 0) Mod 1280))/1280                              

_Hminus1 =(((_Pos select 0) Mod 1280)- (((_Pos select 0) Mod 1280)Mod 128))/128        

_Hminus2 = (((((_Pos select 0) Mod 1280)Mod 128) - ((((_Pos select 0 ) Mod 1280 )Mod 128 ) Mod 12.8 ) )/12.8   )    

_VMajusc = 9-(((_Pos select 1)                      - ((_Pos select 1) Mod 1280))/1280  )                            

_Vminus1 = 9-((((_Pos select 1) Mod 1280) - (((_Pos select 1) Mod 1280)Mod 128))/128   )    

_Vminus2 = 9-(((((_Pos select 1) Mod 1280)Mod 128) - ((((_Pos select 1 ) Mod 1280 )Mod 128 ) Mod 12.8 ) )/12.8   )    

lbSetCurSel [6001, _HMajusc ]

lbSetCurSel [6002, _Hminus1 ]

lbSetCurSel [6003, _Hminus2 ]

lbSetCurSel [6004, _VMajusc ]

lbSetCurSel [6005, _Vminus1 ]

lbSetCurSel [6006, _Vminus2 ]

5) a script for move the map with slider (u can use sliders for your problem, maybe give ideas)

;init

_zoom = 0.3

sliderSetRange [4000, 0, 10]

sliderSetPosition [4000, _zoom *10]

_OldSliderZoomPos = sliderPosition 4000

sliderSetSpeed [4000, 0.5, 2.0]

sliderSetRange [4001, 0, 12]

sliderSetPosition [4001, 6]

_OldSliderH = sliderPosition 4001

sliderSetSpeed [4001, 0.5, 2.0]

sliderSetRange [4002, 0, 12]

sliderSetPosition [4002, 6]

_OldSliderV = sliderPosition 4002

sliderSetSpeed [4002, 0.5, 2.0]

;loop for detect event

#MainLoop

~0.001

? _OldSliderZoomPos != sliderPosition 4000 and (ctrlVisible 4000): Goto "4000"

?_OldSliderH != sliderPosition 4001 and (ctrlVisible 4001): Goto "4001"

?_OldSliderV != sliderPosition 4002 and (ctrlVisible 4002): Goto "4002"

?  !(cancel) and !(validation)and (ctrlVisible 101) : goto "Mainloop"

#4000

_OldSliderZoomPos = sliderPosition 4000

_Zoom = ((sliderPosition 4000) * 0.1)

mapAnimAdd [0, _Zoom, _currentPos  ]

mapAnimCommit

#Return4000

Goto "MainLoop"

#4001

_OldSliderH = sliderPosition 4001

_currentPos = [(sliderPosition 4001*1000),_currentPos select 1]

mapAnimAdd [0, _Zoom, _currentPos  ]

mapAnimCommit

#Return4001

Goto "MainLoop"

#4002

_OldSliderV = sliderPosition 4002

_currentPos = [_currentPos select 0,(sliderPosition 4002*1000)]

mapAnimAdd [0, _Zoom, _currentPos  ]

mapAnimCommit

#Return4002

Goto "MainLoop"

; In this script a bug of init of sliderposition, don't know why, but let it down when 1.85 out with onmap...

Note : mapAnim works with map show by user and with forcemap...

Share this post


Link to post
Share on other sites

Haven't you forgotten something now uiox?

You'll need a dialog with a slider set up to use your 2)

And if you'd read what Capn said about #1 :

This way isn't really possible yet because forcemap does not allow a clickable map, and shownmap and showmap control the availability of the map, not its display)

You'd see that it's not possible to do that biggrin.gif

Share this post


Link to post
Share on other sites

Better learn English instead of OFP scripting biggrin.gif

Share this post


Link to post
Share on other sites

That's why I'm curious about the command engine... how are you using dialogs, the radio, and onmapsingleclick? be interesting to knwo the implementation.

Right now, I've resigned myself to two user input boxes, the letter & number coords.

Share this post


Link to post
Share on other sites

1) Install a script for manage clic on map

2) In this script u call a dialog

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Pos = _this select 0

_Unit = _this select 1

_Shift = _this select 2

_Alt = _this select 3

?!(_Alt) and _Shift :  [_pos] exec "ArtyDialog.sqs"; exit<span id='postcolor'>

Note you pass clic position to the dialog

3) Create a dialog with 6 combos boxes (and buttons etc)

You can adapt the code I have write in prev post

4) If OK, you tranform Aaa000 into pos array and use it...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×