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 … 8 9 10 11 12 … 18 Next »
Functions working "on arguments " in starfall
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Functions working "on arguments " in starfall
04-07-2016, 09:58 PM,
#1
pho Offline
once you go pho you never go back
***
Posts: 578
Threads: 82
Joined: Oct 2013
Functions working "on arguments " in starfall
I'm lost, im looking to make a custom function which works likes with e2, here you "apply" the function to something separated using ":"
for example:

with e2 i can do something like that using "This"
Code:
function number entity:belongsToPlayer(Player:entity) { if(This:owner() == Player){ return 1 } else{ return 0 } } print(Prop:belongsToPlayer(owner()))

but with starfall it seems much more complicated, someone told me about meta-tables, and someone said i should look for initherance.
help me pls
Website Find
Reply
05-07-2016, 01:15 AM,
#2
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: Functions working "on arguments " in starfall
They probably should've pointed out that there's a section on this in the starfall tutorial Tongue
Meta-tables and meta-methods (objects)

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
05-07-2016, 02:06 AM, (This post was last modified: 05-07-2016, 05:05 AM by Red The Blue Color.)
#3
Red The Blue Color Offline
TSCM Super Donating Member
****
Posts: 422
Threads: 34
Joined: Feb 2015
RE: Functions working "on arguments " in starfall
Also to add onto the meta tables since GetTypeDef doesn't seem to be mentioned if you wanted to find already existing meta tables for example players you would do something like this
Player = GetTypeDef( "Player" )

function Player:leltits(Arg)
print(Arg," ",self:name())
end

ents.owner():leltits("Hello")

"with it's superior software, i have no doubt it will succeed in finding fuck all" - T-17, 2016

[Super Member] [ENCOM] т-ѕсм.Red The Blue Color™: server do you support Hitler?
[Server] srcds_linux: The probabilty is about 99.99%, so interpret that how you want to.
Find
Reply
05-07-2016, 11:09 AM,
#4
pho Offline
once you go pho you never go back
***
Posts: 578
Threads: 82
Joined: Oct 2013
RE: Functions working "on arguments " in starfall
thanks m89
why does it doesnt work with table/array type ?
Website Find
Reply
05-07-2016, 04:33 PM,
#5
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Functions working "on arguments " in starfall
(05-07-2016, 11:09 AM)pho Wrote: thanks m89
why does it doesnt work with table/array type ?
You can't add methods to any Lua type except for strings, which you can add to by adding to the string table (as in standard Lua).

For tables specifically, there's no way to make a universal metatable because they're supposed to take a specific metatable to represent some specific object. Tables are way more than just data holders.
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.