Home   Help Search Login Register  

Author Topic: Just a hidden syntax error ... maybe  (Read 1084 times)

0 Members and 1 Guest are viewing this topic.

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Just a hidden syntax error ... maybe
« on: 26 Oct 2008, 10:55:53 »
Pain o pain ....
Whats wrong with this code? It gives an error about string, expecting code right before the second DO (part of the FOR loop) ....
Its not making a whole lot of sense to me .... no matter how many times I adjust it.
Thanks for your help.

BTW, the idea is to detect if theres Shore/Land nearby (when in water) by spining a empty cam around at "ground" level to see if it rises above sea level.
Can't think of a better way :(

Quote
_soldier = _this Select 0;
_HLimit = _this select 1;
_iDis = _this select 2;

_TempPos = "camera" CamCreate [0, 0, 0];

while{alive _soldier}do
{
_TempPos setPos (getpos _soldier);
_FLand = 0;

for [{_idir=0}, {_idir<361}, {_idir=_idir+20}] do
{
   _NextBodyX = (_pos Select 0) + ((Sin _idir) * _iDis);
   _NextBodyY = (_pos Select 1) + ((Cos _idir) * _iDis);
   _TempPos SetPos [_NextBodyX, _NextBodyY, 0];
   if ((getposasl _TempPos select 2) => _HLimit) then {_FLand = 1};
};


if (_FLand == 1) then
{
   hint format["At Shore: %1", _FLand]
};
Sleep 1.046233;

};

camDestroy _TempPos;

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Just a hidden syntax error ... maybe
« Reply #1 on: 26 Oct 2008, 11:47:06 »
Try with a gamelogic:

Code: [Select]
private["_soldier", "_HLimit", "_iDis", "_asl_log", "_center", "_idir","_FLand"];
_soldier = _this Select 0;
_HLimit = _this select 1;
_iDis = _this select 2;

_asl_log = "logic" createVehicleLocal [0,0,0];

while{alive _soldier}do
{
   _FLand = 0;
   _center = getPos (vehicle _soldier);
   for [{_idir=0}, {_idir<359}, {_idir=_idir+20}] do
   {
      _asl_log setPos [(_center select 0)+sin(_idir)*_iDis, (_center select 1)+cos(_idir)*_iDis, 0];
      if ((getposASL _asl_log select 2) >= _HLimit) then
      {
         _FLand = 1
      };
   };


   if (_FLand == 1) then
   {
      hint format["At Shore: %1", _FLand]
   };
   Sleep 1.046233;
};

deleteVehicle _asl_log;

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Re: Just a hidden syntax error ... maybe
« Reply #2 on: 26 Oct 2008, 12:34:16 »
Thanks mandoble, probably heads of bad code there by me.
Works as it should, but with wave variance and shallow beaches I'm not getting enough resolution to properly detect the land-sea interface :(

Need to look for another trick.
... wonder if I can detect the seabed ...

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Just a hidden syntax error ... maybe
« Reply #3 on: 26 Oct 2008, 12:45:46 »
Use surfareIsWater command then.
« Last Edit: 26 Oct 2008, 14:19:26 by Planck »

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Re: Just a hidden syntax error ... maybe
« Reply #4 on: 26 Oct 2008, 14:36:36 »
HOLY CR@P ..... it was right in front of me the whole time ..... Thanks heaps Mandoble  :good: