Jump to content

Getting Started Scripting


Xzempt

Recommended Posts

hmm, won't that some times give me a number below the _min value?

say for instance, if

(random floor _min) returned 1 and 
(random floor _max)returned 3

1 + 3 / 2 = 2. ya?

That's impossible, the example is used to calculate average value, it can never be less than min and more than max. You simply add the given values together first and then divide by amount of values used.
In your own result:

(1+3) / 2 = 4 /2 = 2
2 > 1 (min)
2 < 3 (max)

If you want pure randomness between min max then:
 

_rnd = random floor 10; //0 - 10

_rnd = (random floor 20) - 10 // -10 - 10

 

Link to comment
Share on other sites

You're saying that'll never return a value below 5 or above 10? (_min _max)

sorry for the quote, can't seem to get rid of it. lol

Disregard this, I see what you're saying now. Sometimes I am slow rofl

Edited by Xzempt
Link to comment
Share on other sites

Just like in math back at school, in programming stuff inside parenthesis is calculated first, otherwise multiplication and division takes priority. Use it to your advantage when you need to calc values before commands are executed (and to avoid syntax errors)

2 + 6 / 2 = 5

(2 + 6) / 2 = 4

Link to comment
Share on other sites

I'm not sure the correct terminology here, so bear with me a moment. I need this script to execute multiple times.

 

For instance, say I need it to execute every 600 seconds. Can you perhaps point me in the direction i need to go?

One more thing, What command am I looking for to give me a message on the right of my screen like some of these other mission scripts do?

Edited by Xzempt
Link to comment
Share on other sites

Hi Xzempt,

If you want a script that repeats infinitely you can use this:

while {true} do
{
    //do something
    uiSleep 600;
}

About those messages you mentioned: do you mean those black boxes with text? If so, this:

https://community.bistudio.com/wiki/hint
Unless you want a hint without a sound, then you will need this:
https://community.bistudio.com/wiki/hintSilent

Link to comment
Share on other sites

Don't the hints show in the middle of the screen? I don't know if you're familiar with blck_eagls AI missions but it gives a message on the right  side of the screen saying something about a Bandit Patrol has been spotted in a near by sector. That's the kind of message I'm looking to use

Link to comment
Share on other sites

You are thinking of dynamic text, Hint appears on top-right corner of the screen.

Or you can always make your own little dialog, resize and place it where you want. This can be done using RscTitles, cutRsc and RscStructuredText.
Jump in a single player Editor, press ESC and choose GUI editor, play around with it. F1 shows you all the shortcuts, when saving out using ctrl + s save it as config entry, it will appear in your clipboard.

Then simply add your exported dialog to description.ext (inside existing rscTitles if exists):

RscTitles {
    mydialog
    {
        idd = -1;
        duration = 9999;
        onLoad = "uiNamespace setVariable ['myDialogDisplay',_this select 0]";
        
        controls
        {
            myBox: RscStructuredText
            {
                idc = 5001;
                //x y z
            };
        };
    };
};

Then

createDialog "myDialog";
_display = uiNamespace getVariable "myDialogDisplay";
_ctrl = _display displayCtrl 5001;

Now that you have access to control you made, the rest of magic you can do is here: 
https://community.bistudio.com/wiki/Category:Command_Group:_GUI_Control

Edited by raymix
syntax spelling
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...