Page 1 of 1

problem with lua script - need help

Posted: Mon Mar 22, 2021 10:33 pm
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?

Re: problem with lua script - need help

Posted: Mon Mar 22, 2021 10:49 pm
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:

Re: problem with lua script - need help

Posted: Tue Mar 23, 2021 3:02 pm
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)?

Re: problem with lua script - need help

Posted: Tue Mar 23, 2021 3:26 pm
by cicciopastic
i tested it hotseat, i will send you my files tonight (i am working now) :cry:

thanks a lot

Re: problem with lua script - need help

Posted: Tue Mar 23, 2021 7:27 pm
by cicciopastic
Rudankort wrote: Tue Mar 23, 2021 3:02 pmRudankort
ok here are the files i use ... thank for your interest!

Re: problem with lua script - need help

Posted: Thu Mar 25, 2021 9:54 am
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