Page 2 of 2

RE: InputBox value to Distance

Posted: Sat Feb 12, 2022 9:05 am
by Parel803
Good afternoon,
I tried to make an extra question in the total (zeroQ) to have an inputBox for string input. Is was combining with trial&error. I put the new function in and added 'name' in the first function and in the AddUnit line. With zeroQ for the calling. Of course I did something wrong. It is asking the input but giving 'missing Name'. Sadly I do not understand enough to see what's wrong, tried changes but no luck yet.

Hope someone has the time to have a look.
best regards GJ

RE: InputBox value to Distance

Posted: Sat Feb 12, 2022 7:44 pm
by KnightHawk75
re: code attached to post #21

zeroQ() itself does not return a value, which is why the name is coming up blank in the call to InitiateCOIstatic() even though the name was validated.

Basically change:

Code: Select all

 local function zeroQ()
   local validatedUnitname = gParel.navtrain.newUnitNameFromUser('Enter the name for the new unit:','Civilian')
   if validatedUnitname == nil then 
     --abort or set default, or do whatever here.
     --validateUnitName = "SomeDefaultName"; --default
     print('Could not obtain new unit name.'); return;  --abort
   end
 end
 
To

Code: Select all

 local function zeroQ()
   local validatedUnitname = gParel.navtrain.newUnitNameFromUser('Enter the name for the new unit:','Civilian')
   if validatedUnitname == nil then 
     --abort or set default, or do whatever here.
     --validateUnitName = "SomeDefaultName"; --default
     print('Could not obtain new unit name.'); return;  --abort
   end
   return validatedUnitName;  --** add this so it returns the name **
 end
 

RE: InputBox value to Distance

Posted: Sun Feb 13, 2022 11:52 am
by Parel803
KH, thx for the hulp
best regards GJ