help with lua scripts 2

A forum to discuss custom scenarios, campaigns and modding in general.

Moderator: Panzer Corps 2 Moderators

Post Reply
cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 166
Joined: Mon Oct 26, 2015 9:01 pm

help with lua scripts 2

Post by cicciopastic » Tue Apr 13, 2021 11:18 am

Hi guys,

two questions: i am working on a player vs player game and need the following settings

1) i need a city to start to provide prestige (say 50 every turn) once it is captured by player 1: is this possible? How do I do that?
2) i have a very busy reinforcement calendar and i set the reinforcement calendar by turn: this way all reinforcement arrive on player 1 round. Suppose I would like that players 2 reinforcement would arrive on his own round .... is there a way to do this?
tks for help, ciao Pietro

cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 166
Joined: Mon Oct 26, 2015 9:01 pm

Re: help with lua scripts 2

Post by cicciopastic » Thu Apr 22, 2021 8:34 pm

for the first question i found the following solution:

1) i need a city to start to provide prestige (say 50 every turn) once it is captured by player 1: is this possible? How do I do that?

i set Badajos prestige per turn to 50, then i wrote the followiong piece of script where player 1 is the owner of Badajos at the beginning of the game


local badajos = {14,38}
local hex = world:GetHex(badajos)

if hex.owner == 1 then
local player = world:GetPlayer(1)
player.prestige = player.prestige - 50
end

cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 166
Joined: Mon Oct 26, 2015 9:01 pm

Re: help with lua scripts 2

Post by cicciopastic » Thu Apr 22, 2021 10:06 pm

Sorry guys :oops:

i have to restate my lua scriptig: one possible correct solution to question: i need a city to start to provide prestige (say 50 every turn) once it is captured by player 0: is this possible? How do I do that?

My solution is the following: count must be set to 0, Action to endturnaction and set city (Badajos in my example) prestige per turn to 50

LUA SCRIPT
una_volta = 0 -- this variable is needed because the condition will be tested twice a round as i set Action to endturnaction.

function effetto_Badajos()
-- Badajos non attiva
local badajos = {14,38}
local hex = world:GetHex(badajos)
if hex.owner == 1 and una_volta == 0 then
local player = world:GetPlayer(1)
player.prestige = player.prestige - 50
una_volta = una_volta+1
else
una_volta = 0
end
end


hope this may help anybody else

Post Reply

Return to “Panzer Corps 2 Scenario Design”