Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 13 14 15 16 17 18 Next »
stargate.setName
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
stargate.setName
12-06-2015, 12:45 PM, (This post was last modified: 12-06-2015, 12:49 PM by 4N0NYM.)
#1
4N0NYM Offline
absens
****
Posts: 561
Threads: 211
Joined: Dec 2014
stargate.setName
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
Find
Reply
12-06-2015, 12:51 PM,
#2
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
RE: stargate.setName
Shouldn't you use SA1 instead of SA?
Find
Reply
12-06-2015, 12:59 PM, (This post was last modified: 12-06-2015, 01:03 PM by SuperPlayer.)
#3
SuperPlayer Offline
TSCM Super Member
****
Posts: 234
Threads: 30
Joined: Oct 2014
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.
Find
Reply
12-06-2015, 02:24 PM,
#4
4N0NYM Offline
absens
****
Posts: 561
Threads: 211
Joined: Dec 2014
RE: stargate.setName

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
Find
Reply
12-06-2015, 02:28 PM,
#5
SuperPlayer Offline
TSCM Super Member
****
Posts: 234
Threads: 30
Joined: Oct 2014
RE: stargate.setName
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.
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.