{"action":"created","issue":{"url":"https://api.github.com/repos/M-Tass/Cyth/issues/8","repository_url":"https://api.github.com/repos/M-Tass/Cyth","labels_url":"https://api.github.com/repos/M-Tass/Cyth/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/M-Tass/Cyth/issues/8/comments","events_url":"https://api.github.com/repos/M-Tass/Cyth/issues/8/events","html_url":"https://github.com/M-Tass/Cyth/issues/8","id":331235940,"node_id":"MDU6SXNzdWUzMzEyMzU5NDA=","number":8,"title":"Having trouble passing tables into functions","user":{"login":"FocuzJS","id":16075058,"node_id":"MDQ6VXNlcjE2MDc1MDU4","avatar_url":"https://avatars3.githubusercontent.com/u/16075058?v=4","gravatar_id":"","url":"https://api.github.com/users/FocuzJS","html_url":"https://github.com/FocuzJS","followers_url":"https://api.github.com/users/FocuzJS/followers","following_url":"https://api.github.com/users/FocuzJS/following{/other_user}","gists_url":"https://api.github.com/users/FocuzJS/gists{/gist_id}","starred_url":"https://api.github.com/users/FocuzJS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FocuzJS/subscriptions","organizations_url":"https://api.github.com/users/FocuzJS/orgs","repos_url":"https://api.github.com/users/FocuzJS/repos","events_url":"https://api.github.com/users/FocuzJS/events{/privacy}","received_events_url":"https://api.github.com/users/FocuzJS/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-06-11T15:22:23Z","updated_at":"2018-06-17T19:39:06Z","closed_at":"2018-06-14T08:47:14Z","author_association":"NONE","body":"So I've worked with tables as far as pulling values from a table goes, I'm using `ents.FindByClass` to return a table on the stack and then i want to use the `Count ` method of `table` and when I make a call to `Count` with `Push(-2)` assuming its the table, but I must not know something about tables, because this call to `Count` fails with `tried to call a table value`  when i use `ents.GetAll()` or `tried to call a nil value` with `FindByClass`. I've tried switching from `Count` to `IsValid` and get the same lua errors.\r\n\r\nSome example code:\r\n```cpp\r\nauto glua = globals::lua->create_interface(lua::type::client);\r\n\r\nif (glua) {\r\n\tglua->PushSpecial(lua::special::glob);\r\n\tglua->GetField(-1, \"ents\");\r\n\tglua->GetField(-1, \"FindByClass\");\r\n\tglua->PushString(\"bit_miner_*\", 11);\r\n\tglua->Call(1, 1);\r\n\r\n\tglua->GetField(-1, \"IsValid\");\r\n\tglua->Push(-2);\r\n\tglua->Call(1, 1);\r\n\r\n\tif (!glua->GetBool())\r\n\t{\r\n\t\tglua->Pop(4);\r\n\t\tcontinue;\r\n\t}\r\n\r\n\tglua->Pop();\r\n\r\n\tglua->PushString(\"1\");\r\n\tglua->GetTable(-2);\r\n\r\n\t//the way this part was done may be a misunderstanding of stacks but im sure this is not the root cause of my issue because i've tried other combinations without this\r\n\r\n\tglua->GetField(-1, \"IsValid\");\r\n\tglua->Call(1, 1);\r\n\r\n\t//glua->GetField(-2, \"Count\");\r\n\t//glua->Push(-2);\r\n\t//glua->Call(1, 1);\r\n\t//auto x = glua->GetNumber();\r\n\r\n\t//char s[50];\r\n\r\n\t//sprintf(s, \"%f\", x);\r\n\tif (glua->GetBool()) {\r\n\t\tglobals::print({ 255, 0, 0, 255 }, \"boolin\");\r\n\t}\r\n\telse {\r\n\t\tglobals::print({ 255, 0, 0, 255 }, \"not boolin\");\r\n\t}\r\n\r\n\tglua->Pop(5);\r\n}\r\n```\r\n\r\nmaybe if you could show me an example of passing a table into a function, i would probably be able to figure this out on my own :)"},"comment":{"url":"https://api.github.com/repos/M-Tass/Cyth/issues/comments/397901402","html_url":"https://github.com/M-Tass/Cyth/issues/8#issuecomment-397901402","issue_url":"https://api.github.com/repos/M-Tass/Cyth/issues/8","id":397901402,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzkwMTQwMg==","user":{"login":"FocuzJS","id":16075058,"node_id":"MDQ6VXNlcjE2MDc1MDU4","avatar_url":"https://avatars3.githubusercontent.com/u/16075058?v=4","gravatar_id":"","url":"https://api.github.com/users/FocuzJS","html_url":"https://github.com/FocuzJS","followers_url":"https://api.github.com/users/FocuzJS/followers","following_url":"https://api.github.com/users/FocuzJS/following{/other_user}","gists_url":"https://api.github.com/users/FocuzJS/gists{/gist_id}","starred_url":"https://api.github.com/users/FocuzJS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FocuzJS/subscriptions","organizations_url":"https://api.github.com/users/FocuzJS/orgs","repos_url":"https://api.github.com/users/FocuzJS/repos","events_url":"https://api.github.com/users/FocuzJS/events{/privacy}","received_events_url":"https://api.github.com/users/FocuzJS/received_events","type":"User","site_admin":false},"created_at":"2018-06-17T19:39:06Z","updated_at":"2018-06-17T19:39:06Z","author_association":"NONE","body":"prop_physics works everywhere but flood and the public source indicates that its' still a `prop_physics`.. "}}
{"actor":{"display_login":"FocuzJS"}}