Jump to content
Bamse

Creating Display with text defined in init.sqf

Recommended Posts

Hi everyone!

 

I'm trying to produce a config where I create an item that among other things creates a display. I want that displays' text property to show a variable that I define in a missions init.sqf. It is meant to be multiplayer compatible so the variable should be public.

So, in my missions' init I create a public variable named "bamse" and set the value to for example 1000.

I'm quite out of my depth here and are trying to figure out how to actually set the text.

 

I've been trying to use the following;

#define IDC_BAMSE1 = 10001

class Bamse1 : RscDisplayBaseBamse {
    idc = IDC_BAMSE1;
    x = 0.1595 * safezoneW + safezoneX;
    y = 0.811 * safezoneH + safezoneY;
    text = "(ctrlSetText [IDC_BAMSE1, (missionNamespace getVariable "bamse")];)";
    };

but that doesn't work at all. When I launch the game I get a CTD with error: /<item_dialog>/Bamse1.bamse: "" encountered instead of '='

 

I've been trying to read up on dialogs and displays and their controls and also poke around a bit how other mods are doing similar stuff but I still don't get the hang of it.

Can I even do this on the control or does it need to be fired in OnLoad or something? Does it help me if I create a function getting the variable instead so text = "call wow_fnc_getvariable;"?

Am I doing something fundamentally wrong so your instinct is "dude, rtfm" or am I even close? :P

 

Share this post


Link to post
Share on other sites

I can see an issue with how youre using text attributes.

This display will need to be opened before the control can be changed. This is because you cant execute code from the text attribute, it will only display what is in the string.
That needs to be done via a script or function, assuming you have no buttons on it.

 

So your config should look like this for now:

#define IDC_BAMSE1 = 10001

class Bamse1 : RscDisplayBaseBamse {
idc = IDC_BAMSE1;
x = 0.1595 * safezoneW + safezoneX;
y = 0.811 * safezoneH + safezoneY;
text = "";
};

And the you will need to adjust the text using ctrlsettext after the display is opened. (Unsure about your IDC definition working outside the config, best use IDC #)

 

For example:

 

open.sqf

createdialog "YOUR_DISPLAY";

//Used private variable just to be safe, try your initial getvariable code if you want.
_text = missionNamespace getVariable "bamse";

ctrlSetText [10001, _text];

Share this post


Link to post
Share on other sites

Thank you so much for the reply, I'll try it out tomorrow when I'm back home again.

Share this post


Link to post
Share on other sites

If you have any more trouble, Ill post a simplified version of one that I use for you to check out. Good luck

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

×