Page 1 of 1

LUA help/ more detailed guide? video?

Posted: Thu Aug 13, 2020 6:31 pm
by ChristianC
Hello, I have many scenario ideas which I would love to create, however the LUA guide is a bit perplexing. From some coding classes I took awhile back I understand the basic principles of functions, variables, methods and whatnot but this is still confusing to me. Would a developer or a veteran scenario maker be so kind to upload a video that shows concrete examples of using these codes in the editor (or LUA file) for the rest of us that want to make content for this game but are at this road block? Thanks

Re: LUA help/ more detailed guide? video?

Posted: Thu Aug 13, 2020 6:43 pm
by Kerensky
It's far too complex for me to explain because it is beyond my comprehension, I work purely through examples and reserve engineering.

And that's my advise, look at existing game scenarios and see what's there and how it works.

Defenders of the Reich has a wealth of functions going on, as does almost every single scenario of the Spanish Civil War DLC. The tutorial scenarios are also a good place to look, because they often rely on scripts to promote various gameplay aspects to highlight.

The real issue is that knowledge of LUA is... rather worthless. Sure it will help a person understand the basic syntax of things, but that is of exactly 0% helpful, because the game has so many specific links between script code and game data that no generic LUA lesson will cover.

Re: LUA help/ more detailed guide? video?

Posted: Thu Aug 13, 2020 8:04 pm
by nexusno2000
It's not that difficult.

Use existing scripts as templates, and adjust to taste.

As more DLCs are added, you'll have more templates to work from.

It's time consuming at first, but once you get the hang of it, it's not that bad.

Re: LUA help/ more detailed guide? video?

Posted: Thu Aug 13, 2020 8:14 pm
by Kerensky
"Adjust to taste" is definitely the choice phrase.

What are you trying to get scenarios to do? Find a scenario that does something akin to it, and copy paste the scripts wholesale, and then edit the bits you want to change.

Lots of functions exist, too many to list.

Adding heroes to units, customizing those hero traits and stats, two types of message pop ups, many interactions with victory conditions, counting and tracking a currency, creating units via script like rewards or as enemy reinforcement waves, giving and taking away prestige, giving captured equipment or prototype stocks...

Re: LUA help/ more detailed guide? video?

Posted: Fri Aug 14, 2020 5:05 pm
by ChristianC
Okay, thanks for the replies, I suppose I will work with what I have for now (these files). The problem remains that many of the functions are still incomprehensible to me. I am also having trouble setting objectives and triggers in the editor itself (such as setting success/fail conditions for custom objectives). Right now I am working on a partisan hunter scenario in which a player must clear out a series of partisan strong holds from a general vicinity but am getting stuck on this part. I would like to reiterate for anyone else reading this that I think it would do the community a great benefit if a scenario designer would simply record a session(s) in the editor/LUA files to create a mission (of course commentary would be EXTRA helpful), not only for me of course but I assume a lot of other people as well. Maybe these could be put on a private channel with a link or something, just an idea.

Re: LUA help/ more detailed guide? video?

Posted: Fri Aug 14, 2020 7:17 pm
by Kerensky
Why does 'clearing strongholds' require LUA at all?

Sounds like it's either hex/flag taking, or unit destruction. Both of which are adequately covered without the use of LUA invocations.

Re: LUA help/ more detailed guide? video?

Posted: Fri Aug 14, 2020 7:29 pm
by nexusno2000
To get mileage out of Lua scripts, first you must understand how the scenario editor works and what it's limitations are, how the various campaign files fit together, and more.

I suppose I could make a YouTube or two, but I'm still very much learning, so I think I'll wait for a bit before I do so.

Re: LUA help/ more detailed guide? video?

Posted: Tue Aug 25, 2020 10:25 am
by o_t_d_x
nexusno2000 wrote: Thu Aug 13, 2020 8:04 pm It's not that difficult.

Use existing scripts as templates, and adjust to taste.

As more DLCs are added, you'll have more templates to work from.

It's time consuming at first, but once you get the hang of it, it's not that bad.
And how should i create a script that drops unit classes at pre defined positions at the map ? With a random number, so that not all positions are filled and that its different every time ?
The search for the coordinates alone would take masses of time. Because i have hundreds of possible drop zones in my pc1 mod, on EVERY map. In the old editor that was so simpel and fast: draw zones on the map with a few klicks, then pull down menu scripts, 5 sec. later the script is ready.

And i need maaaaaany of these scripts and other scripst on every map. It would be hell of work to do that without the old editor. How does that fit to the "easy to use" advertisment for the editor ? I bought pc2 to play MY content, its frustrating that i cant do that at the moment. Because transfering my highly complex pc1 mod to pc2 engine would be much work WITH the old editor. With the new its soooooooooooooooooooooooooooo much more work, that i dont dare even to start.

Re: LUA help/ more detailed guide? video?

Posted: Tue Aug 25, 2020 1:50 pm
by fluffybunnyuk
Ebro uses:-
function SpawnWave(player, zone, units)
local owner = world:GetPlayer(player)

local cur_hex = 1

-- Iterate through all units and spawn each one
for _,u in ipairs(units) do
-- Find the next vacant hex in the zone
while zone[cur_hex] do
hex = world:GetHex(zone[cur_hex])
if hex:GetUnit(0) == nil then break end -- found
cur_hex = cur_hex + 1
end

-- If we have run out of hexes in the zone, stop
if not zone[cur_hex] then return end

-- Create the unit in the free hex we've found
-- 1. Create and execute purchase action, use unit type, transport type and overstrength as parameters
local create_action = world:MakePurchaseAction(owner, u[1], u[2], u[3])
create_action.auxiliary = false -- spawn core units
create_action.cost = 0 -- don't take money for units we generate
create_action.faction = owner.factions[1] --set to first faction of owning player for created units
world:Exec(create_action)

-- 2. Create and execute deploy action, place the unit in the hex we've picked.
local unit = world:GetUnit(create_action.id)
deploy_action = world:MakeDeployAction(unit, zone[cur_hex])
world:Exec(deploy_action)

-- 3. Now modify the unit to set its experience to the value we need.
unit.experience = u[4]

-- 4. Now modify the unit to set its aggressiveness to the value we need.
player_aggressiveness = { 0, 85, 70, 70 }
unit.aggressiveness = player_aggressiveness[player+1]

end

end


With a bit of modification using a random number routine that'd do the job. I'm sure Kerensky would know.

Re: LUA help/ more detailed guide? video?

Posted: Tue Aug 25, 2020 9:34 pm
by Kerensky
You can very easily make a scenario without a single LUA script.

If you want complex things to happen, you do have to engage with the system though.

Re: LUA help/ more detailed guide? video?

Posted: Wed Aug 26, 2020 2:37 pm
by o_t_d_x
fluffybunnyuk wrote: Tue Aug 25, 2020 1:50 pm Ebro uses:-
function SpawnWave(player, zone, units)
local owner = world:GetPlayer(player)

local cur_hex = 1

-- Iterate through all units and spawn each one
for _,u in ipairs(units) do
-- Find the next vacant hex in the zone
while zone[cur_hex] do
hex = world:GetHex(zone[cur_hex])
if hex:GetUnit(0) == nil then break end -- found
cur_hex = cur_hex + 1
end

-- If we have run out of hexes in the zone, stop
if not zone[cur_hex] then return end

-- Create the unit in the free hex we've found
-- 1. Create and execute purchase action, use unit type, transport type and overstrength as parameters
local create_action = world:MakePurchaseAction(owner, u[1], u[2], u[3])
create_action.auxiliary = false -- spawn core units
create_action.cost = 0 -- don't take money for units we generate
create_action.faction = owner.factions[1] --set to first faction of owning player for created units
world:Exec(create_action)

-- 2. Create and execute deploy action, place the unit in the hex we've picked.
local unit = world:GetUnit(create_action.id)
deploy_action = world:MakeDeployAction(unit, zone[cur_hex])
world:Exec(deploy_action)

-- 3. Now modify the unit to set its experience to the value we need.
unit.experience = u[4]

-- 4. Now modify the unit to set its aggressiveness to the value we need.
player_aggressiveness = { 0, 85, 70, 70 }
unit.aggressiveness = player_aggressiveness[player+1]

end

end


With a bit of modification using a random number routine that'd do the job. I'm sure Kerensky would know.
Thanks for the advice, but thats exactly what i meant: its more work and harder to understand. I hoped to get basically the same editor with fewer bugs and more options. Old editor: drawing the zones on the map and script pull down menu f. script. Easy and fastly done.
Here: a very long text that i dont really understand. And i would need so many of these scripts for every map. My english isnt so good, its hard for me to explain what i mean. Its not as simple as dropping units in a little zone.
In the old editor i had for example:

zone zero: mines
zone one: infantry
zone two: tanks
zone tree: arty
zone four: air def.
zone five: pak
.
.
.
On my maps the units are mostly on the right side of the map (in the editor). (Mostly because some units are always at the same hex, when its important not to have randomness.) The actual positioning ON the map is done by the script, for most units.

So i have for example 40 minefields for zone zero. The mines are all on the right side in a line in the editor, but in the game the mines are spread randomly on the zone zero hexes. Since there are much more zero hexes, then mines, they are spread differently in every new game. So even i never know, where the mines are.
With lua i have to define the zones with some sort of coordinates. That alone means that i have tousands of coordinates to enter in the script. With the zones in the old editor i dont need to do that at all: I just search good ambush positions and klick the zone numbers on the hexes. Time needed: a few minutes for a map. Typing hundreds of coordinates for my kursk map f. example: many hours ? days ?

The same for infantry and all other weapon groups. So you can create defencive positions, only with zones. Sometimes you have maybe only one infantry holding a hill behind a bridge. If you start the map again, there could be the infantry again, but with arty and air defence behind it. Honestly: Its many years since i modded part one, i have to launch the old editor to see the details of my work. I simply dont remember everything. But i remember that playing it was much fun, because i never knew where the enemy is.

Re: LUA help/ more detailed guide? video?

Posted: Wed Aug 26, 2020 3:39 pm
by fluffybunnyuk
Ah well, sorry.
Theres pros and cons to every design decision for game editors, and scripting.
Having written code for over 35 years, i took to it like a duck to water. I appreciate the power of PzC2 scripting, and can go beyond the in-DLC code.
For those who dont code its going to be a rather big shock. But really its the future, something thats needed to deal with complexity.

So my recommendation is team up with someone who codes. You can do the design stuff, and they can do the script.

By the way i have a 60x60 normandy invasion map i created (painted on top of the real map). I use the same thing to alter deployment areas, pillbox locations, mine locations etc etc. Its great fun, and take hours, and hours, and days, and days to play...

Re: LUA help/ more detailed guide? video?

Posted: Fri Aug 28, 2020 9:47 am
by o_t_d_x
Yeah, my project is so big, it might be a good idea, to work with other people together. But even with help, why should "we" have so much work with coding, when the right tool (old editor with zones and pull down menu scripts) does it so much better and faster ? Without help i have only one option left: ignore the game till there are no more dlc s released and then i check the status of the editor. If its the same, then i stay with pc1. Still there are things i like better in pc1 and with my mod combined, its more fun then pc2.

Re: LUA help/ more detailed guide? video?

Posted: Fri Aug 28, 2020 10:29 am
by fluffybunnyuk
Simple solution seems to be that you should play Panzer Corps 1. Lifes too short to reinvent the wheel.

The zones feature should be added i think. Along with better documentation. I had to scan the binary to discover various script syntax i needed.
I think it was sidelined, due to people buying FM edition, and the need to push those DLC out in a reasonable time.
Now they are out , its probably worth petitioning for script/editor upgrades. I should get on that case too.

Re: LUA help/ more detailed guide? video?

Posted: Sat Aug 29, 2020 2:22 pm
by o_t_d_x
fluffybunnyuk wrote: Fri Aug 28, 2020 10:29 am Simple solution seems to be that you should play Panzer Corps 1. Lifes too short to reinvent the wheel.

The zones feature should be added i think. Along with better documentation. I had to scan the binary to discover various script syntax i needed.
I think it was sidelined, due to people buying FM edition, and the need to push those DLC out in a reasonable time.
Now they are out , its probably worth petitioning for script/editor upgrades. I should get on that case too.
Coding yourself might be the better solution for special, complex scripts. But the std. unit dropping scripts, the std. trigger scripts, the std. counterattack scripts etc., the old way is simply much faster. (and the new editor could make it even faster with a "copy script" function) I think the editor should have BOTH ways of scripting AND the zones. So you have the flexibility and power of coding AND the old way. Just imagine hundred complex maps with tousands of coordinates. Want to look for the coordinates, note them and then put em in the code ? How often do you make mistakes, doing that ? Then you have to check for the errors ..... Want that extra weeks of work ? I dont think so. Zones can save you soooo much time.
I think every modder wants to save time, if possible.


Another big bonus is that ALL the old PC1 modders could contribute. There wont be such a big and good modding community, if there is a LUA wall. Because many good designers are lousy programmers. And its said easily: go team up with somebody. The programmers i know are highly stressed guys who never would touch a computer after work, if possible.

Re: LUA help/ more detailed guide? video?

Posted: Tue Sep 01, 2020 8:21 am
by o_t_d_x
Kerensky wrote: Tue Aug 25, 2020 9:34 pm You can very easily make a scenario without a single LUA script.

If you want complex things to happen, you do have to engage with the system though.
I am absolutly NOT interested in single scenarios. The things i want, havent been complex in the old editor. They are only complex now, because the developer of the editor has thrown out the easy to use tools, like zones and pull down menu scripts.

I just want a tool that i can use to create campaigns like i did in pc1. And i am sure there are MANY modders, that feel the same. For the few guys who are capable of programming, like wookie, its great as it is. But the majority of the community isnt capable of programming. Otherwise we would have campaigns here, that were created by MANY people. How much campaign creators do we have at the moment ? Two ? Three ? It should be 30, 40 ......

Re: LUA help/ more detailed guide? video?

Posted: Fri Oct 16, 2020 2:22 pm
by Ljungen81
I totally agree with you o_d_t_x. If the developers cared about what the customers wanted they would develop a user friendly UI/layer so that ”normal people” can mod. I am seriously concerned about the developers lack of attention to their previous customers wishes. The responses in forums and on discord are dismissive and lacks the will to understand. The fact that PzC2 has dropped about 3000 concurrent players in 7 months while PzC1 are still going strong cements that the developers were wrong. I hope that this feedback doesnt get me banned but if so Please keep in mind that banning people that try to help you is not a winning tactic :)

Re: LUA help/ more detailed guide? video?

Posted: Sat Oct 17, 2020 1:13 pm
by o_t_d_x
The first two dlcs are average at best, compared to many pc1 mods.

(My first opinion was better, but now i have to say spain would be good, but the allied ai ruined it for me and the second dlc was so easy i never played it a second time: poland is too short, instead i have a boring finland and denmark map (the second finland map is good). Both dlcs and the main campaign suffer from near zero replayability, compared to my mod, where units are dropped differently every new playthrough. - so my conclusion is: i wont buy dlcs.)

So thats the reason for the lua wall. Who would buy these dlcs if there is a better alternative for free ?

In my case it would be no problem, because i dont release my mod ever. I just want my own personal second world war trip - and nobody can create that, except myself. And its mostly finished, but only for pc 1.