InputBox value to Distance

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: InputBox value to Distance

Post 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
Attachments
Name_input..iateUnit.zip
(1.6 KiB) Downloaded 14 times
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: InputBox value to Distance

Post 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
 
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: InputBox value to Distance

Post by Parel803 »

KH, thx for the hulp
best regards GJ
Post Reply

Return to “Lua Legion”