Got some code from it from these prompts:
1) can you design and create a warzone mod that uses special units
2) warlight mods are written in lua
3) do you have any examples of warlight special units
4) can you link me the special units page on the warlight wiki
5) can you link the special unit page from warlight wiki
6) can you link the Mod API Reference pages from warlight wiki
7) run a search of Mod API Reference in warlight wiki
8) here's information about special units when making a warlight mod https://www.warzone.com/wiki/Mod_API_Reference:SpecialUnit
9) can you make an example of a warlight special unit when making a mod
10) you must use mod hooks for warlight mods to take affect. here's information about mod hooks https://www.warzone.com/wiki/Mod_Hooks
11) 'onTurnStart' should be Server_AdvanceTurn_Start
12) addHook is not a function. should be in a file like Server_AdvanceTurn.lua for the Server_AdvanceTurn_Start hook
13) addHook is not a function
14) the function signature for Server_AdvanceTurn_Start is incorrect. should be Server_AdvanceTurn_Start(game, addNewOrder)
15) can i have a reminder of what the ninja special unit code looks like so far
16) you've missed the Server_AdvanceTurn_Start part
17) the stealth ability of a ninja cannot be implemented as warlight mods prevent changing fog levels
18) let's make the addUnitType function
19) can you make the settings for the ninja be configurable
20) what i mean is use the Client_PresentConfigureUI(rootParent) hook in the Client_PresentConfigureUI.lua file to let the user customise the ninja
21) the UI.CreateForm is not built into the warzone mod api
22) here's which UI options are allowed in the warlight mod framework https://www.warzone.com/wiki/Mod_API_Reference:UI
23) can you try making the Client_PresentConfigureUI hook again?
24) WG is not defined in warlight mods
25) WG is nil
26) to save the ninja settings we can use the Client_SaveConfigureUI(alert) hook in the Client_SaveConfigureUI.lua file
27) we dont need to save alert as part of the settings
28) we can add settings to warlight mods by forking https://github.com/DanWaLes/DanWaLes.github.io/tree/master/Auto_Settings_Files_Documentation/code and defining the settings for the mod in the __settings.lua file. documentation of the framework can be found in https://danwales.github.io/Auto_Settings_Files_Documentation/. generates the Client_PresentSettingsUI.lua, Client_SaveConfigureUI .lua and Client_PresentConfigureUI.lua files that are needed to change, save and display the settings of a mod to a user
29) can you make the ninja settings use the Auto Settings Files framework?
30) User your syntax of the file is incorrect, see the documentation https://danwales.github.io/Auto_Settings_Files_Documentation/
31) should use the addSetting function
Arguments:
name - string - name of the setting. all names must be unique to function correctly
label - string - summery of what the setting does
inputType - one of 'int', 'float', 'bool' or 'text'
defaultValue - same type as inputType - the default value for the setting's value in Client_PresentConfigureUI
otherProps - table or nil - if table then these keys are optional:
help - function(parent) - gives a more detailed explanation of what the setting does when a help button (?) is clicked
labelColor - string - color of the setting's label text
32) color names are not supported in warlight mods. can use hex colors instead
33) Depending on the inputType certain keys on otherProps are forced and some become optional
int
Forced keys:
minValue - number - the lowest the setting's value can be
maxValue - number - the highest the setting's value can be while using the setting slider
Optional keys:
absoluteMax - number - allows user to enter a higher number than maxValue
float
Forced keys:
dp - number - the number of decimal places to round the setting's value when saving the settings
minValue - number - the lowest the setting's value can be
maxValue - number - the highest the setting's value can be while using the setting slider
Optional keys:
absoluteMax - number - allows user to enter a higher number than maxValue
bool
Optional keys:
subsettings - table or nil. if table then is an array of setting
text
Optional keys:
placeholder - string - the placeholder text
charLimit - number - the maximum number of characters that can be entered
34) can we add the minValue, maxValue and or absoluteMax
35) can we try doing this for all of the ninja's settings
36) thanks
37) remind me what the current ninja code is
38) what does the settings file look like
39) could do with a help function
40) which messages have i sent so far in this conversation
41) can you add the help function to all the settings
Code
Server_AdvanceTurn.lua
-- Load Ninja settings from the framework
local ninjaSettings = Warzone.Settings.NinjaSettings
-- Function to apply custom Ninja settings
function applyCustomNinjaSettings(territory)
if ninjaSettings then
territory.NumArmies.NumArmies[game.ServerGame.Settings.Armies[ninjaSettings.name]].SetArmies(ninjaSettings.move)
-- Add similar logic for attack and defense
end
end
-- In the Server_AdvanceTurn_Start hook, apply the custom settings
function Server_AdvanceTurn_Start(game, addNewOrder)
for _, territory in pairs(game.ServerGame.LatestTurnStanding.Territories) do
applyCustomNinjaSettings(territory)
end
end
__settings.lua
-- Define Ninja settings
Warzone:addSetting("NinjaName", "Name of Ninja", "text", {
defaultValue = "Ninja",
placeholder = "Enter a name for the Ninja",
charLimit = 20, -- Maximum number of characters
help = function(parent)
local helpText = UI.CreateLabel(parent)
helpText:SetText("Enter the name for your Ninja unit. This name will be displayed in the game.")
helpText:SetColor("#FFFFFF") -- Hexadecimal color code for white
end
})
Warzone:addSetting("NinjaMove", "Ninja's Movement Range", "int", {
defaultValue = 2,
minValue = 1, -- Minimum allowed value
maxValue = 10, -- Maximum allowed value using the setting slider
absoluteMax = 15, -- Optional: Allows users to enter a value higher than maxValue
help = function(parent)
local helpText = UI.CreateLabel(parent)
helpText:SetText("Customize the Ninja's movement range. This affects how far the Ninja can move on the map.")
helpText:SetColor("#FFFFFF") -- Hexadecimal color code for white
end
})
Warzone:addSetting("NinjaAttack", "Ninja's Attack Strength", "int", {
defaultValue = 4,
minValue = 1, -- Minimum allowed value
maxValue = 10, -- Maximum allowed value using the setting slider
absoluteMax = 15, -- Optional: Allows users to enter a value higher than maxValue
help = function(parent)
local helpText = UI.CreateLabel(parent)
helpText:SetText("Adjust the Ninja's attack strength. This value determines the Ninja's combat effectiveness.")
helpText:SetColor("#FFFFFF") -- Hexadecimal color code for white
end
})
Warzone:addSetting("NinjaDefense", "Ninja's Defense Strength", "int", {
defaultValue = 3,
minValue = 1, -- Minimum allowed value
maxValue = 10, -- Maximum allowed value using the setting slider
absoluteMax = 15, -- Optional: Allows users to enter a value higher than maxValue
help = function(parent)
local helpText = UI.CreateLabel(parent)
helpText:SetText("Set the Ninja's defense strength. This affects the Ninja's ability to resist enemy attacks.")
helpText:SetColor("#FFFFFF") -- Hexadecimal color code for white
end
})