Code: Select all
elem.set_slider_minimum_maximum(0,25000)
elem.slider_value = global.entities[entity.unit_number].amount
(so the value i'm assigning is 100% correct)
(printing elem.slider_value after the creation also says "0")
Code: Select all
elem.set_slider_minimum_maximum(0,25000)
elem.slider_value = global.entities[entity.unit_number].amount
Code: Select all
/c function fluid_gui(player,entity,mode)
if player.gui.center["own_market_fluid_"..player.index.."_"..entity.unit_number] then
player.gui.center["own_market_fluid_"..player.index.."_"..entity.unit_number].destroy()
end
local elem
local recipe_height, recipe_width
recipe_height = 100
recipe_width = 405
local gui = player.gui.center.add{type="frame", name= "own_market_fluid_"..player.index.."_"..entity.unit_number, direction="vertical"}
gui.style.width= recipe_width
if mode == "buy" then
local selection_flow = gui.add{type= "flow",name = "selection_flow", direction = "horizontal"}
elem = selection_flow.add{type= "sprite-button",name = "owm_item_selector",style = "slot_button"}
elem.style.width = 50
elem.style.height = 50
local parameters_flow = selection_flow.add{type= "flow",name = "parameters_flow", direction = "vertical"}
local x_flow = parameters_flow.add{type= "flow",name = "x_flow"}
x_flow.style.horizontal_align = "right"
x_flow.style.width = recipe_width-70
x_flow.style.top_margin = -2
x_flow.style.top_padding = -5
x_flow.style.right_padding = -3
local temp = x_flow.add{type = "button", name = "own_fluid_sell", style = "icon_back_button", caption = "Sell" }
temp.style.top_margin = 5
local temp = x_flow.add{type = "button", name = "own_fluid_buy", style = "confirm_button", caption = "Buy" }
temp.style.top_margin = 5
temp.ignored_by_interaction = true
local temp = x_flow.add{type = "sprite-button", name = "own_fluid_close", sprite = "own_market_close"}
temp.style.width = 25
temp.style.height = 25
local amount_flow = parameters_flow.add{type= "flow",name = "amount_flow"}
elem = amount_flow.add{type= "label",name = "amount_caption"}
elem.caption = "Fill up to.."
elem.style.width = 70
elem = amount_flow.add{type= "slider",name = "owm_amount_selector"}
elem.style.top_margin=7
elem.style.width=recipe_width-210
elem.set_slider_minimum_maximum(0,25000)
elem.slider_value = 0
elem = amount_flow.add{type= "textfield",name = "owm_amount_field"}
elem.style.width = 60
elem.style.height = 25
elem.text = 0
elem.ignored_by_interaction = true
else
local selection_flow = gui.add{type= "flow",name = "selection_flow", direction = "horizontal"}
local parameters_flow = selection_flow.add{type= "flow",name = "parameters_flow", direction = "vertical"}
local x_flow = parameters_flow.add{type= "flow",name = "x_flow"}
x_flow.style.horizontal_align = "right"
x_flow.style.width = recipe_width-16
x_flow.style.top_margin = -2
x_flow.style.top_padding = -5
x_flow.style.right_padding = -3
local temp = x_flow.add{type = "button", name = "own_fluid_sell", style = "red_back_button", caption = "Sell" }
temp.style.top_margin = 5
temp.ignored_by_interaction = true
local temp = x_flow.add{type = "button", name = "own_fluid_buy", style = "forward_button", caption = "Buy" }
temp.style.top_margin = 5
local temp = x_flow.add{type = "sprite-button", name = "own_fluid_close", sprite = "own_market_close"}
temp.style.width = 25
temp.style.height = 25
end
player.opened = gui
end
Code: Select all
/c script.on_nth_tick(10, function() fluid_gui(game.players[1], game.players[1].character, "buy") end)