Hello Tynan, hello Rimworld Com,
i want to ask you how to implement a building that produces something on its own.
I have understood that this might have to be implemented by a .dll.
Let's say a mining drill that mines iron every few seconds.
Maybe i have to reference the mining code so the building calls this code every few seconds and spit out something? Or something totaly different :)
Can you guide me in the right direction please? :)
Thank you.
I wonder why no one has asked this before, or i have not found the topic where this has been discussed.
Best regards from Germany, so be kind if my english isnt that good ;)
You can use the Ticker or TickerRare to do so.
In principle the Ticker is, when activated, a function that is called 60 times per second.
So you can do some program, that updates an internal counter every tick.
If the counter is done, call your SpawnItem-function and you have your result.
The TickerRare (or RareTicker? don't remember right now.) is called every 250 ticks.
Normally prefer this one as it doesn't need a faster counter and it will be better for the performance.
With this you can make it so that lets say coal is produced every x seconds.
And you can integrate a random counter target and don't have a fixed time :)
Thank you that helps alot.
How can i spawn something? Sorry but i dont know where to start here. I think i have to call a function from the core?
And how can i define where to place it.
Can i reference a tile from the builduing?
Lets say its a 3x3 tile wide building.
Maybe i can say its on a spot beside, above or ontop of it.
XXX
XXX
XXX
O
or inside it
XXX
XXX
XOX
Look at the ThingMaker class, specifically methods of its that reference spawn. As for the location, you specify that when you spawn an item (rimworld effectively uses 2 axis for the positions).
Thank you for looking at this. It will be very helpful for me because I will be implementing this in my mod as well. If I manage to figure it out I will let you know.
so basically copying industrial rims iron mine?
Quote from: dannyepsin on May 06, 2014, 05:56:32 AM
so basically copying industrial rims iron mine?
wow... slow down there, as long as its his code its not an exact copy.
Quote from: Blackjack1000K on May 06, 2014, 06:05:07 AM
Quote from: dannyepsin on May 06, 2014, 05:56:32 AM
so basically copying industrial rims iron mine?
wow... slow down there, as long as its his code its not an exact copy.
Aye to that.
If we are going by copying he would be 'copying' any one of several different mods :P Pretty sure there's only one way to do it anyway, something like:
ThingMaker.Spawn(ThingDef.Named("Def"), IntVec3 place);
Though I can't remember exactly, and I'm currently away from my desktop to look properly. :P
thank you all
ThingMaker sounds good, i will look deeper into this.
I dont want to copy industrial rim :)
Just implement something new with a similar effect.
Heck i myself dont know exactly what i want to implement, but to spawn something is realy the key to do so much things and i thought it would be nice to know. ;)