{"action":"reopened","issue":{"url":"https://api.github.com/repos/leafo/moonscript/issues/303","repository_url":"https://api.github.com/repos/leafo/moonscript","labels_url":"https://api.github.com/repos/leafo/moonscript/issues/303/labels{/name}","comments_url":"https://api.github.com/repos/leafo/moonscript/issues/303/comments","events_url":"https://api.github.com/repos/leafo/moonscript/issues/303/events","html_url":"https://github.com/leafo/moonscript/issues/303","id":193193191,"number":303,"title":"Function Parameters nil","user":{"login":"AndrewBastin","id":9131943,"avatar_url":"https://avatars.githubusercontent.com/u/9131943?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewBastin","html_url":"https://github.com/AndrewBastin","followers_url":"https://api.github.com/users/AndrewBastin/followers","following_url":"https://api.github.com/users/AndrewBastin/following{/other_user}","gists_url":"https://api.github.com/users/AndrewBastin/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewBastin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewBastin/subscriptions","organizations_url":"https://api.github.com/users/AndrewBastin/orgs","repos_url":"https://api.github.com/users/AndrewBastin/repos","events_url":"https://api.github.com/users/AndrewBastin/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewBastin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-02T19:07:58Z","updated_at":"2016-12-02T19:33:44Z","closed_at":null,"body":"Hi there,\r\n\r\nI am not sure if this is the right place to put this.. Anyways, I just started using Moonscript out of curiosity.. I really liked the syntax (haven't used coffee before though).. So, I thought of working on a LOVE game on it and I ran into this issue..\r\n\r\nNOTE : I am coming from C# and have not ventured much scripting and lua and stuff.. So, please forgive me if I mixed in some concepts and keywords here and there :P\r\n\r\nI have this Entity class, having a table (in an array fashion) with 1 component (type of Component class) as a property..\r\nIt has a function called addComponent which takes a component as a parameter and adds it to the component table. But the thing is, the parameters, self and component are being called as nil.\r\n\r\nEntity class:\r\n~~~~\r\nimport Component from require 'ecs.component'\r\nimport Transform from require 'components.transform'\r\n\r\nclass Entity\r\n  name: \"\" -- Name of the Entity\r\n  transform: Transform 0, 0, 0, 0, 0\r\n  components: { transform } -- Component table of the entity\r\n\r\n  new: (@name, @transform) =>\r\n    @components = { transform }\r\n\r\n  -- Adds a component to the components table\r\n  -- component : Expected to be of ecs.component type\r\n  addComponent: (component) =>\r\n    -- Component is null\r\n    for i = 1, table.getn @components -- Self is null\r\n      if table[i].__name == component.__name\r\n        -- This component already exists in the entity... We will replace it\r\n        table.remove(@components, i)\r\n        table.insert(@components, component)\r\n        return -- Not safe to modify this array anymore...\r\n\r\n    table.insert(@components, component) -- We havent found any existing component like that, so just add it\r\n\r\n{ :Entity}\r\n~~~~\r\n\r\nI loaded it in main.moon in love.load:\r\n~~~~\r\nlove.load = () ->\r\n  love.window.setTitle \"Testing Moonscript\"\r\n  testEntity = Entity \"Test Entity\", Transform 10, 10, 10, 10\r\n  testEntity.addComponent SpriteRenderer!\r\n~~~~\r\n\r\nAnd then pops up the error : \r\n~~~~\r\nbad argument to #1 to 'getn' (table expected, got nil)\r\n~~~~\r\nI am happy to provide more code if requested...\r\n\r\nThank You..."}}
{"actor":{"display_login":"AndrewBastin"}}