TheNamelessOne
Warlord
- Joined
- Dec 18, 2013
- Messages
- 227
Here's the documentation of all of the available functions / objects, which I'll be expanding in the coming days: Lua function reference.
As I understand it, once you've enabled LUA in the launcher, if you run a scenario with an 'events.lua' file it'll ask you which one to use.Can you confirm If I understand correctly, in terms of the event files, you must either use the standard macro or the lua scripting events? You cannot use both.
Can you confirm If I understand correctly, in terms of the event files, you must either use the standard macro or the lua scripting events? You cannot use both.
For my part, I have limited programming skills but I would like to take advantage of this new tool, if not on my current project, at least in the future. I've been reviewing your SciFi events.lua file and find that I'm able to understand many, though not all, sections of it (thanks in large part to your numerous coding comment explanations). Hopefully you or other designers will create more lua event files that programming novices like myself will able to use as references.
In the meantime, I hope you don't mind but I took the liberty to create a simple reference guide for your project that other designers may want to use. I find it's been a very useful tool for my current project. It lists all the features you've implemented to date along with their descriptions. I've attached the PDF below.
Can confirm the Sci-Fi script works, but I've been trying to implement LUA in a custom scenario and while the platform can tell if there are coding errors, it never actually runs the events.lua and defaults to macro.
Amazing work. Probably covers several of my earlier requests in one. I've got no experience with Lua, so I've got some learning to do. I thought scenario designers would be all over this one. Where did they go?Here it is, release 0.14
Same for me. I didn't have the problem with the launcher from post 649.(EXE is back to tripping 'TR/Crypt.ZPACK.Gen4'. )
See here.Okay, I set tech 94 to value 0 for tribes 6 and 7. It was already 0 for the other tribes. It seemed to fix the problem. Considering tech 94 was a low priority tech and the main tree doesn't seem to depend on it, I am rather baffled why that tech caused the entire tree to be value 1 for column 0 in advance2 & leaders2 for the last two tribes.
Amazing work. Probably covers several of my earlier requests in one. I've got no experience with Lua, so I've got some learning to do. I thought scenario designers would be all over this one. Where did they go?
This was pretty much all copy-pasted either from the Sci-Fi demo or the posted conversion guide, so in theory it should work:It should run events.lua when there are no errors. Can you post the example?
local civlua = require "civlua"
local func = require "functions"
local state = { }
local justOnce = function (key, f) civlua.justOnce(civlua.property(state, key), f) end
local negate = function (f) return function (x) return not f(x) end end
civ.scen.onSchism(function (tribe)
return false
end)
local function buildTransport(unittype, mask)
local unittype = civlua.findUnitType(unittype)
unittype.buildTransport = unittype.buildTransport | mask
end
local function useTransport(unittype, mask)
local unittype = civlua.findUnitType(unittype)
unittype.useTransport = unittype.useTransport | mask
end
local function nativeTransport(unittype, mask)
local unittype = civlua.findUnitType(unittype)
unittype.nativeTransport = unittype.nativeTransport | mask
end
civ.scen.onTurn(function (turn)
if turn == 1 then
-- Set initial map transport parameters
useTransport("Settlers", 1)
useTransport("Engineers", 1)
useTransport("Tommies", 1)
useTransport("Volunteers", 1)
useTransport("Soldati", 1)
useTransport("GP", 1)
useTransport("Stormtroopers", 1)
useTransport("Militia", 1)
useTransport("Fanatics", 1)
useTransport("Partisans", 1)
useTransport("Alpine Troops", 1)
useTransport("Infantry", 1)
useTransport("Commandos", 1)
useTransport("Paratroopers", 1)
useTransport("Mech. Inf.", 1)
useTransport("T-72", 1)
useTransport("Leopard", 1)
useTransport("Type 90", 1)
useTransport("T-80", 1)
useTransport("Centurion", 1)
useTransport("Chieftain", 1)
useTransport("Armor", 1)
useTransport("AT Infantry", 1)
useTransport("Field Gun", 1)
useTransport("Artillery", 1)
useTransport("Howitzer", 1)
useTransport("Diplomat", 1)
useTransport("Spy", 1)
useTransport("Caravan", 1)
useTransport("Freight", 1)
useTransport("Warhawk", 1)
useTransport("Volunteers", 2)
useTransport("GP", 2)
civ.ui.text("It blended.")
end
end)
civ.scen.onLoad(function (buffer) state = civlua.unserialize(buffer) end)
civ.scen.onSave(function () return civlua.serialize(state) end)
I'd mentioned playable barbarians earlier, and on testing the hack it looks like it'd take a lot more work. The user interface short-circuits constantly: map reveal is buggy in a way I haven't seen since running the original Civ2 on low memory in Win3.1, movement and combat is instantaneous to the point you might not even realize you've lost your troops, and lose them you willattack and defence strength seem nerfed regardless of difficulty. I threw a tank at a settler and the tank nearly died.or, even more exciting, perhaps even scripted takeover of the barbarians ...
Correct, it's one or the other now, but there's no technical reason for this. I could implement it, is this something that might be useful?
If I have some spare time, I'd like to convert the Midgard scenario as well. Until then, feel free to ask Lua questions on this forum.
Perhaps all have vanished into their caves to learn lua. At least I hope so.
Code:civ.scen.onCityProduction(function (city, prod) if civ.isUnit(prod) and prod.type.name == "Warriors" then city.size = city.size - 1 end end)
(Which causes a city to lose 1 pop when building Warriors.)
Amazing work. Probably covers several of my earlier requests in one. I've got no experience with Lua, so I've got some learning to do. I thought scenario designers would be all over this one. Where did they go?
With the greatest of respect, can someone explain why it would be worth doing? Thanks.
PS
Still think extra unit status levels above "veteran" would transform the game in a fun way!