mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Fix amount textbox validation & event
This commit is contained in:
@@ -89,8 +89,9 @@ toggle-section-collapse-tooltip=Collapse Section
|
|||||||
toggle-entity-tooltip=Toggle the autofill of __1__ entity (overwrites autofill settings of the entity)
|
toggle-entity-tooltip=Toggle the autofill of __1__ entity (overwrites autofill settings of the entity)
|
||||||
toggle-tooltip=Toggle the autofill of __1__ into the __2__ slot of entities
|
toggle-tooltip=Toggle the autofill of __1__ into the __2__ slot of entities
|
||||||
amount-tooltip=Amount of items it will try and put into the __1__ slot of __2__
|
amount-tooltip=Amount of items it will try and put into the __1__ slot of __2__
|
||||||
confirmed=Set autofill amount to __1__ __2__ for __3__
|
invalid=Set autofill amount to the maximum __1__ __2__ for __3__
|
||||||
filled=Autofilled the __1__ with __2__ __3__
|
filled=Autofilled the __1__ with __2__ __3__
|
||||||
|
|
||||||
[warp-list]
|
[warp-list]
|
||||||
main-caption=Warp List
|
main-caption=Warp List
|
||||||
main-tooltip=Warp List; Must be within __1__ tiles to use
|
main-tooltip=Warp List; Must be within __1__ tiles to use
|
||||||
|
|||||||
@@ -157,7 +157,10 @@ Gui.element(function(event_trigger, parent, item)
|
|||||||
type = 'textfield',
|
type = 'textfield',
|
||||||
text = item.amount,
|
text = item.amount,
|
||||||
tooltip = {'autofill.amount-tooltip', item.category, rich_img('item', item.entity) },
|
tooltip = {'autofill.amount-tooltip', item.category, rich_img('item', item.entity) },
|
||||||
clear_and_focus_on_right_click = true
|
clear_and_focus_on_right_click = true,
|
||||||
|
numeric = true,
|
||||||
|
allow_decimal = false,
|
||||||
|
allow_negative = false
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
:style{
|
:style{
|
||||||
@@ -165,7 +168,10 @@ end)
|
|||||||
height = 31,
|
height = 31,
|
||||||
padding = -2
|
padding = -2
|
||||||
}
|
}
|
||||||
:on_confirmed(function(player, element, _)
|
:on_text_changed(function(player, element, _)
|
||||||
|
local value = tonumber(element.text)
|
||||||
|
if not value then value = 0 end
|
||||||
|
local clamped = math.clamp(value, 0, 1000)
|
||||||
local item_name = string.sub(element.parent.name, 1 + string.len('toggle-setting-'), -1)
|
local item_name = string.sub(element.parent.name, 1 + string.len('toggle-setting-'), -1)
|
||||||
local entity_name = element.parent.parent.parent.parent.name
|
local entity_name = element.parent.parent.parent.parent.name
|
||||||
if not autofill_player_settings[player.name] then return end
|
if not autofill_player_settings[player.name] then return end
|
||||||
@@ -173,8 +179,12 @@ end)
|
|||||||
if not setting then return end
|
if not setting then return end
|
||||||
local item = setting.items[item_name]
|
local item = setting.items[item_name]
|
||||||
if not item then return end
|
if not item then return end
|
||||||
item.amount = tonumber(element.text)
|
item.amount = clamped
|
||||||
player.print({'autofill.confirmed', item.amount, rich_img('item', item.name), rich_img('entity', entity_name) })
|
if clamped ~= value then
|
||||||
|
element.text = clamped
|
||||||
|
player.print({'autofill.invalid', item.amount, rich_img('item', item.name), rich_img('entity', entity_name) })
|
||||||
|
return
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Autofill setting, contains a button and a textbox
|
--- Autofill setting, contains a button and a textbox
|
||||||
|
|||||||
Reference in New Issue
Block a user