delta
Contributors
Posts: 29
|
Post by delta on Jan 14, 2021 2:38:16 GMT
I have a script that contains 50 or so different regions, so I have regions all over the place, what's a good way to keep track or organize regions, should I separate them into a different file?
|
|
|
Post by Exilereven on Jan 14, 2021 5:57:34 GMT
I have a script that contains 50 or so different regions, so I have regions all over the place, what's a good way to keep track or organize regions, should I separate them into a different file? have you tried just using tables? at the beginning put REG = { region_1 = Region(x,y,h,w), region_2 = Region(x,y,h,w), region_3 = Region(x,y,h,w), } then you can call it like this REG.region_1:exists('img.png') then they will all be nice and neat. or put them all in a seperate lua file and use dofile and load it at the beginning of your script, so you can keep the regions file by itslef for ease of use to see it when you open it. hooe this helps.
|
|
delta
Contributors
Posts: 29
|
Post by delta on Jan 19, 2021 23:12:08 GMT
I have a script that contains 50 or so different regions, so I have regions all over the place, what's a good way to keep track or organize regions, should I separate them into a different file? have you tried just using tables? at the beginning put REG = { region_1 = Region(x,y,h,w), region_2 = Region(x,y,h,w), region_3 = Region(x,y,h,w), } then you can call it like this REG.region_1:exists('img.png') then they will all be nice and neat. or put them all in a seperate lua file and use dofile and load it at the beginning of your script, so you can keep the regions file by itslef for ease of use to see it when you open it. hooe this helps. That does look better, thank you, that shouldn't slow do my script correct? I think a read that a dofile would just have to run once, I believe
|
|
|
Post by Exilereven on Jan 19, 2021 23:16:57 GMT
have you tried just using tables? at the beginning put REG = { region_1 = Region(x,y,h,w), region_2 = Region(x,y,h,w), region_3 = Region(x,y,h,w), } then you can call it like this REG.region_1:exists('img.png') then they will all be nice and neat. or put them all in a seperate lua file and use dofile and load it at the beginning of your script, so you can keep the regions file by itslef for ease of use to see it when you open it. hooe this helps. That does look better, thank you, that shouldn't slow do my script correct? I think a read that a dofile would just have to run once, I believe think of it as pre loading, not running. a dofile just loads everything in it before hand.
|
|
delta
Contributors
Posts: 29
|
Post by delta on Jan 19, 2021 23:21:33 GMT
That does look better, thank you, that shouldn't slow do my script correct? I think a read that a dofile would just have to run once, I believe think of it as pre loading, not running. a dofile just loads everything in it before hand. Thanks for your help!, one last question, Is there issues with creating scripts with phones that are fullscreen natively, no camera notches and no nav bar? Creating on a Redmi K20 how would I make sure my script would work on other phones? immersive would be false on mine but what about there's?
|
|
|
Post by AnkuLua on Jan 20, 2021 8:03:56 GMT
think of it as pre loading, not running. a dofile just loads everything in it before hand. Thanks for your help!, one last question, Is there issues with creating scripts with phones that are fullscreen natively, no camera notches and no nav bar? Creating on a Redmi K20 how would I make sure my script would work on other phones? immersive would be false on mine but what about there's? For notch, you can refer to the autoGameArea() and related API reference. ankulua.boards.net/thread/7/settings#autoGameAreaAlso refer to following thread for writing script for all wide screens. ankulua.boards.net/thread/1286/skill-write-scripts-wide-screens
|
|
|
Post by crossa on Feb 4, 2021 5:56:07 GMT
I have a script that contains 50 or so different regions, so I have regions all over the place, what's a good way to keep track or organize regions, should I separate them into a different file? have you tried just using tables? at the beginning put REG = { region_1 = Region(x,y,h,w), region_2 = Region(x,y,h,w), region_3 = Region(x,y,h,w), } then you can call it like this REG.region_1:exists('img.png') then they will all be nice and neat. or put them all in a seperate lua file and use dofile and load it at the beginning of your script, so you can keep the regions file by itslef for ease of use to see it when you open it. hooe this helps. Hi there... nice information to provide there... I am starting to manage my region for now. A question please. Is there anyway to call them by index ? Im new in Lua and also newbie as programmer. let say i want to do this asd(2) and have this function function asd(a) REG = { region_1 = Region(x,y,h,w), region_2 = Region(x,y,h,w), region_3 = Region(x,y,h,w), } -- i want to call them by parameter a click(REG.region_ .. a) -- it cant work click(REG[2]) -- also cant workend Thank you.
|
|
|
Post by Mercobots on Feb 5, 2021 0:43:25 GMT
hi there first of all let me explain the basic of tables you can create 2 kind of tables, the named table and indexed tables
named table
table = { key_1 = value1, key_2 = value2, }
named table access
print(table.key_1) or print(table["key_1"])
named table access using loop (pairs)
for k,v in pairs(REG) do print("Key = "..k.." | value = ".. v) end
indexed table
table = { value1, value2, }
indexed table access
print(table[1])
indexed table access using loop (ipairs)
for i,v in ipairs(REG) do print("index = "..i.." | value = ".. v) end
For your case you can use the same logic
REG = { region_1 = Region(x,y,h,w), region_2 = Region(x,y,h,w), region_3 = Region(x,y,h,w), }
REG.region_1
REG = { Region(x,y,h,w), Region(x,y,h,w), Region(x,y,h,w), }
REG[1]
you can even mix both tables types
REG = { buttons = { Region(x,y,h,w), Region(x,y,h,w), Region(x,y,h,w), }, frames = { Region(x,y,h,w), Region(x,y,h,w), Region(x,y,h,w), } }
REG.buttons[1] REG.frames[2]
best regards
|
|