Team Spartan Cookies & Milk Forums
stargate.setName - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: stargate.setName (/thread-995.html)



stargate.setName - 4N0NYM - 12-06-2015

ever if i try to make

local Owner = ents.owner()

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: stargate.setName - Destiny's Player - 12-06-2015

Shouldn't you use SA1 instead of SA?


RE: sv: SF:Starfall/MIDWAYCONTROLPANAL.txt:15: attempt to call method 'getWirelink' (a ni - SuperPlayer - 12-06-2015

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.


RE: stargate.setName - 4N0NYM - 12-06-2015


local Owner = ents.owner()
function Owner1( Ent )
return Ent:owner() == Owner
end

SA = find.byClass("stargate_sg1", Owner1)
SA1 = SA[1]:getWirelink()



Shield = find.byClass("st_shield_emitter", Owner1)
Shield1 = Shield[3]:getWirelink()

Node = find.byClass("stargazer_node", Owner1)
Node1 = Node[4]:getWirelink()

STARGATEA = find.byClass("stargate_movie", Owner1)
STARGATEA1 = STARGATEA[5]:getWirelink()

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



RE: stargate.setName - SuperPlayer - 12-06-2015

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.