function Owner1( Ent )
return Ent:owner() == Owner
end
local SA = find.byClass("stargate_sg1", Owner1)
local SA1 = SA:getWirelink[1]()--line 15 is here
stargate.setName(SA,"Test")--line 23 is here
i get a message with sv: sv: SF:main:23: Type mismatch (Expected Entity, got Wirelink) in function setName
or
sv: SF:main:23: Type mismatch (Expected Entity, got table) in function setName
RE: sv: SF:Starfall/MIDWAYCONTROLPANAL.txt:15: attempt to call method 'getWirelink' (a ni
Hey xXxANOxXx!
for the first error [SF:main:23: Type mismatch (Expected Entity, got Wirelink)] this happens when you use SA1(a wirelink) in the setName function. But in the function you need to use an entity.
stargate.setName(Gate,Name)
--Gate is the Gate entity
--Name is the string name you want the gate to have
As for the second problem[sv: SF:main:23: Type mismatch (Expected Entity, got table)] you use following to find the gate(s).
local SA = find.byClass("stargate_sg1", Owner1)--This function saves all stargate_sg1 belonging to you in a table. So handle it as a table.
--Just use the first entry in the table:
if IsValid(SA[1]) then--Check if the gate is there
stargate.setName(SA[1],"Test")--If yes set the name of the first gate in the table to "Test"
end
@Destiny's Player
No you shouldnt use SA1 because as I explained its a wirelink and the function uses an Entity.
LS = find.byClass("stargazer_ls_core", Owner1)
LS1 = LS[6]:getWirelink()
--stargazer_ls_core
function sendToClient()--Send stuff to client/Yes i know strings are slow but for learning its the easiest, You can also send tables
net.start()
net.writeString(String)
net.broadcast()
end
timer.create("Timer1",2,1,sendToClient)--Send our String to the CLIENT after 1 second and do this just 1 time
if IsValid(SA[1]) then--Check if the gate is there
stargate.setName(SA[1],"MIDWAY MilkyWay")--If yes set the name of the first gate in the table to "Test"
IRISSG1 = stargate.iris(SA[1])
stargate.irisToggle(IRISSG1)
end
if IsValid(STARGATEA[5]) then
stargate.setName(STARGATEA[5],"MIDWAY PEGASUS")
end
You are not getting the point. These are all DIFFERENT tables. So for each table you have to use the FIRST value of each table. Maybe you should read the LUA tutorial in Person8880 Starfall tutorial.