Home   Help Search Login Register  

Author Topic: onMapSingleClick bugginess  (Read 638 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
onMapSingleClick bugginess
« on: 24 Sep 2005, 22:59:56 »
Is the onMapSingleClick command a bit buggy? I have the following script written for an example mission for a function I wrote.
The script is called in my init.sqs

Code: [Select]
#loop
onMapSingleClick {mapClick = +_pos}
@(Format ["%1",mapClick]) != "scalar bool array string 0xfcffffef"
onMapSingleClick {}
~0.5
_tmp = [[mapClick select 0,mapClick select 1],10,5] call SteepestDir
_steepestdir = _tmp select 0
_slope = _tmp select 1
"markPos" setMarkerPos mapClick
Me setPos mapClick
Me setDir _steepestdir
Hint Format["You are now at:\n Position = %1\n Facing Direction = %2\n Slope = %3",mapClick,_steepestdir,_slope]
mapClick = nil
_pos = nil
~1
goto "loop"

Now in both the mission editor and in pbo form the above script does not work all of the time.  Sometimes a single map click will be accepted, sometimes no map click will be accepted but most of the time it works as it is supposed to and accepts multiple clicks forever.

Without the small delays I put in it fails more often.  Is there something I am doing wrong or is this command a little buggy?
« Last Edit: 24 Sep 2005, 23:00:26 by Mr.Peanut »
urp!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:onMapSingleClick bugginess
« Reply #1 on: 25 Sep 2005, 01:32:40 »
Hmm... when you say that it sometimes "fails", what exactly do you mean? Does the hint get displayed, but nothing happens? Do you try clicking more than once, with slight pauses in between (to compensate for the pauses in your script)?

Anyways, I honestly have no idea what the problem would be, without actually running the script myself. I have never run into any bugs with this command, save the fact that it was poorly made. Although I think sometimes the actual mapclicks aren't always registered, especially if you are clicking during a high-lag environment, so that might count as a bug.

But I do think you are approaching the problem in a poor manner. Generally I think it is best to execute a separate script from the mapclick command, instead of using a global variable as a 'flag' to continue with the script.

So in init.sqs, you could put this:

onMapSingleClick {_pos exec "mapclick.sqs"}

And in 'mapclick.sqs', you put this:

onMapSingleClick {}
_tmp = [[_this select 0,_this select 1],10,5] call SteepestDir
_steepestdir = _tmp select 0
_slope = _tmp select 1
"markPos" setMarkerPos mapClick
Me setPos _this
Me setDir _steepestdir
Hint Format["You are now at:\n Position = %1\n Facing Direction = %2\n Slope = %3",_this,_steepestdir,_slope]
onMapSingleClick {_pos exec "mapclick.sqs"}


Now for my shameless plug: if you are going to be doing ANYTHING with the 'onmapsingleclick' command, then I HIGHLY recommend that you use my handler suite that I've made for it. It lets you easily do a number of things with the command that would otherwise be very tough, like working with multiple 'onmapsingleclick' events, limiting the number of clicks for a single event, etc. And I hope to add 'double-click' functionality soon too! Grab it here:

http://www.ofpec.com/editors/resource_view.php?id=850
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:onMapSingleClick bugginess
« Reply #2 on: 25 Sep 2005, 04:12:35 »
By fails, I mean nothing happens. A single click is not registered. A double click will still place a marker.
« Last Edit: 25 Sep 2005, 04:14:06 by Mr.Peanut »
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:onMapSingleClick bugginess
« Reply #3 on: 25 Sep 2005, 14:22:37 »
This command is definitely bugged.

Try the following:
Put a marker on the map called "markPos" and a single unit.

init.sqs
Code: [Select]
onMapSingleClick {[_pos] exec "onMapClick.sqs"}
onMapClick.sqs
Code: [Select]
onMapSingleClick {}
_pos = _this select 0
"markPos" setMarkerPos _pos
onMapSingleClick {[_pos] exec "onMapClick.sqs"}
exit

Run the mission and start clicking on the map. Even with slow deliberate clicks, eventually it stops accepting single map clicks.
« Last Edit: 25 Sep 2005, 14:24:32 by Mr.Peanut »
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:onMapSingleClick bugginess
« Reply #4 on: 25 Sep 2005, 21:28:10 »
Have posted above example on bugged commands thread.
urp!