problem with lua script - need help

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: 173
Joined: Mon Oct 26, 2015 9:01 pm

problem with lua script - need help

Post by cicciopastic »

hi guys,

i implemented a game for two human players (payer 1 vs player 2) .... on turn 2 a message must appear and a unit must appear: below i copied my lua script
when i test the game: on turn 2 the ESMilitia appears correctly, but no message is shown (!?) and on the next player turn the "end turn" button is disabled (!?) ... the only way to end turn is to hit alt+e ... what do you think? ...

function turnodue()
return world.round == 2
end


string_1 = NSLOCTEXT("spagna_last", "string_1", "ATTENZIONE: sono arrivati rinforzi italiani a Cadiz")


function italiani1()

TutorialMessage(string_1)

local giocatore = world:GetPlayer(0) -- primo giocatore
local esagono = {15,52} -- esagono di piazzamento
local unita = "ESMilitia" -- quale unità
local create_action = world:MakePurchaseAction(giocatore, unita, "", -5)
create_action.auxiliary = false
create_action.cost = 0 -- costo zero
world:Exec(create_action)

local unit = world:GetUnit(create_action.id)
local hex = world:GetHex(esagono)
if (hex:GetUnit(0) == nil) then -- se l'esagono è vuoto

deploy_action = world:MakeDeployAction(unit,esagono)
world:Exec(deploy_action)
end

end

second question: suppose i would like to make the same on player 2 round ... how should i correct this?
cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 173
Joined: Mon Oct 26, 2015 9:01 pm

Re: problem with lua script - need help

Post by cicciopastic »

one more thing: on player 2 second turn i even noticed that if i click on next unit button it cycles player 1 units (why!?) ... very strange

and, even stranger, if i perform that action on turn one everything is ok!!!!! :shock: :shock: :shock:
Rudankort
FlashBack Games
FlashBack Games
Posts: 3836
Joined: Sat Aug 21, 2010 2:23 pm
Contact:

Re: problem with lua script - need help

Post by Rudankort »

Can you post here this whole scenario (pz2scn and lua files)? We'll have a look. Also: how do you test it exactly (hotseat, PBEM++, online)?
cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 173
Joined: Mon Oct 26, 2015 9:01 pm

Re: problem with lua script - need help

Post by cicciopastic »

i tested it hotseat, i will send you my files tonight (i am working now) :cry:

thanks a lot
cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 173
Joined: Mon Oct 26, 2015 9:01 pm

Re: problem with lua script - need help

Post by cicciopastic »

Rudankort wrote: Tue Mar 23, 2021 3:02 pmRudankort
ok here are the files i use ... thank for your interest!
Attachments
spagna_last.zip
(111.7 KiB) Downloaded 76 times
cicciopastic
Administrative Corporal - SdKfz 232 8Rad
Administrative Corporal - SdKfz 232 8Rad
Posts: 173
Joined: Mon Oct 26, 2015 9:01 pm

Re: problem with lua script - need help

Post by cicciopastic »

hi guys,

i would like to let anybody who is downloding my scenario know, that i did it just for my fun, it is not complete and not tested so plz be kind on your opinion, but if you have any suggestion, or want to help you are more than welcome.

I would even kindly ask to send me a notice if you want to download it and give me a brief feedback. tks
Post Reply

Return to “Panzer Corps 2 Scenario Design”