Hello guys I am new to lua but I understand the basics of it very well and have even made my own hud for darkrp, I thought this was to easy so I now want to make a farm type script, I want to just make a tree entity (which I already have) and on this tree I want to make apples appear (I have also made a apple model and exported it to gmod already) on my tree every so long, once it reaches its max amount of apples I want it to be where when you click e on it all of the apples fall to the ground and you can pick them up or something, I think just making the apples grow on the tree's would be a great start. So for this I have to make my apple entities spawn on the tree entity every so seconds. What would be the best way to do this, I know you guys are going to say google it but it is truly very hard to even find what to google for these kinds of things.
First, you create an infinite timer for the apple growth. Every time the timer ticks, you will check if the tree has the maximum amount of apples so you won't have 1000 apples in one tree. After checking that, you add 1 to the apples variable, you can set a entity variable using ENT.AppleCount or self.AppleCount or something like that if it's in a function. After creating the tree entity, now you need to create the apple entity, modify if however you like, but don't call physics yet because we want it to spawn on top of the tree and fall down when the player presses USE key, also don't forget to filter the collider group so that apple doesn't collide with the tree. So back to the tree, each timer ticks you also create an apple entity using ents.Create(). For each apple in the tree, you need to set a different position for the apple so it doesn't spawn in the same position. After creating that, using the ENT:Use() function, you add physics to all of the apples so you need to add all these apples in the tree into a table. It might seem complicated but try your luck.
Ok this is extremely confusing but also maybe something I can do at the same time, I will try using some of this Knowledge, thanks a million
I couldn't find a way to send private message but whatever:
Steam Community
Sorry, you need to Log In to post a reply to this thread.