• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

SQL + Lua tutorial needed

rocklikeafool

Warmaster
Joined
Jan 9, 2008
Messages
2,416
Location
Wherever there's Tequila...
Is there a tutorial for how to do basic lua functions in CivV? For example, giving a unit promotion through a specific call? Or summoning a unit (like a skeleton or demon for one turn)? I'm wondering, because it comes to mind that creating spells for the Naerality Reborn mod would probably be easiest to do, if I could use the following pseudo-code.

Pseudo-code:
Spoiler :

Code:
1. Call promotion (via an executable action, like a spell that can only be used once per turn by the unit casting the spell).
2. Add promotion to units (or units around unit).
3. Promotion fades after a specific set of conditions. (For instance, the promotion only is designed to last 1 turn.)

OR

Code:
1. Call temporary unit (again, via executable spell that can only be used once per turn by the unit casting the spell).
2. Temporary unit (as an example, a fireball) is summoned.
3. Temporary units fades upon fulfilling specific conditions. (For instance, a fireball dies upon attacking, causing collateral damage. Or a summoned skeleton/demon fades after 1-3 turns.)


Anyway...what lua tutorials for CivV would you recommend I check into? Thanks.


Moderator Action: 2 threads combined and moved to the main forum.
Because the tutorials subforum is for tutorials only, not for questions ;).
 
I'm looking for a tutorial that explains the kind of basic functions that SQL would use in CivV. I'm not really new to coding (I'm studying computer science), just new to SQL. So, I can understand the basic logic of it; I just need more knowledge on the syntax and command types.
 
I am having a hard time finding good relevant LUA tutorials too... However I have done some SQL modding so I can at least give some examples from my own mod.

I am assuming you have ModBuddy installed and is using that for the modding. In ModBuddy right click your mod and choose Add -> New Item -> Game Rules (SQL) when you press Add you will have a file called "Game Rules1.sql", now we can add some lines to this file:

-- Plantations on banana resource gives 1 gold instead of removing 1 production
UPDATE Improvement_ResourceType_Yields SET Yield = 1 WHERE ResourceType = 'RESOURCE_BANANA' AND YieldType = 'YIELD_PRODUCTION';
UPDATE Improvement_ResourceType_Yields SET YieldType = 'YIELD_GOLD' WHERE ResourceType = 'RESOURCE_BANANA' AND YieldType = 'YIELD_PRODUCTION';

-- Barbarians never cease to reward experience
UPDATE Defines SET Value = -1 WHERE Name = 'BARBARIAN_MAX_XP_VALUE';

-- Mint works with the copper resource, but only gives 1 extra gold
INSERT INTO Building_ResourceYieldChanges VALUES ('BUILDING_MINT', 'RESOURCE_COPPER', 'YIELD_GOLD', 1);
INSERT INTO Building_LocalResourceOrs VALUES ('BUILDING_MINT', 'RESOURCE_COPPER');

-- Pikeman/Landsknecht upgrades to Musketman instead of Lancer.
UPDATE Unit_ClassUpgrades SET UnitClassType = 'UNITCLASS_MUSKETMAN' WHERE UnitClassType = 'UNITCLASS_LANCER';
UPDATE Units SET ObsoleteTech = 'TECH_GUNPOWDER' WHERE Type = 'UNIT_PIKEMAN' OR Type = 'UNIT_GERMAN_LANDSKNECHT';
UPDATE Units SET GoodyHutUpgradeUnitClass = 'UNITCLASS_MUSKETMAN' WHERE Type = 'UNIT_PIKEMAN' OR Type = 'UNIT_GERMAN_LANDSKNECHT';
 
You can add many rows to a table with one insert statement (100s if you like). See here. My mod tables are modified entirely in SQL (not XML) so you can find a lot of examples there.

I learned Lua by looking at other large mods. The core Lua is also useful (and now you have G&K scenarios). Get a good search program (Windows Grep or whatever) and grep "promotion" to get started.
 
Hmm...thanks, guys. I'll have to look more at this when I've some spare time (:lol: spare time, like I have any). But anyway, I disgress. Thank you both.
 
Pazyryk I must say that code looks very simple to use. Maybe I shall consider using it in my next mod to make things easier.
 
Back
Top Bottom