Lua ImGui

Андруша.

Известный
Автор темы
44
6
Привет. В общем такой вопрос:
Как сделать что бы в этом поле ввода было какое нибудь стандартное значение?
imgui.InputText(u8"Общая цена продажи.", pricemedss)

Весь код
script_name('AutoMeds') -- название скрипта
script_description('Command') -- описание скрипта

require "lib.moonloader" -- подключение библиотеки
local sampev = require 'lib.samp.events'
--
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
--local text_buffer = imgui.ImBuffer(256)

--colors
local c_sir = 0xFF6E6E6E
local c_white = "{E6E6E6}"
local c_red = "{FF5858}"
local c_sgreen = "{6DFC51}"
local c_green = "{04FE0D}"



local font_flag = require('moonloader').font_flag
local my_font = renderCreateFont('Verdana', 12, font_flag.BOLD + font_flag.SHADOW)

local inicfg = require 'inicfg'
local directIni = 'moonloader\\config\\automeds.ini'
local mainIni = inicfg.load(nil, directIni)--dsfadsfadsfdsfdsfds
--

local checked_radio = imgui.ImInt(1)
--local sstatus = imgui.ImBool(false)
--local n_rstatus = imgui.ImBool(false)
local combo_select = imgui.ImInt(0)

local sw, sh = getScreenResolution()




function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end

sampAddChatMessage("[AutoMeds] {6E6E6E}by {6DFC51}Загружен{6E6E6E}. {E6E6E6}/sam", 0xFFFCDB00)

_, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
nick = sampGetPlayerNickname(id)
---
sampRegisterChatCommand("sam", cmd_sam)
sampRegisterChatCommand("ch", cmd_ch)
--iniread
mainIni = inicfg.load(nil, directIni)
sstatus = mainIni.settings.sstatus
rstatus = mainIni.settings.rstatus
stabl = mainIni.settings.stabl
smon = mainIni.settings.smon
pricemeds = mainIni.settings.pricemeds
--
n_sstatus = imgui.ImBool(sstatus)
n_rstatus = imgui.ImBool(rstatus)
pricemedss = imgui.ImBuffer(256)


sampAddChatMessage(pricemeds, -1)


--
imgui.Process = false

while true do
wait(0)
if main_window_state.v == false then
imgui.Process = false
end


----
if n_sstatus.v == true then
--/

if n_rstatus.v == true then
renderFontDrawText(my_font,"Продано таблеток: {E6E6E6}"..stabl.."{6E6E6E} Сума: {E6E6E6}"..smon, 10, 280, c_sir)
end


--/////
function sampev.onServerMessage(color, text)
if string.find(text, "+plz") or string.find(text, "+здя") or string.find(text, "+pls") or string.find(text, "+зды")then
if text:find(".+%[%d+]") then
idsell = text:match(".+%[(%d+)]")
elseif text:find(".+%(%d+%)") then
idsell = text:match(".+%((%d+)%)")
end
nicksell = sampGetPlayerNickname(idsell)
if nick == nicksell then
return
else
_, Ped_ped = sampGetCharHandleBySampPlayerId(idsell)
x,y,z = getCharCoordinates(Ped_ped) --playerPed
x1,y1,z1 = getCharCoordinates(playerPed)
distance = getDistanceBetweenCoords3d(x, y, z, x1, y1, z1)
---------------
if distance < 4.5 then
---/

--
sampSendChat("/sellmeds "..nicksell.." "..pricemeds)
---/
else return end
end
end
--/
if string.find(text, "Сделка:") then
if text:match(".+%за $(%d+)%.") then
money = text:match(".+%за $(%d+)%.")/2
smon = money + smon
stabl = stabl + 1
mainIni.settings.smon = smon
mainIni.settings.stabl = stabl
inicfg.save(mainIni, directIni)
end
end
--
if string.find(text, "купить у тебя лекарство за") then
return false
end
if string.find(text, "предлагает сдать кровь. Набери /accept blood, чтобы начать процедуру") then
sampSendChat("/accept blood")
end
--/
end
end
--

end
end

function cmd_sam(arg)
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end

function cmd_ch()
sampAddChatMessage(pricemeds, -1)
end

function imgui.OnDrawFrame()
mainIni = inicfg.load(nil, directIni)
imgui.SetNextWindowSize(imgui.ImVec2(350, 300), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

imgui.Begin("AutoMeds by ", main_window_state)
--
imgui.Text(u8"Основные настройки")
imgui.Separator()
imgui.Checkbox(u8"Включить скрипт", n_sstatus)
mainIni.settings.sstatus = n_sstatus.v
imgui.Checkbox(u8"Включить рендер", n_rstatus)
mainIni.settings.rstatus = n_rstatus.v
imgui.Separator()
imgui.Text(u8"Цены")
imgui.Separator()
imgui.PushItemWidth(70)
imgui.InputText(u8"Общая цена продажи.", pricemedss)

mainIni.settings.pricemeds = pricemedss.v
pricemeds = pricemedss.v
imgui.Separator()
inicfg.save(mainIni, directIni)
--
imgui.End()

end
 

neverlane

t.me/neverlane00
Друг
1,000
1,136
  • Нравится
Реакции: Андруша.

Андруша.

Известный
Автор темы
44
6
Lua:
pricemedss = imgui.ImBuffer('standart value',256)
--или
pricemedss = imgui.ImBuffer(tostring(pricemeds),256)
при первом варианте просто выводит название переменной, а не значение
Но со вторым все отлично.
Благодарю)