Jump to content
Sertica

How To Call Scripts Properly

Recommended Posts

I have a script like this:

Spoiler

info = {
	disableSerialization;
	_ctrl = ((findDisplay 46) displayCtrl 9999);
	if (!isNull _ctrl) then {ctrlDelete _ctrl};
	[] spawn {
		disableSerialization;
		_ctrl = (findDisplay 46) ctrlCreate ["RscStructuredText", 9999];
		_ctrl ctrlSetPosition [0, 0, 0.25, 5]; 
		_ctrl ctrlSetTextColor [0.2, 0, 0.2, 1];
		_ctrl ctrlSetbackgroundColor [0.8, 0.8, 0.8, 0.1];
		_ctrl ctrlCommit 0;
		_list = [];
		
		private _dwellingTypes = ["NameVillage", "NameCity", "NameCityCapital"];
		while {true} do {
			_list pushback "Test Data<br/>";
			_dwellings = nearestLocations [getPos player, _dwellingTypes, 100];
			if ((count _dwellings) > 0) then {
				_nearestDwelling = _dwellings select 0;
				_dwellingName = text _nearestDwelling;
				_list pushback ("Nearest Dwelling: " + _dwellingName + "<br/>");
				hint str (count _dwellingName);
			};
			_ctrl ctrlSetStructuredText parsetext (_list joinString "");
			_ctrl ctrlSetPosition [-0.6, 0.0, ctrlTextWidth _ctrl, ctrlTextHeight _ctrl];
			_ctrl ctrlCommit 0;
			_list resize 0;
			sleep 5;
		};
	};
};

and init file is:


call compile preprocessFileLineNumbers ("monitorText.sqf");
call info;

 

When I "Play in SP" from the editor I immediately see the hint, but not the text box.  If I go into debug console and local execute "call info" I suddenly see the text box.  What is the difference that makes it appear when called in one way instead of the other?

Share this post


Link to post
Share on other sites

The mission display (Display #46) is not present during mission init. Creating a control ontop of a non-existent dialog won't work.

  • Thanks 1

Share this post


Link to post
Share on other sites

you probably have to add a line:
waitUntil {!isNull findDisplay 46};
just before disableSerialization;

  • Thanks 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

×