Jump to content

Help on table


iiv03

Recommended Posts

hey, how do i make the table all the name on the right?

i use:

local nameTable = {"test1","test2"}



----
----
local offsetX = 0

		for i ,v in pairs(nameTable) do
		dxDrawText(v, referee.x*1.17, referee.y+20, sizeX+offsetX, sizeY ,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "left","top",false)
		end
		offsetX = offsetX + referee.x

i tried to move it on some coordinates and it didn't work

Link to comment
  On 06/12/2019 at 11:00, stPatrick said:

ipairs instead of pairs at line 9.

Expand  


--
local nameTable = {"test1","test2"}
--
-- in function
	local textmoveX = sX*0.3
	local offsetX = 0
		for i ,v in ipairs(nameTable) do
		dxDrawText(v, referee.x + textmoveX, referee.y, sizeX+offsetX, sizeY ,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
		end
		offsetX = referee.x + textmoveX
--end

hey stPatrick, there is no difference when i'm put iparis

 

 

EDIT::

 

okay i did something wrong and I fixed it

i put offsetX = etc. out loop so that's why not work ?

Edited by xFabel
Link to comment
  • Moderators
  On 06/12/2019 at 11:41, xFabel said:


--
local nameTable = {"test1","test2"}
--
-- in function
	local textmoveX = sX*0.3
	local offsetX = 0
		for i ,v in ipairs(nameTable) do
		dxDrawText(v, referee.x + textmoveX, referee.y, sizeX+offsetX, sizeY ,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
		end
		offsetX = referee.x + textmoveX
--end

hey stPatrick, there is no difference when i'm put iparis

Expand  

I don't know whats the problem because I don't know the full code and I don't really understand what you want to do.

Maybe the offsetX, put it inside the for loop, after dxDrawText.

Link to comment
  On 06/12/2019 at 11:46, stPatrick said:

I don't know whats the problem because I don't know the full code and I don't really understand what you want to do.

Maybe the offsetX, put it inside the for loop, after dxDrawText.

Expand  

i make other table but here in debugscript tell me table is nil

local offsetY = 0
-- table with column
local referees = {
	["Status"] = {
		columns = {
			{"Running", "test"},
			{"Free Round", "test"},
			{"Waiting", "test"},
			{"Paused", "test"},
			{"Training", "test"},
		}
	}
-- to make loop of table
  for i, v in pairs(referees) do
	for i, column in pairs(v.columns) do
		column.height = referee.y * (tonumber(column[3]) or 0)
	end
end
-- render column when panel showing
function referee.renderColumns(columns, offsetY)
		for i, column in ipairs (columns) do
		dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
		offsetY = offsetY + column.height
end
end
 

to 'iparis' (table expected, got nil) at line 20 (render column)

where wrong?

Link to comment
  • Moderators
  On 06/12/2019 at 12:55, xFabel said:

i make other table but here in debugscript tell me table is nil

local offsetY = 0
-- table with column
local referees = {
	["Status"] = {
		columns = {
			{"Running", "test"},
			{"Free Round", "test"},
			{"Waiting", "test"},
			{"Paused", "test"},
			{"Training", "test"},
		}
	}
-- to make loop of table
  for i, v in pairs(referees) do
	for i, column in pairs(v.columns) do
		column.height = referee.y * (tonumber(column[3]) or 0)
	end
end
-- render column when panel showing
function referee.renderColumns(columns, offsetY)
		for i, column in ipairs (columns) do
		dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
		offsetY = offsetY + column.height
end
end
 

to 'iparis' (table expected, got nil) at line 20 (render column)

Expand  

 

Where you call renderColumns?

Edited by stPatrick
Link to comment
  On 06/12/2019 at 13:05, stPatrick said:

Where you call renderColumns?

Expand  
	function Opendx()
	referee.ShowDxPanel = not referee.ShowDxPanel
	if referee.ShowDxPanel then
		referee.tick = getTickCount()
		removeEventHandler("onClientRender", root, referee.renderColumns)
		showCursor(true)
		addEventHandler("onClientRender", root, referee.renderColumns)
		--addEventHandler("onClientClick", root, onClick)
	else
		--removeEventHandler("onClientClick", root, onClick)
		showCursor(false)
		referee.tick = getTickCount()
  	end
end
bindKey("f2", "down", Opendx)

 

Link to comment
  • Moderators
  On 06/12/2019 at 13:06, xFabel said:
	function Opendx()
	referee.ShowDxPanel = not referee.ShowDxPanel
	if referee.ShowDxPanel then
		referee.tick = getTickCount()
		removeEventHandler("onClientRender", root, referee.renderColumns)
		showCursor(true)
		addEventHandler("onClientRender", root, referee.renderColumns)
		--addEventHandler("onClientClick", root, onClick)
	else
		--removeEventHandler("onClientClick", root, onClick)
		showCursor(false)
		referee.tick = getTickCount()
  	end
end
bindKey("f2", "down", Opendx)

 

Expand  

 

Use like this

-- render column when panel showing
function referee.renderColumns()
    local offsetY = 0
    for i, column in ipairs (referee["status"].columns) do
        dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
        offsetY = offsetY + column.height
    end
end

 

Link to comment

in first, i'm test dxdrawtext like this

function referee.renderColumns()
		--for i, column in ipairs (columns) do
		dxDrawText("test", referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
	--	offsetY = offsetY + column.height
--end
end

and work but when put table give me error

  On 06/12/2019 at 13:09, stPatrick said:

 

Use like this


-- render column when panel showing
function referee.renderColumns()
    local offsetY = 0
    for i, column in ipairs (referee["status"].columns) do
        dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
        offsetY = offsetY + column.height
    end
end

 

Expand  

hm does not work

attempt to index field 'status' (a nil value)

Link to comment
  On 06/12/2019 at 13:12, stPatrick said:

 

uppercase letter S, I missed

Expand  

have question when i moved the coordinates and they do not move why?

 

        dxDrawText(column[1], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + offsetY,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
        offsetY = offsetY + referee.y

it's not move like this

 

Running

Waiting

etc..

Edited by xFabel
Link to comment
  • Moderators
  On 06/12/2019 at 13:44, xFabel said:

have question when i moved the coordinates and they do not move why?

 

        dxDrawText(column[1], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + offsetY,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
        offsetY = offsetY + referee.y

it's not move like this

 

Running

Waiting

etc..

Expand  

 

-- render column when panel showing
function referee.renderColumns()
    for i, column in ipairs (referee["Status"].columns) do
        dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
        offsetY = offsetY + column.height
    end
end

Remove local offsetY = 0

Link to comment
  On 06/12/2019 at 13:55, stPatrick said:

 


-- render column when panel showing
function referee.renderColumns()
    for i, column in ipairs (referee["Status"].columns) do
        dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
        offsetY = offsetY + column.height
    end
end

Remove local offsetY = 0

Expand  

other question ^^

how make color in table like "Running" i wanna give color green and "Waiting" give color orange etc... is there a way?

Link to comment
  • Moderators
  On 06/12/2019 at 14:27, xFabel said:

other question ^^

how make color in table like "Running" i wanna give color green and "Waiting" give color orange etc... is there a way?

Expand  

 

First, define colors in the table:

local referees = {
	["Status"] = {
		columns = {
			{"Running", "test", {255,0,0}},
			{"Free Round", "test", {255,0,0}},
			{"Waiting", "test", {255,0,0}},
			{"Paused", "test", {255,0,0}},
			{"Training", "test", {255,0,0}},
		}
	}

 

And use like this in render:

-- render column when panel showing
function referee.renderColumns()
    for i, column in ipairs (referee["Status"].columns) do
        dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(column[3][1],column[3][2],column[3][3],255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false)
        offsetY = offsetY + column.height
    end
end

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...