ID:139281
 
Code:
obj
wheat
icon = 'icon.dmi'
icon_state = "wheat"

verb/harvest_wheat()
set src in oview(1)
src.Move(usr)
var/turf/farm/seeds = 0


Problem description: So far I have a farm that produces wheat and now I have a harvest command as seen above. The only problem is that it only takes 1 wheat at a time. How can I take all the wheat? There is usually alot of wheat in one spot.

for(var/obj/wheat/W in loc)
W.Move(usr)


Additionally, that last line doesn't do anything. Presumably you want to be modifying loc.seeds or something?
In response to Garthor
Thanks alot, it works :)

But I have another problem:

turf
farm
icon = 'icon.dmi'
icon_state = "farm"
density = 1
var/seeds = 0 // *** further down the code this changes to 1.

obj
wheat
icon = 'icon.dmi'
icon_state = "wheat"

verb/harvest_wheat()
set src in oview(1)
for(var/obj/wheat/W in loc)
W.Move(usr)
var/obj/farm/seeds = 0 // *** I need this command to change the variable to 0



In response to Saladon
> obj
> wheat
> icon = 'icon.dmi'
> icon_state = "wheat"
>
> verb/harvest_wheat()
> set src in oview(1)
> for(var/obj/wheat/W in loc)
> W.Move(usr)
> src.seeds = 0 // This will work.
>


In response to Saladon
That would be:

var/turf/farm/F = src.loc
// We would get an error if F is not the proper type, so we need to check it
if(istype(F))
F.seeds = 0


This has to go BEFORE the for() loop, by the way.
In response to Garthor
Thanks guys. I understand it a little better now