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

Register

Team Spartan Cookies & Milk Forums Feedback Suggestions and improvements v
« Previous 1 … 15 16 17 18 19 … 36 Next »
Starfall Libraries
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Starfall Libraries
15-01-2019, 09:12 PM,
#1
exoRift Offline
TSCM Member
***
Posts: 16
Threads: 10
Joined: Nov 2018
Starfall Libraries
Make a library system where people can upload code and it can be inducted into a person's code to use. This would be useful if a person wanted, for example, to make a command engine.
Find
Reply
15-01-2019, 11:23 PM,
#2
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: Starfall Libraries
this is currently done through shared files, just throw your functions into a table and allow someone else to include/dependency your shared file.

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
15-01-2019, 11:37 PM,
#3
exoRift Offline
TSCM Member
***
Posts: 16
Threads: 10
Joined: Nov 2018
RE: Starfall Libraries
(15-01-2019, 11:23 PM)T-20 Wrote: this is currently done through shared files, just throw your functions into a table and allow someone else to include/dependency your shared file.

How would I include a file?
Also, is there modular support (originally what I'm suggesting)?
Find
Reply
16-01-2019, 06:15 AM,
#4
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: Starfall Libraries
I'm not sure I follow on modular support but given it's coded correctly and people include comment files detailing what's in the library for dependency based ones it should feel fairly natural, many people have done it this way previously although I don't think to the amount of modularity that you're thinking of.

check the --@include and --@dependency preprocessors in the SF Documentation for how to add files to your code

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
17-01-2019, 01:06 AM,
#5
exoRift Offline
TSCM Member
***
Posts: 16
Threads: 10
Joined: Nov 2018
RE: Starfall Libraries
So how would I create a module where requiring the file returns a table that does stuff?
Find
Reply
17-01-2019, 03:38 AM,
#6
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: Starfall Libraries
requiring a file will allow you access to any non-local variables made within it, so to protect parts of it from manipulation you can use local to restrict access to stuff within the file

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
17-01-2019, 05:44 PM,
#7
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Starfall Libraries
Globals are one way to pass around values, but you can also return values from files and they'll be returned by require(). For example:

mymodule/index.txt:
--@name Module Example

local Module = {}

function Module.Hello()
print( "Hello World!" )
end

return Module

In another file:
--@name Include The Module
--@dependency mymodule/index.txt

local Module = require( "mymodule/index" )
Module.Hello()

Includes are recursively resolved in dependencies too, so you can build multi-file libraries in this way.
Find
Reply
17-01-2019, 10:56 PM,
#8
exoRift Offline
TSCM Member
***
Posts: 16
Threads: 10
Joined: Nov 2018
RE: Starfall Libraries
(17-01-2019, 05:44 PM)Person8880 Wrote: Globals are one way to pass around values, but you can also return values from files and they'll be returned by require(). For example:

mymodule/index.txt:
--@name Module Example

local Module = {}

function Module.Hello()
print( "Hello World!" )
end

return Module

In another file:
--@name Include The Module
--@dependency mymodule/index.txt

local Module = require( "mymodule/index" )
Module.Hello()

Includes are recursively resolved in dependencies too, so you can build multi-file libraries in this way.

I see. Thank you, Person.
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


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

Powered By MyBB, © 2002-2026 MyBB Group.