[TOT] The Test Of Time Patch Project

Here's the documentation of all of the available functions / objects, which I'll be expanding in the coming days: Lua function reference.
 
Hi TNO,

Once again you've opened up a whole new world of possibilities for designers with your latest lua scripting addition.

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.

Once again thank you for your continuing support to the community!
 

Attachments

  • TOTPP v014.pdf
    619.3 KB · Views: 364
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.
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 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.
 
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.

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? I could imagine it would be nice to add Lua functionality to an already finished project, and not having to convert old events, on the other hand, interactions between the two could cause confusing bugs.

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.

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.

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.

Nice work!

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.

It should run events.lua when there are no errors. Can you post the example?
 
Here it is, release 0.14
Amazing work. :goodjob: 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?

(EXE is back to tripping 'TR/Crypt.ZPACK.Gen4'. :dunno:)
Same for me. I didn't have the problem with the launcher from post 649.

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.
See here.
 
Amazing work. :goodjob: 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?

Perhaps all have vanished into their caves to learn lua. At least I hope so. :)


TNO, two quick questions based on your excellent ever-growing writeup of lua functionalities - would if be possible in principle to create a "Set" method for all instances where a "Get" method exists? Specific background is the civ.getPlayerTribe function - would a setPlayerTribe work? (like via cheat menu I guess?)
This would open up enormous possibilities for me, like completely scripted schisms were you take over the "rebels" (if you so choose) or, even more exciting, perhaps even scripted takeover of the barbarians ...

And another concerning triggers (very much looking forward to that section in your documentation btw ;) ) - is it possible to have an event trigger by key-pressed? (e.g. we could script road-building pioneer units where a pressed "r" key triggers a check for terrain etc and changes the tile)

Cheers, Grishnach
 
It should run events.lua when there are no errors. Can you post the example?
This was pretty much all copy-pasted either from the Sci-Fi demo or the posted conversion guide, so in theory it should work:
Spoiler :
Code:
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)
The text popup at the end is what should tell me the script ran, but even just using that alone in a test file it never prompts. When I have both events.lua and events.txt, no matter which I choose it only runs the .txt, and when I only have .lua it still prompts the selection on load yet doesn't run the file at all. Needless to say, I'm stumped.

or, even more exciting, perhaps even scripted takeover of the barbarians ...
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 will—attack and defence strength seem nerfed regardless of difficulty. I threw a tank at a settler and the tank nearly died.
 
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?

The thing about the macro language is that I find, in my personal experience, that it's unreliable when creating more complex interdependent events that use masks. In my "Total War' scenario I struggled endlessly with getting the masks to work properly, even when by all accounts they should have worked.

In addition, I believe Lua should allow developers to create more complex if/else conditions that aren't possible with macro.

Obviously, designers who are comfortable with coding should be able to completely replace the macro language with Lua scripting. I'm a very long way from being comfortable. :cry:

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.

Thanks.

Perhaps all have vanished into their caves to learn lua. At least I hope so. :)

It's going to be a very deep cave! I started looking at the www.lua.org site. Feel like I'm back in school after just a couple of years (cough, cough decades!?!?) :lol:
 
I really like this patch and all the options it offers. However, after installing and starting a new game I noticed that all new units are built without a supporting home city, i.e. NONE. This seems to hold true for the AI as well. Is there a settling in the launcher I overlooked, is it intentional or did something odd happen?
Awesome that you have put this much time and effort into sprucing up an old game!
 
Testifying to the above. It might not have been as much of a problem, but the AI starves itself by spamming settlers yet seems strangely averse to actually settle. In a test game the Spanish were knocked out by barbarians and the substitute Aztecs have a dozen settlers but only one city.
 
I can also attest to the settling issue. Before the Capitalization Limit was made configurable, eventually AI civs stopped founding cities altogether. After the configurability was enabled, the AI also became rather averse to building city improvements, especially with high capitalization thresholds. I frequently saw cities staying at level 8 populations for dozens and dozens of turns at a time, even when all techs were discovered.
 
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.)

This sounds intriguing. I'm curious how to implement this. Where in my files would I place such a script? When customizing it for a scenario, do I only need to modify the part in quotations (i.e., the unit name "Warriors")?
 
Some mind-blowing developments, fellers!
Major kudos to TNO for his continued work and efforts! :)

I was wondering about "Veteran" status lately, it would be fun if higher levels than "Veteran" could be implemented?
Perhaps a further status, of "Elite"...:)
Attainable using the same method as regular/veteran units are promoted, and giving another +50% attack, etc?

Is there also a way to use the "Veteran" system to add other upgrades to units?
Like more moves or more defence? Just a wild thought...
 
Kudos and thank you for all your hard work, TNO, sincerely.
I would like to second what Ciarran said, extra veterancy levels would be great indeed.
Even more RPG like. Veteran, elite, epic, exalted etc.
I have one question, not really a request because I understand it has to do with the domain mechanics and it may not be possible.
You know how air units can be allowed to/ restricted from attacking other air units by switching the fighter flag on/ off?
Can a similar flag be made for attacking ground or sea units?
For example to make pure interceptors that can attack other air units only or torpedo planes that can attack sea units only?
This effect can be achieved now by giving air units the submarine flag, but it only works over water tiles.
 
Amazing work TNO. Also kudos to tootall for the pdf guide.

I have recently begun dabbling with C sharp and Visual Basic so it would be very useful for me to get into Lua. It will be good to learn some coding whilst working on my favourite hobby. I find it easier to learn stuff when I'm applying to to something I enjoy!
 
Amazing work. :goodjob: 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?

I think what TheNamelessOne has done is amazing. I'm incorporating the features of the previous ToTPP release in my current scenario project. But I'm hesitating to throw out my events work and stop work to learn Lua. Unlike some, I don't have a computer background.

Changes in the Patch up to now have been extensions of the existing program. Adding Lua is different, as it replaces a major feature of ToT. Over the years, I've learned how to use the ToT macro language and flatter myself that I'm pretty good at it. Unlike Tootall, I find it reliable. Good ToT scenarios take huge amounts of time to make, and I'm not sure I want to spend the time learning an entirely new events language. With the greatest of respect, can someone explain why it would be worth doing? Thanks.
 
With the greatest of respect, can someone explain why it would be worth doing? Thanks.

I can definitely understand that - if a combination of scripts and lua was possible then that could really solve a lot of such issues I guess.

And I agree that the script language is fine for most purposes. lua (if it works as promised ;) ) would allow an enormous range of possibilities which are simply impossible to implement via scripts.

Simple example taken from Colonization: there you have dragoons, which when defeated turn into normal soldiers (at the same position), which in turn become civilians (at the same position) when defeated. Defeated civilians are destroyed. With Civ2 scripts you can have the destruction of a dragoon trigger something, but it is simply impossible to assign the "current location" dynamically. You could drop the defeated soldiers at some prearranged position for example but in many cases I can think of this simply defeats the purpose.

With lua something like that should actually be rather simple: within the onUnitKilled (or similar trigger) you simply check three times for "name='dragoon'" -> then create soldier, "name='soldier'" -> then create civilian, "name='civilian'" -> give a nice text message or something.

Depending on what kinds of triggers are possible (already, perhaps there can be more in the future?) you could also implement the other way round - after producing unit "soldiers" and unit "horses" you get them in the same position, trigger something ("key pressed" would be perfect for that), the two individual units are destroyed and a "combined" dragoon unit is created at the same position.

Now these ideas all center around combat and units only, in principle one could create vast interactive event chains - all depending on what could trigger what of course.

(Ages back I dabbled in things like that with the CSPL project, but that never managed to work under non Win-98 environments (as far as I remember ...) so nothing came from it.)
 
I noticed that the "bribe city revolt" diplo/spy option does not allow for the new limitless gold factor.
It will not let you subvert/bribe a city if the doubled amount exceeds 30k gold. And if the regular bribe
is more than 30k, the option is greyed out...

Perhaps we should consider allowing the bribe amounts to be limitless too? Although some may
argue it puts a good cap on spy actions...At the same time, so would a bribe cost of 100k!

Just something that might be easily fixed for the next update...?

PS
Still think extra unit status levels above "veteran" would transform the game in a fun way!
 
PS
Still think extra unit status levels above "veteran" would transform the game in a fun way!

Thinking about that a bit - that should actually be implementable via lua, completely customized to the scenario requirements. Given the new 127 unit limit, the "elite" status could be represented by a separate unit.
In case of combat, one could check whether the victor was already a veteran. If so the unit is destroyed and a new unit is created at same position (based on random number perhaps, with equal hp as previously or any other specifics, ...). Based on what the "base unit" was, one would probably assign different "elite units", with perhaps vastly different specs.

But again, this depends on the exact possible triggers - have to check this is more detail soon. :)
 
Top Bottom