Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onStart()
- PrepDialog(200.0, 200.0)
- ReceiveDialog(user) --as there is no current turn before turn execution start, must choose a user to receive dialog
- PrepText('{Localization InterfaceStrings HelloWorld}', 'Notice')
- PrepText('{Localization InterfaceStrings HelloWorld2}', 'Notice2')
- PrepText('{Localization InterfaceStrings PlusRed}', 'PlusRed')
- AddFuncPrevText('PlusRed', true, true) --1st arg is funcname
- --2nd arg is if whole text is pressable, 3rd arg true for lclick, false for rclick
- --2nd and 3rd args are true by default and can be skipped
- BindIgnorePrevTextFunc() --pressing on PlusRed func will not close the dialog anymore
- PrepText('{Localization InterfaceStrings MinusRed}', 'MinusRed')
- AddFuncPrevText('MinusRed')
- BindIgnorePrevTextFunc()
- PrepText('{Localization InterfaceStrings PlusBlue}', 'PlusBlue')
- AddFuncPrevText('PlusBlue')
- BindIgnorePrevTextFunc()
- PrepText('{Localization InterfaceStrings MinusBlue}', 'MinusBlue')
- AddFuncPrevText('MinusBlue')
- BindIgnorePrevTextFunc()
- PrepButton('onStartProper', 50.0, 30.0, 'GenericAccept')
- BindKeyPrevButton(false)
- FormFulldialog() --creates VN-like dialog at the bottom of the screen
- end
- function PlusRed()
- PlusUnit('Team1')
- end
- function PlusBlue()
- PlusUnit('Team0')
- end
- function PlusUnit(teamName)
- local ghosts = GetUnitGhosts()
- if ghosts[1] != nil then --if there are ghost units - despawned units
- local hexes = GetFreeHexes("SpawnPoint " .. teamName) --finding all free hexes of team's spawn point
- if hexes[1] == nil then
- hexes = GetFreeHexes() --if no free hexes, spawn in the world randomly
- end
- local randUp = 0
- for i in ipairs(hexes) do
- randUp = i
- end
- MoveUnit(hexes[RandomInt(randUp) + 1], ghosts[1]) --ghost unit must be "placed" in valid hex beforehand
- --adjusting random by +1 because lua starts arrays from 1
- ChangeUnitTeam(teamName, ghosts[1]) --assigning new team
- EmbodyGhUnit(ghosts[1]) --giving new body to a ghost unit
- ForceFloat('init', RandomFloat(9.0, 12,0), ghosts[1])
- else
- SpawnUnit('UnitBaseStats', 'BaseClass', teamName)
- ForceFloat('init', RandomFloat(9.0, 12,0))
- end
- end
- function MinusRed()
- MinusUnit('Team1')
- end
- function MinusBlue()
- MinusUnit('Team0')
- end
- function MinusUnit(teamName)
- local units = GetUnits(teamName)
- if (units[1] != nil) then
- DestroyObject(units[1])
- end
- end
- function onStartProper()
- Start()
- --game will start processing turns when onStart()'s thread ends
- --can be used to give player some map-specific options, show some dialogs, story, etc.
- --scripts that use turn execution-reliant commands will be ignored
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement