Jump to content

Pleaaase a script enigma needing some hints ;)


Recommended Posts

Posted (edited)

Hi guys,

Developping a script for CA, with a "wingman" tank which obeys you and gives you intel. I am encountering the following problem

On a new mission, if I place everything I need, it works and text messages get displayed. 

On any other already made mission, it works, but text messages don't display. 

The script is attached there, the part which interests us is from line 2669 to end. (Yup it's big)

 

An example of function here, very basic for getting the status of the unit

 

local function statutXLB()
timer.scheduleFunction(statutXLB, {}, timer.getTime() + 60) 

--XL is tank leader
--XLB is tank follower


local XL = Unit.getByName("XL") 
local XLB = Unit.getByName("XLBis")
	if XL and XLB then
			local XLBlife = Unit.getLife(XLB)
			local XLID = XL:getID()
			
	
	if XLBlife < 20 and XLBlife > 10 then 
										 trigger.action.outTextForGroup(XLID,  "106, engin endommagé", 10 , false)--Rejoins formation
										
							end
								
	if XLBlife < 10 and XLBlife > 5 then 
										trigger.action.outTextForGroup(XLID,  "106, engin gravement endommagé", 10 , false)
		end
		if XLBlife < 5 and XLBlife > 1 then 
										trigger.action.outTextForGroup(XLID,  "106, situation critique", 10 , false)
		end
		end
	end

	statutXLB()

The message will appear on a test mission made for it. But won't on older missions (even done 3 monthes ago). Everything related in the script to unit movement etc works. Functions which mix movement and text work but only for movement on older missions, texts don't appear while they do on the test mission. If I erase everything on the older mission and I only place what I need, it won't work either. 

 

Any clue of what's going on there ? Cause I'm starting to really think about a possible bug. Please note that there are other messages of this kind which are displayed in older functions above this, like this part (line 626) for static construction purpose. 

 


local function CancelConstruction(constructor_leader,construction_data)
	if constructor_leader then
		trigger.action.outTextForGroup(constructor_leader:getGroup():getID(), "construction canceled", 10 ,false)
	end

 

And these ones DO work ! 

 

Here is your challenge 😛

 

For testing purpose, you simply need to run this script, and put a vehicle group with names of unit and group as XL and another as XLBis. You need to be cockpit in the vehicle via CA to get the messages. 

 

Nicolas

ModpackScript_2022.lua

Edited by dimitriov
  • dimitriov changed the title to Pleaaase a script enigma needing some hints ;)
Posted (edited)

Maybe you don't pass the ID as a number?

https://wiki.hoggitworld.com/view/DCS_func_outTextForGroup

And from what i see, on first example you take the ID from Unit, not group (like in second example)

The ID parameter should be from Group:

function trigger.action.outTextForGroup(number groupId , string text , number displayTime , boolean clearview)

local XL = Unit.getByName("XL") 
local XLID = XL:getID()
constructor_leader:getGroup():getID()

Hope it helps you.

Edited by dark_wood
Posted (edited)

Well it was apparently not the problem. Though it seems that it works again for some reason. I finished the script this morning and now the vehicles (XL and XLB) are dynamically added therefore perhaps did it change something there. 

 

Link for final script here :  https://drive.google.com/file/d/1il2WyC6W2Y1nnBEHirByC3f0pdzJeIQG/view?usp=sharing

You'd need the frenchpack to use it but it allows for now :

 building fortifications, minefield, illumination flare, repair vehicles and CA tank AI buddy along with logistics. 

 

Edited by dimitriov
Posted
2 hours ago, dimitriov said:

Well it was apparently not the problem. Though it seems that it works again for some reason. I finished the script this morning and now the vehicles (XL and XLB) are dynamically added therefore perhaps did it change something there....

When you dynamically spawn your group/unit (in script of your latest post), you manually give the same ID for group and single unit in group (1001 for example) so groupID or unitID works the same in outTextForGroup function in this case.

The modification you made for XLID ("= XL:getGroup():getID()" instead of "= XL:getID()", XL being a unit) was needed for usual cases where IDs are different between group and unit, like @dark_wood wrote.

  • Recently Browsing   0 members

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