dealman 21 Posted February 11, 2016 So, since you seemingly can't create your own custom notifications in the new EDEN Editor, I took upon myself the task of writing a new custom function which does this very thing. However, I have very little experience in scripting for ArmA 3, let alone creating my own function. After some research and vigorous wiki reading, I've got the function working to some extent. But I can't get my parameters to work, there simply is no documentation(at least none that I can find) on how to make use of params when calling a custom function. Currently this is the code I have; private ["_notificationText", "_notificationColor"]; [_notificationText, _notificationColor] spawn { params [ ["_notificationText", "N/A", [""]], ["_notificationColor", [0.35, 0.35, 0.35, 1.0], [[]], 4] ]; disableserialization; _display = findDisplay 313; _ctrlNotification = _display displayCtrl 10312; _ctrlNotificationTextHeight = ctrlTextHeight _ctrlNotification; _ctrlNotification ctrlSetStructuredText parseText _notificationText; _ctrlNotification ctrlSetBackgroundColor _notificationColor; _ctrlNotificationPos = ctrlPosition _ctrlNotification; _ctrlNotificationPos set [3, ctrlTextHeight _ctrlNotification]; _ctrlNotification ctrlSetPosition _ctrlNotificationPos; _ctrlNotification ctrlCommit 0.1; uisleep 2; _ctrlNotificationPos set [3,0]; _ctrlNotification ctrlSetPosition _ctrlNotificationPos; _ctrlNotification ctrlCommit 0.1; }; Which is called via this function and the intended syntax. ["Test Message", [0, 0.71, 0, 1]] call DT_fnc_DisplayCustom3DENNotification; However, no matter what arguments I pass when calling the function, it always uses the default values. As I said, this is my first time trying to create my own function and while the documentation on the params function is very nice, there's absolute no information whatsoever on how to use it when calling a function. So I've just been going with trial and error but I'm not getting anywhere. So any help would be greatly appreciated! Share this post Link to post Share on other sites
Greenfist 1863 Posted February 11, 2016 The first line creates two private variables, but you don't define what they are. Then you pass them to the spawn as nulls. Replace: private ["_notificationText", "_notificationColor"]; [_notificationText, _notificationColor] spawn { With: _this spawn { Which will take the original paramaters to the spawned function. OR replace the first private with params -> params ["_notificationText", "_notificationColor"]; Share this post Link to post Share on other sites
dealman 21 Posted February 11, 2016 With: _this spawn { This gives me an error, saying _notificationText is an undefined variable. I was however able to get it to work by doing this; params [ ["_notificationText", "N/A", [""]], ["_notificationColor", [0.35, 0.35, 0.35, 1.0], [[]], 4] ]; [_notificationText, _notificationColor] spawn { _notificationText = _this select 0; // Added _notificationColor = _this select 1; // Added disableserialization; _display = findDisplay 313; _ctrlNotification = _display displayCtrl 10312; _ctrlNotificationTextHeight = ctrlTextHeight _ctrlNotification; _ctrlNotification ctrlSetStructuredText parseText _notificationText; _ctrlNotification ctrlSetBackgroundColor _notificationColor; _ctrlNotificationPos = ctrlPosition _ctrlNotification; _ctrlNotificationPos set [3, ctrlTextHeight _ctrlNotification]; _ctrlNotification ctrlSetPosition _ctrlNotificationPos; _ctrlNotification ctrlCommit 0.1; uisleep 2; _ctrlNotificationPos set [3,0]; _ctrlNotification ctrlSetPosition _ctrlNotificationPos; _ctrlNotification ctrlCommit 0.1; }; But I don't think that's the proper way of using params. I'm rather confused at the moment :/ Share this post Link to post Share on other sites
Greenfist 1863 Posted February 11, 2016 This really shouldn't give you undefined error: _this spawn { params [ ["_notificationText", "N/A", [""]], ["_notificationColor", [0.35, 0.35, 0.35, 1.0], [[]], 4] ]; disableserialization; ... }; And I don't think there's anything wrong with your way of using params. Share this post Link to post Share on other sites
dealman 21 Posted February 11, 2016 Cheers for the help, I've managed to get it to work the way I want. Seems rather odd that Bohemia didn't think of letting us make custom notifications since they have a function for custom message boxes in the EDEN Editor. Either way, if someone wants it here you go, I take no credit since it was originally made by Bohemia - I merely edited it. And there are probably a million ways it could be improved. :P #include "\a3\3DEN\UI\resincl.inc" /* Syntax: [<TextMessage>, <BackgroundColor>, <TextColor>, <Sound>, <DisplayTime>] call BIS_fnc_3DENShowMessage; * TextMessage: STRING - Message to be displayed * Color: ARRAY - Background colour, example; [0.71, 0, 0, 1] would be opaque red background * TextColor: STRING - Hex colour code for the text, defaults to #FFFFFF (White) * Sound: INT or STRING * Sound: INT - 0 or 1 (0 = "3DEN_notificationDefault" | 1 = "3DEN_notificationWarning") * Sound: STRING - If you want to play another sound other than the 2 default ones, use a string * DisplayTime: SCALAR - Time for the message to be displayed */ params [ ["_notificationText", "N/A", [""]], ["_notificationBGColor", [0.35, 0.35, 0.35, 1.0], [[]], 4], ["_notificationFGColor", "#FFFFFF", [""]], ["_isWarning", 0, [0, ""]], ["_displayTime", 2, [0]] ]; [_notificationText, _notificationBGColor, _notificationFGColor, _isWarning, _displayTime] spawn { _notificationText = _this select 0; _notificationBGColor = _this select 1; _notificationFGColor = _this select 2; _isWarning = _this select 3; _displayTime = _this select 4; disableserialization; _display = findDisplay IDD_DISPLAY3DEN; _ctrlNotification = _display displayCtrl IDC_DISPLAY3DEN_NOTIFICATION; _ctrlNotificationTextHeight = ctrlTextHeight _ctrlNotification; _ctrlNotification ctrlSetStructuredText parseText (format["<t color='%1'>%2</t>", _notificationFGColor, _notificationText]); _ctrlNotification ctrlSetBackgroundColor _notificationBGColor; _ctrlNotificationPos = ctrlPosition _ctrlNotification; _ctrlNotificationPos set [3, ctrlTextHeight _ctrlNotification]; _ctrlNotification ctrlSetPosition _ctrlNotificationPos; _ctrlNotification ctrlCommit 0.1; if(typeName _isWarning == "STRING") then { playSound [_isWarning, true]; } else { if(_isWarning == 0) then { playSound ["3DEN_notificationDefault", true]; } else { playSound ["3DEN_notificationWarning", true]; }; }; uisleep _displayTime; _ctrlNotificationPos set [3,0]; _ctrlNotification ctrlSetPosition _ctrlNotificationPos; _ctrlNotification ctrlCommit 0.1; }; Share this post Link to post Share on other sites