Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

Author Topic: Getpos/setpos doesn't do what its told  (Read 1294 times)

0 Members and 1 Guest are viewing this topic.

Goettschwan

  • Guest
Getpos/setpos doesn't do what its told
« on: 16 May 2005, 17:52:49 »
I have made this little script for myself to better understand scripting in OFp.
It uses two arrays, some random numbers and a game logic which runs the script to move the game logic around the map to predefined positions at various heights.
But in the control with hint the first position is always okay (and varying),
then on the second the getpos command delivers always position "10968.8,3284.92,-0.440994".
It is not possible for the height value to go into negative with this script.
And this value will stay there forever, while the variables in the setpos command function as i thought they'd do and will be actualized with the loop.
The positions roughly equal some trees in Lipani,Nogova.
Code: [Select]
#loop
_treesX=[10650.293945,10700.918945,10707.552734,10734.062500,10735.851563,10745.424805,10749.095703,10780.573242,10805.087891,10814.947266,10823.416016,10835.656250,10839.375000,10843.005859,10881.998047,10901.287109,10914.408203,10926.298828,10951.916992,10974.490234,10980.588867]
_treesZ=[3187.731934,3062.773193,3196.926758,3150.397461,2976.351074,3182.318115,3293.530273,3294.403809,3026.086914,2992.170654,3257.679688,3282.161621,3031.016602,2976.652588,3241.941162,3032.453125,2957.813965,3094.065186,3173.368164,3115.416016,3242.299561]
_rand=random 20
_whichtree=_rand - (_rand mod 1)+1
_rand=random 4
_height=_rand - (_rand mod 1)+1

this setpos[_treesX select _whichtree,_treesZ select _whichtree,_height]
hint format["%1 %2 %3\n%4 %5 %6",getpos this select 0,getpos this select 1,getpos this select 2,_treesX select _whichtree,_treesZ select _whichtree,_height]
~3
goto "loop"

Can anybody see an error in it which would explain this behaviour?
Thanks, StG

Goettschwan

  • Guest
Re:Getpos/setpos doesn't do what its told
« Reply #1 on: 16 May 2005, 17:54:28 »
And while i am on it, is it possible to export arrays like these two to some .csv file or something like that, and call up the array from there ?
It would make it easier to work with them.
Thanks, StG

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Getpos/setpos doesn't do what its told
« Reply #2 on: 16 May 2005, 18:52:24 »
Try not using the word this as a variable.  this and _this have all sorts of meanings in OFP - you might be confusing it.

While on the subject of setPos getPos if you have an object, say a piece of fence called _obj then

_obj setPos getPos _obj will result in the fence moving approx 1/2 its length sidways
« Last Edit: 16 May 2005, 18:52:48 by THobson »

Goettschwan

  • Guest
Re:Getpos/setpos doesn't do what its told
« Reply #3 on: 16 May 2005, 19:13:46 »
I don't quite understand, THobson.
On behalf of "this", yes i should maybe name the gamelogic and call it up with its name instead of using "this".
I thought "this" refers to the calling unit, in this example the game logic running the script.

On the second, i had some problems to grasp it, but if i understand correctly you want to show me some kind of "bug"?
I set a position with the position being the actual one, and this moves the object somewhere else. Is this it?
Thanks, StG

Goettschwan

  • Guest
Re:Getpos/setpos doesn't do what its told
« Reply #4 on: 16 May 2005, 19:30:58 »
Okay, i have given the game logic a name, and exchanged the "this" in the script with the name, and it functions.  :D
Thanks, THobson, once again.
But is it possible to export large arrays into .csv files or anything like that?
StG
« Last Edit: 16 May 2005, 19:32:10 by Goettschwan »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Getpos/setpos doesn't do what its told
« Reply #5 on: 16 May 2005, 20:25:42 »
On the second point, THobson is right.   If you setPos an object to its own position it is likely to move slightly.

There is a tutorial on this and _this in the editors depot.

Oh, and when you think of something else just after making your post, please use the modify button it the top right hand corner of the post.  It's much better than making a new post yourself.   Two consecutive posts by the same person can be a little confusing.   ;)
« Last Edit: 16 May 2005, 20:31:15 by macguba »
Plenty of reviewed ArmA missions for you to play

Goettschwan

  • Guest
Re:Getpos/setpos doesn't do what its told
« Reply #6 on: 16 May 2005, 20:34:56 »
It is not that i didn't believe THobson, it is that i found it difficult to grasp ;)
I have read the beginner part of the "this" tutorial, but i found my use of "this" quite appropiate. But then, apparently "this" has its pitfalls.
Normally i modify my posts, this was an exception. Will try to behave.  :)
Thanks for your help,
StG

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Getpos/setpos doesn't do what its told
« Reply #7 on: 16 May 2005, 20:44:26 »
My pleasure.   :)
Plenty of reviewed ArmA missions for you to play