Jump to content
Sign in to follow this  
alleycat

Custom mission parameters failing - zero divisor

Recommended Posts

A 'zero divisor' error is probably an out of bounds error in this case; you are trying to access an element of any array that does not exist. That means that the paramArray does not contain what you expect it to. Try printing out the value of the paramsArray to see what is really there. Also make sure you save the mission to reload any changes made to the description.ext.

It is working for me in a very simple test mission with an extremely simple params class. Create a new mission in the editor, save it, and put this in the description.ext:

class Params {
   class Test {
       title = "Test";
       values[] = {0,1,2};
       texts[] = {"0","1","2"};
       default = 0;
   }
}

Then save and preview the mission. In the debug console, type this and click local exec:

hint str paramsArray

The game should print out: [0]

Share this post


Link to post
Share on other sites

Ok the zero division error stopped, but how to connect this to something in the init.sqf?

class Params
{
   class Weather
       {

               title = "Weather";
               values[] = {0,1};
               texts[] = {"Sunny","Rainy"};
               default = 1;
       };



   };




};

Using this in init.sqf:

10 setOvercast (paramsArray select 1);

Has no effect.

Share this post


Link to post
Share on other sites

Another question. Why wont this work in a unit condition of presence:

(paramsArray select 0) == 1

Share this post


Link to post
Share on other sites

Each subclass that you define in params places a value in paramsArray. If only one param is defined, then paramsArray has only one element. '(paramsArray select 1)' is trying to access the second element. Array indexes start at 0.

Also, the description.ext snippet that you posted has an extra } in it. I removed that and tested your code. It works fine using this:

10 setOvercast (paramsArray select 0);

Regarding the unit condition, I cannot get that to work. It could be an issue with the order of initialization of the mission (paramsArray must be undefined when the game checks that condition).

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
Sign in to follow this  

×