line 525 is the gui:rem line at the bottom, and npcbutton = {}, mb, i forgot it was the load function and not there. This is the only function that addresses it otherwise
I thought
was the same as .i.o , from my errors, and what you say, its pretty obvious they're not, woops lol
Is there another way to set functions for each instance of button other than using a colon ? Im just using what ive learned from the documentation. using:
Code: Select all
function npcbutton[i][o]:click(x, y)
, gives me the error:
syntax error; ( expected near [
on that line, same with a comma. Cant make sense of this
before, i tried setting it as
Code: Select all
npcbutton[i][o]:click = function(x, y)
this caused the funky errors i was talking about. Using a comma instead will run, but crashes with the error:
Gspot.lua:380: attempt to index local 'element' (a nil value)
with a traceback to this line:
Code: Select all
gui:rem(npcbutton[playertargetid][playertargetnpc])
if the destroyed npc(and therefore element) isn't the last in the table. note: the playertargetid and playertargetnpc are the i and o values for that specific npc, respectively
What im trynna do here is, as every npc is spawned, they spawn as
, where i is the type of npc and o is the number of npc.
when they're killed, they are deleted with table.remove, which moves all other entries in that npc type down to fill the empty entry in the table. This works as intended as far as i can tell, any destroyed npcs are properly removed and the new ones spawn in the now vacant places at the end of the table
but when each npc is spawned, a hidden button is spawned with the same i and o values, but under npcbutton. a specific button with npc specific information, ie the position of the button is set as the same values as the npc's coordinates at creation (and properly edited as needed later)
what i wanna do is the same as the NPCS table, remove the button that was 'attached' to that npc, while keeping the other buttons in the corresponding positions in their table. Such that npc [1][2] has a button at npcbutton[1][2], and if that npc becomes npc[1][1] due to 1st npc death, the button also moves to npcbutton[1][1] after the original [1][1] button is removed from the table. This way the references for npc and button are interchangable between the two for purposes of selection
sorry for he lots of code blocks, kept setting stuff as italic