Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added string conversion to the slider value #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -415,60 +415,60 @@ local gui_change_handlers = {
local settings = global[event.player_index]
event.element.slider_value = math.floor(event.element.slider_value)
settings.x = event.element.slider_value
event.element.parent.artillery_bombardment_x_textbox.text = event.element.slider_value
event.element.parent.artillery_bombardment_x_textbox.text = tostring(event.element.slider_value)
end,
artillery_bombardment_x_textbox = function(event)
local settings = global[event.player_index]
if tonumber(event.element.text) and math.floor(tonumber(event.element.text)) >= 1 then
settings.x = math.floor(tonumber(event.element.text))
event.element.parent.artillery_bombardment_x_slider.slider_value = tonumber(event.element.text)
elseif not tonumber(event.element.text) and string.len(event.element.text) > 0 then
event.element.text = settings.x or event.element.parent.artillery_bombardment_x_slider.slider_value
event.element.text = tostring(settings.x or event.element.parent.artillery_bombardment_x_slider.slider_value)
end
end,
artillery_bombardment_y_slider = function(event)
local settings = global[event.player_index]
event.element.slider_value = math.floor(event.element.slider_value)
settings.y = event.element.slider_value
event.element.parent.artillery_bombardment_y_textbox.text = event.element.slider_value
event.element.parent.artillery_bombardment_y_textbox.text = tostring(event.element.slider_value)
end,
artillery_bombardment_y_textbox = function(event)
local settings = global[event.player_index]
if tonumber(event.element.text) and math.floor(tonumber(event.element.text)) >= 1 then
settings.y = math.floor(tonumber(event.element.text))
event.element.parent.artillery_bombardment_y_slider.slider_value = tonumber(event.element.text)
elseif not tonumber(event.element.text) and string.len(event.element.text) > 0 then
event.element.text = settings.y or event.element.parent.artillery_bombardment_y_slider.slider_value
event.element.text = tostring(settings.y or event.element.parent.artillery_bombardment_y_slider.slider_value)
end
end,
artillery_bombardment_column_slider = function(event)
local settings = global[event.player_index]
event.element.slider_value = math.floor(event.element.slider_value)
settings.col_count = event.element.slider_value
event.element.parent.artillery_bombardment_column_textbox.text = event.element.slider_value
event.element.parent.artillery_bombardment_column_textbox.text = tostring(event.element.slider_value)
end,
artillery_bombardment_column_textbox = function(event)
local settings = global[event.player_index]
if tonumber(event.element.text) and math.floor(tonumber(event.element.text)) >= 1 then
settings.col_count = math.floor(tonumber(event.element.text))
event.element.parent.artillery_bombardment_column_slider.slider_value = tonumber(event.element.text)
elseif not tonumber(event.element.text) and string.len(event.element.text) > 0 then
event.element.text = settings.col_count or event.element.parent.artillery_bombardment_column_slider.slider_value
event.element.text = tostring(settings.col_count or event.element.parent.artillery_bombardment_column_slider.slider_value)
end
end,
artillery_bombardment_radius_slider = function(event)
local settings = global[event.player_index]
event.element.slider_value = math.floor(event.element.slider_value)
settings.radius = event.element.slider_value
event.element.parent.artillery_bombardment_radius_textbox.text = event.element.slider_value
event.element.parent.artillery_bombardment_radius_textbox.text = tostring(event.element.slider_value)
end,
artillery_bombardment_radius_textbox = function(event)
local settings = global[event.player_index]
if tonumber(event.element.text) and math.floor(tonumber(event.element.text)) >= 0 then
settings.radius = math.floor(tonumber(event.element.text))
event.element.parent.artillery_bombardment_radius_slider.slider_value = tonumber(event.element.text)
elseif not tonumber(event.element.text) and string.len(event.element.text) > 0 then
event.element.text = settings.radius or event.element.parent.artillery_bombardment_radius_slider.slider_value
event.element.text = tostring(settings.radius or event.element.parent.artillery_bombardment_radius_slider.slider_value)
end
end
}
Expand Down