swipis Posted January 21, 2016 Share Posted January 21, 2016 ok, I doing tutorial and now I got an error "attempt to index field 'context'(a nil value)" in Start function here is the code Script.itemSlots = 4 --int "Item Slots" Script.itemSize = Vec2(64,64) --Vec2 "Item Size" Script.offset = 8.0 --float "Offset" Script.items = {} Script.screenWidth = 0 function Script:Start() self.screenWidth = App.context:GetWidth() end function Script:PostRender(context) for i = 1, self.itemSlots, 1 do context:SetColor(1,1,1,1) local x = self.screenWidth - self.itemSize.x local y = (i * self.itemSize.y) + (i * self.offset) context:DrawRect(x, y, self.itemSize.x, self.itemSize.y) end end please help Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 21, 2016 Share Posted January 21, 2016 At the time of making these tutorials, you could retrieve the context from App. The standard main script has changed since then: Replace self.screenWidth = App.context:GetWidth() You can also get the context like this: self.screenWidth = Context:GetCurrent():GetWidth() Quote Link to comment Share on other sites More sharing options...
swipis Posted January 22, 2016 Author Share Posted January 22, 2016 Thank you AggrorJorn for your tutorials and your answer! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.