Home   Help Search Login Register  

Author Topic: Compass  (Read 1293 times)

0 Members and 2 Guests are viewing this topic.

Offline bigdave003

  • Members
  • *
  • I'm a double bacon genius burger!!
Compass
« on: 27 Jun 2006, 20:41:44 »
Is there a way to enable and disable the compass during a mission? With addAction or radio triggers?
"From this day to the ending of the world we in it shall be remembered. We lucky few, we band of brothers. For he who today sheds his blood with me shall be my brother. "

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Compass
« Reply #1 on: 27 Jun 2006, 20:54:20 »
always check the comref first.

Offline bigdave003

  • Members
  • *
  • I'm a double bacon genius burger!!
Re: Compass
« Reply #2 on: 27 Jun 2006, 21:05:55 »
Probably should have said, but I checked the comref, and that command only works when used in description.ext - i.e the compas status can be defined this way at the start of the mission, but can't be changed this way.
"From this day to the ending of the world we in it shall be remembered. We lucky few, we band of brothers. For he who today sheds his blood with me shall be my brother. "

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Compass
« Reply #3 on: 27 Jun 2006, 21:57:12 »
really?

check attached missionette.

[attachment deleted by admin]

Offline bigdave003

  • Members
  • *
  • I'm a double bacon genius burger!!
Re: Compass
« Reply #4 on: 27 Jun 2006, 22:10:10 »
I stand corrected! In that case, the problem could well be in my scripts - I wanted to script it so that one player has the action to enable or disable the compass (while others do not), so I cobbled these together:

cenable.sqs:
Code: [Select]
_this = _this select 0

showCompass True

~2

_this addAction ["Disable Compass","cdisable.sqs"]

~1

exit

cdisable.sqs:
Code: [Select]
_this = _this select 0

showCompass False

~2

_this addAction ["Enable Compass","cenable.sqs"]

~1

exit

Then in the units init line, I put:

Code: [Select]
[this] exec "cenable.sqs"
And when I previewed, I got the black line at the top of the screen with the # after the
Code: [Select]
_this addAction ["Enable Compass","cenable.sqs"]part of the script.
I'm not great at scripting, so could anyone help?
"From this day to the ending of the world we in it shall be remembered. We lucky few, we band of brothers. For he who today sheds his blood with me shall be my brother. "

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Compass
« Reply #5 on: 27 Jun 2006, 22:20:04 »
don't use _this as a variable, as it is reserved.

cenable.sqs
Code: [Select]
_unit = _this select 0

showCompass True
_unit removeaction encomp
discomp = _unit addAction ["Disable Compass","cdisable.sqs"]

exit

cdisable.sqs
Code: [Select]
_unit = _this select 0

showCompass false
_unit removeaction discomp
encomp = _unit addAction ["Enable Compass","cenable.sqs"]

exit

note the assigning of the action to a global variable. this enables the removal of actions so you don't get multiple actions piling up in the action menu.

in the unit's init line, use

Code: [Select]
encomp = this addAction ["Enable Compass","cenable.sqs"]
« Last Edit: 27 Jun 2006, 22:23:03 by bedges »

Offline bigdave003

  • Members
  • *
  • I'm a double bacon genius burger!!
Re: Compass
« Reply #6 on: 27 Jun 2006, 22:37:38 »
Works a treat, cheers bedges!
"From this day to the ending of the world we in it shall be remembered. We lucky few, we band of brothers. For he who today sheds his blood with me shall be my brother. "

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Compass
« Reply #7 on: 27 Jun 2006, 22:40:18 »
Quote
note the assigning of the action to a global variable.
You can (and should) disable the actions and avoid multiple ones without assigning them as global variables...

Code: [Select]
_unit = _this select 0
_id = _this select 2

showCompass True
_unit removeaction _id
_unit addAction ["Disable Compass","cdisable.sqs"]

Code: [Select]
_unit = _this select 0
_id = _this select 2

showCompass false
_unit removeaction _id
_unit addAction ["Enable Compass","cenable.sqs"]

When you use addAction it automatically 'feeds' an array 'into' the script:
Code: [Select]
[unit the action is attached to, unit using the action, action id]
« Last Edit: 27 Jun 2006, 22:45:58 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Compass
« Reply #8 on: 27 Jun 2006, 23:10:35 »
we teach and learn at the same time ;)

excellent method there, go with the above. much more elegant.