QBG Basic Changes

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

QBG Basic Changes

Post by TitaniumTrout »

I've had a few people ask me about modifying the Quick Battle Generator (QBG) files.

Each QBG is made up of two files. The form.html and script.lua.

Form.html is the front end. It passes information to the script.lua. It can not query beyond what is in that form. Those of you asking for the ability to query the database via that form, sorry, not in the cards.

Script.lua takes the passed variables and puts them into the required spots that you define.

If you haven't worked with a text editor get yourself something like Notepad++ or Visual Studio Code. Those programs are much easier than generic Windows Notepad.

Below is a select from the Form.html file. We use the "SELECT" tag, https://www.w3schools.com/tags/tag_select.asp, to give the player an option to choose.

Image

<select name="BLUFORProficiency">

This is your actual variable name. We'll use this in script.lua.

<option value="0">Novice</option>
<option value="1">Cadet</option>
<option value="2">Veteran</option>
<option value="4">Ace</option>

Each of these is the actual value that you, the player, selects. Note the value, that is what is passed to the variable name BLUFORProficiency.

Once the player makes a selection then the script processes it. You can treat it like any other variable in your lua.

Image

We call it out as the last value (this is important) in the function.

Image

And there's the function itself with the variable called at the end. Now BLUFORProficiency is that proficency value.

Image

Then later on in that function you see the ScenEdit_AddUnit line with the added proficiency. That's the only thing I changed here from the basic setup. As a general rule change one thing at a time with your code. Then if it doesn't work you can figure out what happened from one step to the next.

Commenting your code heavily is also very very useful, in lua you do this with two -- . Then you can "talk" your way through how a program should operate. Just remember, a computer is the dumbest thing, you must tell it exactly what to do and in the proper order. Anything else and it will fail.
Post Reply

Return to “Lua Legion”