Lua Booleans, and SQL Table Definitions

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
How do I access the XMLschema-turned-sql in Lua? (Or what SQL db statement do I call from Lua to do this?) For example, how do I check what "default" of "AITradeModifier" is set to:
Code:
<GameData>
  <!-- Table definition -->
  <Table name="Resources">
    ...
    <Column name="AITradeModifier" type="integer" default="0"/>
    ...


Second question. In languages where false=0 and true=1, a table like this:

someTable = {5, true, 0, -3, false}

Can be looped through like this:

Code:
for someVal in someTable 
    if someVal 
        ...do stuff...

Stuff would be done for elements 1, 2, and 4.

How exactly do I adjust this for lua? Everything I've read about the weird nil system for booleans has just been... weird. I asked my resident Lua expert (brother) but he's only familiar with the Lua implementation in Gary's Mod for HL-2, which is often even weirder. In that version an "if" without a logical expression only checks if a variable exists.
 
Check the SQLite website, it's probably one of the PRAGMA commands. http://www.sqlite.org/lang.html

As for the if statement, only the boolean false and nil are considered as false, everything else is true (this is why "existing variables" can be checked). You don't usually need to evaluate a table like you posted, that's just bad programming ;)
 
Back
Top Bottom