Jump to content

Recommended Posts

Posted

Mist noob here 😶 Trying to make respawn that would change skill level of new aircraft - random ore predefined.  But at this point can not even display the skill level of a new unit..

if not Group.getByName('BadGuy1') then
   mist.respawnGroup('BadGuy1', 5)
end
 
local msg = {}
msg.text =   mist.message.add(mist.getUnitSkill('BadGuy1'))
msg.displayTime = 20
mist.message.add(msg)

 

Posted
1 hour ago, Yuriks said:

...But at this point can not even display the skill level of a new unit...

On the fly, I can see that you use same name for groupName functions and unitName function. Be sure to use unitName for mist.getUnitSkill().

  • Like 1
Posted

@toutenglisse Probably that is it.

Now on the new quest to get unit name 🤔 I guess something with Group.getUnits()? 

Also, what is the best way to debug DCS scrips? insert brakes, see vars,  

Posted
1 hour ago, Yuriks said:

@toutenglisse Probably that is it.

Now on the new quest to get unit name 🤔 I guess something with Group.getUnits()? 

Also, what is the best way to debug DCS scrips? insert brakes, see vars,  

If your group is created with mission editor, the unit name is what is called "pilot name" (by default, if group name is for example "Plane-1" then the unit name is "Plane-1-1").

If I take your code example, what you need to get messages for USA players that will display skills of all units of group 'BadGuy1' is :

Spoiler
local units = Group.getByName('BadGuy1'):getUnits()
for i, unit in pairs(units) do
local msg = {}
msg.text = '' .. mist.getUnitSkill(unit:getName())
msg.msgFor = {countries = {'USA'}}
msg.displayTime = 20
mist.message.add(msg)
end

 

Spoil : units with 'random' skill will return 'random'...

If you want skill to be random, but with you being able to know what the skill is, I assume you would need to use a random number to choose between available skills, and then dynamically spawn bandits with that skill so the messages won't return 'random', but 'Ace' or 'Vet' etc...

  • Thanks 1
Posted
19 minutes ago, Yuriks said:

@toutenglissestill not getting neither name or skills in the text box 

Also getting Unused local `i` 

Since using "pairs()" should i also be listed in the msg?

 

I only checked that the little code I wrote to get units skills from 'BadGuy1' group works. (it just displays skills, not names. If you want them you could use :

msg.text = unit:getName() .. ' : ' .. mist.getUnitSkill(unit:getName())

Looking back to your first post I suspect that your issue is that you try to access units at the time they spawn, and that usually doesn't work well. Run the "message" part a second later.

"i" just means "value" (as "k" means key). "unit" is what to refer to in the msg.

  • Thanks 1
Posted

I must be doing something wrong. mist.message does not show, even though Mist respawn works. I have tried to run it as a separate scrip file and DO SCRIPT right from ME, same. 
Msgs set from ME:Actions:Text works though

@toutenglisse thank you for patience 

 
if not Group.getByName('BadGuy1') then
   mist.respawnGroup('BadGuy1', true)
end
 
-- test msg, not working 
local msg = {}
msg.text = "Test"
msg.msgFor = {countries = {'all'}}
msg.displayTime = 20
mist.message.add(msg)
 
--msgs with skills, not working 
local units= Group.getByName('BadGuy1'):getUnits()
for k, unit in pairs(units) do
   local msg = {}
   msg.text = unit:getName() .. ' : ' .. mist.getUnitSkill(unit:getName())
   msg.msgFor = {countries = {'all'}}
   msg.displayTime = 20
   mist.message.add(msg)
 
end
Posted

Thank you, It does work.

The only key difference with the exertion of 1sec delay is that you put this as skillmessage() function in a separate file while I run it as sequential commands in the same file. 

Could that be the reason? 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...