Events question...

I think the 'addiction' comparison is quite insulting, frankly. At this stage of my life, I'm very torn about trying to learn what's essentially a new language. I love what Lua can do, but I'm not sure I really want to invest the time and energy to learn it. So that really means giving up scenario making, since I'm not willing to be a relic of an obsolete system, as were a couple of designers that insisted on hanging on to MGE. Maybe it's time to find another hobby. The thing about people who quit smoking, is that they can be a little sanctimonious.

Don't go being the type of old crankburger who can only give and never take. Threatening to quit because someone used a comparison you don't agree with is just being a knucklehead. All I'm doing is comparing two things folks are used to against two things that are new. Wasn't trying to insult anyone, just pointing out crutches delay the final victory. I also said at least twice I don't care what anyone does. A finished scenario is a finished scenario and that's a good thing!

And damn right I'm sanctimonious about quitting smoking. It's the prize one gets when they accomplish what so many others deem "impossible." ;)
 
John I certainly didn't mean to be argumentative -- no hard feelings I trust. Your original post was clearly intended to be complimentary and encouraging to Curt, I didn't mean to overlook that.

Always feel free to speak your mind - we will always be good :)

Just to speak to the two projects there with which I had significant involvement: Napoleon was written in Lua really without much of a framework at all, as I was learning the language. If I was going to do that scenario again now, I would write it differently, with a more modular approach instead of putting all the code in a single file. But for a first project, I'm satisfied with how successful it turned out to be. Tootall_2012 was able to grasp the structure well enough to make many additions and enhancements of his own in the later point releases.

Medieval Millennium has its own framework that was basically developed concurrently with Prof. Garfield's work on the Lua Scenario Template. However, I wrote its framework with the goal of making my own Lua event-writing as efficient as possible. So in that sense it's a framework for people who are pretty comfortable with Lua, and it probably isn't going to be very successful as an introduction to events in that language.

I'm not knocking either, just pointing out that we very much have an AC / DC / 4 other "Cs" example set here that is confusing as anything for a beginner is all.

It certainly feels to me like the most overwhelming aspect of the Lua Scenario Template is the sheer number of files, and figuring out the right (or best?) place to put code. If that template is intended to be the starting point for designers who are new to Lua -- and that certainly seems like a praiseworthy goal -- anything that can be done to simplify it and lower the "barrier to entry" would be extremely useful. Perhaps Boudicca needs a higher profile and more promotion as the template to copy. Perhaps a single overview Readme.txt explaining how each of the files in the template is intended to be used would be helpful. But please understand I'm not throwing stones. What's there is great, and I'm only offering encouragement and suggestions that might help it reach a broader audience.

I did write a bit of a designers readme trying to do just this. I guess I didn't invest enough in it. But yeah, no real disagreement from me.

@techumseh It would certainly be a shame if you gave up on scenario-making. I really don't think TheNamelessOne intended to create a divide in the community by adding support for Lua, where only a privileged few move on to the new Elysian Fields. If you don't want to learn Lua, that's your right, and it doesn't mean that scenarios without Lua are "relics". But if you are at least a little bit interested, my point is that you can dip your toe in the waters only as much as you want, without starting over. And as John and Curt and others have pointed out, there are multiple people around in the forums right now who are glad to help you, so now is a great time to give it a try.

I'm helping Tech with a project as we speak. We're just both being very derelict at the moment. It's hard to find time in a day so the process is slow. We'll get there though.

I know I've come across rather snarkily but here's the bottom line... "You do you." Want to write in macro? I'll still play it. Want to use the converter? I'll still play it. Want to use knighttime's style? I'll still play it. Garfield's? I'll still play it.

I don't care what anyone does or how the scenario gets built. All I meant by nudging Curt is I've seen enough from @CurtSibling that I think he's one swift kick in the butt from joining me in the "knows enough about Lua to be dangerous" designer crowd ;)
 
... just pointing out crutches delay the final victory.
... or, sometimes, temporary crutches are a useful or necessary step on the way to the finish line -- and without them, the person doesn't get there at all.

We're on the same team here, trying to get people enthusiastic about using Lua. :) A few different opinions about details doesn't change the big picture.
I'm not knocking either, just pointing out that we very much have an AC / DC / 4 other "Cs" example set here that is confusing as anything for a beginner is all.
Completely agree. Different styles and examples can be helpful to the intermediate/advanced user who's ready to dig into them and look for new ideas, but they're mostly just intimidating to newcomers.
I did write a bit of a designers readme trying to do just this. I guess I didn't invest enough in it. But yeah, no real disagreement from me.
Well, I have to admit I didn't spend much time looking as I wrote my previous post. Glad to hear this was something you already spent time on -- so maybe the info is already out there and just needs better visibility.
I know I've come across rather snarkily but here's the bottom line... "You do you." Want to write in macro? I'll still play it. Want to use the converter? I'll still play it. Want to use knighttime's style? I'll still play it. Garfield's? I'll still play it.
Amen!
All I meant by nudging Curt is I've seen enough from @CurtSibling that I think he's one swift kick in the butt from joining me in the "knows enough about Lua to be dangerous" designer crowd ;)
So, butt kick delivered! :lol: Seriously, though, I'm all for Curt and any other designer making the switch to Lua. (Way to go, @civ2units!) I just don't want anyone to get discouraged or walk away because they're not ready for that full commitment. "You do you" is exactly it.
 
Last edited:
I never called you an addict and those two ribs are pretty benign and said in jest. You are gruff from time to time. Allow me my moment too ;)
 
Have you looked at Boudicca yet? It was built specifically to give an example that could be copied, pasted, and modified? I will say a big part of the problem with learning this is that there is so much out there that is different. Just look at how Garfield and I completely differently answered your question. Both answers work. His is probably the better way to do it. There's a number of different ways to achieve any desired result with this stuff that makes it overwhelming, especially when you consider that:

1. Caesar
2. Napoleon
3. Over the Reich
4. Cold War
5. American War for Independence
6. Medieval Millennium

ALL use different methods. Hence the template was constructed to try and end this.

I'm really at the point where I think maybe I should make Hinge of Fate a public build as opposed to quiet side job just so folks can see a giant scenario built within the confines of the template. Would that be helpful?

As I said, we apprentices sincerely appreciate the time you chaps take to help. I think I will take a close look at the Boudicca mod,
but I respectfully say that making HOF a build were people can see it be made, and the mechanics explained would be og huge help.

Unlike during the dev of "Over the Reich", where most didn't understand, now there are Civ2 designers (like myself) who are eager
to see how things work. Perhaps updating the old Lua tutorials too sometime would be of great benefit to the Civ-Lua project...?
 
I think the 'addiction' comparison is quite insulting, frankly. At this stage of my life, I'm very torn about trying to learn what's essentially a new language. I love what Lua can do, but I'm not sure I really want to invest the time and energy to learn it. So that really means giving up scenario making, since I'm not willing to be a relic of an obsolete system, as were a couple of designers that insisted on hanging on to MGE. Maybe it's time to find another hobby. The thing about people who quit smoking, is that they can be a little sanctimonious.

Take it from me, Tech - Applying Lua is not as bad as it seems, there is a learning curve down the line, sure, but I am convinced I can do it.
If you can get your head around Flags in the Macro system, then starting with Lua will be no problem for a seasoned designer like yourself.

If a low-intellect lifeform like me can do it - You can ace it. And please, no more talk of quitting Civ2. You have Blood and Iron to create! :)
 
Here's an idea - (and I'll stop spamming my own thread) - :)

If I post a Macro event...Can we noobs see it clearly recreated in Lua, with full disclosure on what files to use, where they go, etc?

I know there are different ways to achieve the same thing with Lua, with various designers having their own method, all them excellent.
I for one would be happy to see us all agree on what we could call a "Civ2 SL style" of Lua, just so we are all on the same hymn book page.
 
Here's the designers readme which is unfinished (I had intended to add some examples and links) but at least talks about what is in every different folder. A read through should at least break down the mystery of what goes in what box.
 

Attachments

Yep - I have that one with the Boudicca scen. Might be worth adding those examples somewhere down the line.
 
Thanks Curt. I'm sure I could do it too, given enough time and effort. The thing is, I don't really want to learn Lua. I've struggled to find the motivation, but it escapes me. At this point in my life I have other priorities. I don't need the frustration that I know comes with trying to learn these things, which are clearly not my forte. I'm not alone in this. It's one of the factors McMonkey gave for his retirement also. I do want to acknowledge the efforts of those who have tried to make Lua more accessible, particularly Prof. Garfield. I hope you will continue to do so.

Which leads me to my second consideration. I've always prided myself on making well-crafted scenarios, many with the odd innovation as well. I watched as Exile and a couple of others who wouldn't adopt Test of Time were bypassed and left by the side of the road. I don't want to release out-dated and obsolete scenarios. This is not the outcome of a single obnoxious post, but something I've been considering for months.

Finally, there's the fact that no one really plays these scenarios anymore. The scenario creation community is actually doing pretty well, all things considered. There are new designers popping up and the work that's being done with Lua events is amazing. My hat is off to those producing these scenarios. But I think we've been whistling past the graveyard for quite a while now. There's almost no audience left, because people just don't have ToT installed on their computers. The only time I get significant feedback recently is when I ask someone to playtest one of my scenarios.

I'm intending to remain active on the forum and will await the release of new scenarios with enthusiasm. I may still make a scenario or two with Macro, but just for my own enjoyment. But I doubt that I will be publicly releasing any more scenarios.
 
@techumseh Good to read that you don't give up CIV2. We are a small but awesome community and everyone who leaves us is a loss. But I understand what you wrote. We are all got older since we played CIV2 first time and everyone has other priorities beside CIV2 now. Currently I've some more spare time due to lockdown and corona and maybe that's one reason why I'm very encouraged learning as much as possible from LUA. 1517 will be my attempt of a 100% LUA scenario.

LUA is great and allows a lot of more possibilities than Macro, but this doesn't mean that we all have to use only LUA anymore. Like we wrote before, if you still designing scenarios you can combine Macro with LUA, so you don't have to switch 100%.
And things like recruit restrictions are easy to achieve in LUA with the new template from Prof.Garfield. Other things comming with the time when you are playing with the codes.
 
This is not the outcome of a single obnoxious post, but something I've been considering for months.

You do realize that comment had literally nothing to do with you, right? Not directed at you, not a reflection on you, not anything you needed to worry about.

Are you someone who is actively trying to learn this and wants to get to a point where it is learned? By your own admission, no. Therefore a comment that recommends a different strategy for people who are in that bucket does not apply to you.

You would probably find the lua converter a very useful tool in your creation endeavors. If all you want to do is have well crafted macro events with perhaps an extra touch or two (like diplomacy, or ranged combat, or a work around about some problem you encounter, like "the hump"), then the converter is perfect. Anyone who wants to do what is familiar to them but also have a few extra touches will find it a good use. The scenario can be created, and a few extras added fairly easily. At least you don't have to recreate the entire wheel. Heck, get a scenario up to the point where all you need are one or two touches and there's about half a dozen people willing to add them for you.

There is nothing wrong with this, or "lesser" about this. It's a great tool for people who do not have the time, energy, or inclination to learn lua. It's also a great tool for people who would become too discouraged by the many hours of wasted work that lua produces (I can't tell you how many mornings I've made zero progress because of this). It's great that we have it. I'm not denying that or giving anyone flak if they want to use it. Don't let me discourage anyone.

There's also nothing "outdated" about a scenario that doesn't use lua. You use it if you need it. If you can create a scenario that doesn't require it, what is the point? Take it from me with Over the Reich, there's something to be said for the old familiarity of Civ2. More isn't always better. OTR is not Civ2 at this point. It is a completely new game. 4 folks have played it. So don't feel like your creations are "lesser" or "outdated" or "obsolete." We all love a 20 year old game. There's something to be said for still being able to recognize it. I want to see more Techumseh scenarios with intricately studied OOB, attention to detail, and perfect balance. I don't care if there's lua or not. I just want to help you use it when you need to to get over issues that prevent your vision from being reality.

Again, my comment was directed to people who are willing to put in the time, energy, and frustration that it takes to build a 100% lua scenario. It was directed to the people who know a year from now they'll be going full bore. Well, for people like that, why wait a year? I'd say jump in with both feet as anything else is simply a delay, especially given there's ample examples of the base game mechanics in the scenarios we currently have available. If you're going to go through the trouble of figuring out how to work all the stuff that isn't in the legacy events, you're going to be able to figure out the stuff that is, and then you can enhance those events as well. Lua isn't just "extra types of events." Lua is a complete enhancement of every event. That's the benefit of going 100%.
 
Attached are my attempt of explaining a code for a city conquer event. The following code is an example which I'm currently using in the 1517 scenario and triggers when the Habsburgians conquer Prague. The origin of the code are from @JPetroski's Boudicca scenario as well as @Prof. Garfield. If I wrote or explained anything wrong in the following code, please correct my mistake.

This is an event for conquering Prague during the Thirty Years War by the Imperial troops.
Code:
local turn = civ.getTurn()
    if city == object.cPrague and defender == object.tProtestant and turn >=102 and turn <= 132 then
           gen.justOnce("HRE liberates Prague",function ()
            civ.ui.text("After the Habsburgian victory ...")
            civlua.createUnit(object.uImperialPikemenII, object.tHabsburgian, {{165,39,0}}, {count=2, randomize=false, veteran=false})
            civlua.createUnit(object.uImperialMusketeers, object.tHabsburgian, {{165,39,0}}, {count=1, randomize=false, veteran=false})
            civlua.createUnit(object.uCuirassiers, object.tHabsburgian, {{165,39,0}}, {count=1, randomize=false, veteran=false})
        end)
    end

Attached are the explanation for every line
Code:
local turn = civ.getTurn()
Variable for triggering the event only during a certain time period. Delete this line, if the event shall occur at any time.
Code:
if city ==
Start of the event, same like in Macro.
Code:
object.cPrague
City, which is conquered. You have to define the cities in the object.lua file before.
Code:
 and defender == object.tProtestant
Tribe, which defended the city. Same here, you have to define the tribes in the object.lua before.
Code:
and turn >=102 and turn <= 132 then
Time period, when the event shall appear. Delete this code, if the event shall occur at any time.
Code:
gen.justOnce("HRE liberates Prague",function ()
Same like Macro's "justOnce" function. The event triggers only one time. "HRE liberates Prague" defines the event.
Code:
civ.ui.text("After the Habsburgian victory at the ...")
Text box which will appear after conquering the city.
Code:
civlua.createUnit
Start of the unit creation code.
Code:
(object.uImperialPikemenII,
The unit, which shall appear. You have to define the units in the object.lua file before.
Code:
object.tHabsburgian,
The tribe, who gets the unit.
Code:
{{165,39,0}},
The location, where the unit shall appear. If you would like to use more locations, then write
Code:
{{165,39,0},{165,39,0},...},
.
Code:
{count=2,
Number of units, which shall appear.
Code:
randomize=false,
Only set on true, if you are using more then one location.
Code:
veteran=false})
Units shall be veterans; yes=true, no=false.
Code:
 end)
 end
Ending of the event.

I'm using Notepad++ for creating the events in LUA. If you made everything right, the code for the event should look like this one in the program.
upload_2021-4-27_20-45-28.png
 
@civ2units

Well done - It makes things a little clearer, and not as different from Macro as all that. :)

And now for some questions, with the part that seems to befuddle me...

I assume this nicely-explained data would be in a Lua file - Which one?
And I assume this file would be inside one of the Lua template folders (which are in the scenario folder itself) - Which folder?

Again, good work...You are really leading the way with getting into the Lua engine. :D
 
@techumseh

It has become apparent a long while ago that we are making these scenarios purely for fun, and to honour history. So, why not?
I personally would not care if I was literally Robert Neville making Civ2 scens for myself, while a world of Fortnite vampires roam around outside.

Let them. I will never abandon my first true game obsession (after Daggerfall), and I am still making WW2 scens literally half a lifetime later.

I'll have my CIV2 Fantastic Worlds box flung into the coffin with me. Nuff said!
 
@CurtSibling

The event posted would go in the triggerEvents file. This is a file for specific "triggers" (such as turn, unitkilled, citycaptured, receivedtech, etc. Etc.)

When you open up the trigger events, there's already a "starter" for each trigger. You'd put the type of events (like a city being captured) in the section after that "starter."

Basically, all the events that should have a "if turn == " trigger will go in the onTurn, all city capture ones under the city capture trigger section and so on.

Sorry I'm not at a machine where i can provide the excellent guidance civ2units did.
 
Thanks, @JPetroski ! This info is being kept in mind. In the same spirit, I am going to provide a challenge to the Lua pros - !

The challenge? Transform this Macro event into the equivalent Lua Event.

Code:
@IF
ReceivedTechnology
technology=94
receiver=Soviet Union
@THEN
JUSTONCE
CreateUnit
unit=Light Tank
Count=10
owner=Soviet Union
veteran=no
homecity=None
locations
107,51
108,42
100,40
endlocations
@ENDIF

With instructions on what Lua file to use, where the file would go, and support files (beyond the usual Object file).
It would be of use to classic Macro users to see clear indications of how to make this basic event in Lua...

Over to the wizards. :)
 
@civ2units

Well done - It makes things a little clearer, and not as different from Macro as all that. :)

And now for some questions, with the part that seems to befuddle me...

I assume this nicely-explained data would be in a Lua file - Which one?
And I assume this file would be inside one of the Lua template folders (which are in the scenario folder itself) - Which folder?

Again, good work...You are really leading the way with getting into the Lua engine. :D

Many thanks :thumbsup:
Sorry that I forgot to wrote where you have to put the event in the LUA files. I see @JPetroski did this already.
 
So with the caveat that there may be better ways to do it, the way I'd look at it is like this... I'd use either the onTurn or afterProduction trigger and put in:

if civ.hasTech(object.tUSSR, civ.getTech(94)) then
justOnce("SovietsGotTheTech", function()
civlua.createUnit(object.uLightTank, object.tUSSR, {{107,51,0},{108,42,0},{100,40,0}}, {count=10, randomize=true, veteran=false})
end)
end

I have this in Cold War and am pretty sure it's an event that fires without needing a turn indicator but you might need to put

"if turn >= 1 and civ.hasTech..." in the front instead. I'd ask for feedback from the pros on that.

You could put this in a few different places. I am awaiting correction here but...

onTurn - event fires the first turn that the game realizes that it Soviets have this tech. May or may not mean it fires the 2nd turn that they have it (I'm not clear on this). Will fire for "first" civ (think in the old days when we deliberately picked civ order based on event order).
afterProduction - event fires after a certain civ starts producing something(?) this event is utilized to make sure that you don't need to worry about civ order - you can define the specific civ's turn that it'll fire on

Those two are both in the triggerEvents file.

I've also been playing around with unitActivation frequently. Honestly I think the reason I went with unitActivation is because I wanted an event to fire the same turn that I got the tech, right after I got the tech -- but I'm not 100% this was necessary, I just know it works. Here's one for Hinge of Fate (it's a lot of code but just look at the first line):

Basically, as soon as Germany has the Align Romania tech, and any German unit activates, the event will fire. Note that this won't fire if I had a small scenario where no unit would activate, but I feel the chance of that happening in HoF is slim to none. unitActivation is found in the LuaRulesEvents file.

Code:
if unit.owner == object.tGermany and civ.hasTech(object.tGermany, object.aAlignRomania) then 
    gen.justOnce("Align Romania",function ()
    civ.ui.text("King Carol II of Romania abdicates the thrown, leaving the country in control of fascist Prime Minster Ion Antonescu.  The new leader quickly signs the Tripartite Pact, allying Romania with Germany, Italy, and Japan.  Romania and her critical oil resources will now contribute to the Reich's war effort.")
        if object.cKishinev.owner == object.tNeutrals then object.cKishinev.owner = object.tGermany end 
        if object.cJassy.owner == object.tNeutrals then object.cJassy.owner = object.tGermany end 
        object.cConstanta.owner = object.tGermany               
        object.cGalati.owner = object.tGermany                                               
        object.cBrasou.owner = object.tGermany                   
        object.cPloesti.owner = object.tGermany                   
        object.cBucharest.owner = object.tGermany               
        object.cCluj.owner = object.tGermany                   
        object.cTimisoara.owner = object.tGermany   
        for unit in civ.iterateUnits() do
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cKishinev.location.x and unit.location.y == object.cKishinev.location.y and unit.location.z == object.cKishinev.location.z then civ.deleteUnit(unit)    end
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cJassy.location.x and unit.location.y == object.cJassy.location.y and unit.location.z == object.cJassy.location.z then civ.deleteUnit(unit)    end
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cConstanta.location.x and unit.location.y == object.cConstanta.location.y and unit.location.z == object.cConstanta.location.z then civ.deleteUnit(unit)    end
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cGalati.location.x and unit.location.y == object.cGalati.location.y and unit.location.z == object.cGalati.location.z then civ.deleteUnit(unit)    end
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cBrasou.location.x and unit.location.y == object.cBrasou.location.y and unit.location.z == object.cBrasou.location.z then civ.deleteUnit(unit)    end
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cPloesti.location.x and unit.location.y == object.cPloesti.location.y and unit.location.z == object.cPloesti.location.z then civ.deleteUnit(unit)    end
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cBucharest.location.x and unit.location.y == object.cBucharest.location.y and unit.location.z == object.cBucharest.location.z then civ.deleteUnit(unit)    end
        if (unit.owner ~= object.tGermany and unit.owner ~= object.tUSSR) and unit.location.x == object.cTimisoara.location.x and unit.location.y == object.cTimisoara.location.y and unit.location.z == object.cTimisoara.location.z then civ.deleteUnit(unit)    end
        end 
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{195,111,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{193,101,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{194,94,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{186,92,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{181,101,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{184,106,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{184,110,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uRomanianInfantry, object.tGermany, {{164,104,0}}, {count=3, randomize=false, veteran=false})
        civlua.createUnit(object.uFuelRefinery, object.tGermany, {{183,105,2}}, {count=1, randomize=false, veteran=false})
        for unit in civ.iterateUnits() do
            if unit.location.x == 183 and unit.location.y == 105 and unit.location.z == 2 then 
            unit.homeCity = object.cPloesti
            end 
        end 
    end)
end
 
Back
Top Bottom