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 »
LocInt's SF Help & Request Thread
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
LocInt's SF Help & Request Thread
14-05-2015, 06:06 PM,
#14
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: LocInt's SF Help & Request Thread
What LocInt said expanded:
function findStargateByAddress( Address )
Address = string.sub( Address, 1, 6 ) --Use the first 6 characters of Address only.
local Stargates = stargate.getAllStargates() --Use this because otherwise you find irises too.
for i = 1, #Stargates do
local Stargate = Stargates[ i ]
if stargate.address( Stargate ) == Address then
return Stargate
end
end
end
Basically, string.sub takes a string, a starting character index and an ending character index and returns the parts of the string between the two indices. So in the above, we took the characters between the 1st and 6th inclusive out of the Address string.

You'll note also the use of the local keyword, otherwise you end up leaking values out into the global scope which is bad practise and will almost certainly lead to problems later.
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
LocInt's SF Help & Request Thread - by LocInt - 11-12-2014, 05:55 PM
RE: LocInt's SF Help & Request Thread - by Wirebuilder28 - 11-12-2014, 06:13 PM
RE: LocInt's SF Help & Request Thread - by LocInt - 11-12-2014, 06:41 PM
RE: LocInt's SF Help & Request Thread - by Person8880 - 11-12-2014, 07:21 PM
RE: LocInt's SF Help & Request Thread - by LocInt - 11-12-2014, 07:34 PM
RE: LocInt's SF Help & Request Thread - by Person8880 - 11-12-2014, 07:40 PM
RE: LocInt's SF Help & Request Thread - by LocInt - 11-12-2014, 07:41 PM
RE: LocInt's SF Help & Request Thread - by TheOneAndOnlyTee - 11-12-2014, 09:01 PM
RE: LocInt's SF Help & Request Thread - by Blackhawk - 11-12-2014, 11:28 PM
RE: LocInt's SF Help & Request Thread - by LocInt - 11-12-2014, 11:41 PM
RE: LocInt's SF Help & Request Thread - by Person8880 - 12-12-2014, 06:47 PM
RE: LocInt's SF Help & Request Thread - by SuperPlayer - 14-05-2015, 05:29 PM
RE: LocInt's SF Help & Request Thread - by LocInt - 14-05-2015, 06:04 PM
RE: LocInt's SF Help & Request Thread - by Person8880 - 14-05-2015, 06:06 PM
RE: LocInt's SF Help & Request Thread - by SuperPlayer - 14-05-2015, 06:24 PM
RE: LocInt's SF Help & Request Thread - by Salira - 16-05-2015, 05:46 PM

  • 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.