Home   Help Search Login Register  

Author Topic: Sorry to annoy you with onmapsingleclick problem  (Read 1619 times)

0 Members and 1 Guest are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Sorry to annoy you with onmapsingleclick problem
« on: 03 Apr 2008, 23:15:06 »
Well, i used the search function but the more i read there, the more i get confused. What i want is pretty simple: getting the position of a mapclick.

What i think i have understood:
The onmapsingleclick doesn't pause the script until a mapclick occurs. So i would need a variable set to false, onmapsingleclick setting this variable to true and after this a waituntil command to stop the script till the map is clicked.

I know (guess) that onmapsingleclick returns _pos as it's position but mostly this is used to call a script ([_pos] execVM "blabla.sqf"). So can i get this _pos into my script by using _mypos = _pos?

I guess i just need the correct onmapsingleclick line of code (maybe including the variable which will waituntil need to wait).

May anyone help me on this?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Sorry to annoy you with onmapsingleclick problem
« Reply #1 on: 03 Apr 2008, 23:48:36 »
Nope,
Code: [Select]
my_global_pos = _pos, the code of the click runs independently of the script that set up the onMap function.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Sorry to annoy you with onmapsingleclick problem
« Reply #2 on: 03 Apr 2008, 23:54:50 »
Hm....so i have to go the way through a global variable which i can read in my script afterwards.
Code: [Select]
_map_clicked = false;
onmapsingleclick " "my_global_pos = _pos"; _map_clicked = true;"
waituntil {_map_clicked};
_pos_i_need = my_global_pos;
Is there something correct in it?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Sorry to annoy you with onmapsingleclick problem
« Reply #3 on: 04 Apr 2008, 00:26:16 »
Code: [Select]
map_clicked = false;
onMapSingleClick "my_global_pos = _pos; map_clicked = true; onMapSingleClick '';true;";
waituntil {map_clicked};
_pos_i_need = my_global_pos;

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Sorry to annoy you with onmapsingleclick problem
« Reply #4 on: 04 Apr 2008, 00:42:53 »
Ah, now i see clearer, thx mate. Just that i understand all of it, what does the true at the end stand for?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Sorry to annoy you with onmapsingleclick problem
« Reply #5 on: 04 Apr 2008, 00:45:16 »
That your onMapSingleClick code will "disable" all default ArmA behaviour with map clicks until you receive your click. For example, that clicking the map will not command your driver to move to that position.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Sorry to annoy you with onmapsingleclick problem
« Reply #6 on: 04 Apr 2008, 00:47:38 »
Ah, makes sense, indeed. Thanks mandoble. I'm learning a lot new stuff while writing this script. You and Spooner are noted to be in Credits, for sure.

Works perfectly, Thanks and...

*SOLVED*
« Last Edit: 04 Apr 2008, 16:32:58 by myke13021 »