![]() |
|
Functions working "on arguments " in starfall - 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: Functions working "on arguments " in starfall (/thread-1832.html) |
Functions working "on arguments " in starfall - pho - 04-07-2016 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 RE: Functions working "on arguments " in starfall - TheOneAndOnlyTee - 05-07-2016 They probably should've pointed out that there's a section on this in the starfall tutorial ![]() Meta-tables and meta-methods (objects) RE: Functions working "on arguments " in starfall - Red The Blue Color - 05-07-2016 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
RE: Functions working "on arguments " in starfall - pho - 05-07-2016 thanks m89 why does it doesnt work with table/array type ? RE: Functions working "on arguments " in starfall - Person8880 - 05-07-2016 (05-07-2016, 11:09 AM)pho Wrote: thanks m89You 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. |