Jump to content

Recommended Posts

Hello all,

I'm trying to script a 2d compass (based on code I found on internet, not mine) but I'm really not good at maths. If you are please explain to me in simple words or detailed explanations so I can understand and reproduce.

 

My issues :
1. I can't make it align with north correctly
2. I can't figure out how to change it's width without destroying it's rotation

Size of my picture 4096*4096 pixels.
 

Share this post


Link to post
Share on other sites

I don't get the math in it but I guess _dir could be just

_dir = getDir player;

 

EDIT: strikethrough

Share this post


Link to post
Share on other sites

Why use math?

disableSerialization;
MyCompass = findDisplay 46 ctrlCreate ["RscPictureKeepAspect", -1]; 
MyCompass ctrlSetPosition [0.5,0.5,.1,.1]; 
MyCompass ctrlSetText "\A3\ui_f\data\map\markers\handdrawn\arrow_CA.paa"; 
MyCompass ctrlCommit 0;
addMissionEventHandler ["EachFrame",{
	MyCompass ctrlSetAngle [getDirVisual player, 0.5, 0.5]; 
}];

You can get around the serialization error message by using "with UInamespace do", depends on how you set it up.

 

Cheers

Share this post


Link to post
Share on other sites

Because my 2D compass is Horizontal linear. I want it to slide left or right depending on the orientation of the player

Share this post


Link to post
Share on other sites
15 minutes ago, Flash-Ranger said:

Because my 2D compass is Horizontal linear. I want it to slide left or right depending on the orientation of the player

Use linear conversion then?

 

You're not really specific about what you want.

When the bearing is 0 the slider should be full left, at 360 full right?

 

Could be something like this:

_dir = getDirVisual player;
_newMin = minPositionX;//some x coordinate the image should have when the player bearing is 0
_newMax = maxPositionX;//some x coordinate the image should have when the player bearing is 360
_positionX = linearConversion [0,360,_dir,_newMin,_newMax,true];

Cheers

Share this post


Link to post
Share on other sites

It's fine, I re-read myself I found my own mistakes 😞 silly me ! Sorry for the bother. A Mod can delete this topic !

  • Confused 1

Share this post


Link to post
Share on other sites
7 minutes ago, Flash-Ranger said:

It's fine, I re-read myself I found my own mistakes 😞 silly me ! Sorry for the bother. A Mod can delete this topic !

Why not share how you solved your issue?

Deleting topics won't help others that might run into similar issues.

 

Cheers

  • Like 4

Share this post


Link to post
Share on other sites

Yep, sharing your solution is the best thing to do around here :smile_o:

  • Like 1

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

×