[MOD 0.12.x] Treefarm REDUX (DISCONTINUED)

Looking for a mod? Have a review on a mod you'd like to share?
drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: [MOD 0.3.x] Treefarm

Post by drs9999 »

Oh forgot to say that.
I cant find an error then. For me it was and is working if I start a new game.

Are you sure that you have the latest version? I dont know why it should, but maybe a re-download, re-install can help.

It would be useful if anyone else who have the same problem (with the latest version) can post a small message here.
This is so strange, because in reference to your screenshot everything else seems working correctly...

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: [MOD 0.3.x] Treefarm

Post by slpwnd »

Not sure if this could be related, but still. There is a thin ice when it comes to migrating mod scripts to new versions. What I mean is that you need to be aware of the fact that the user might have run the older version of your mod script which saved some datastructures into glob table. Then when he loads the game with newer version this script must be able to deal with that.

Example:

mod script v. 0.3 stores data in variable glob.foo
in v. 0.4 this changes and the same data are stored in varibale glob.bar.

When a user loads game with the 0.4 script the data might be either in glob.bar or in glob.foo depending on whether he had used (and saved) the game in the v. 0.3 of the mod script.

This is problematic now and we will try to address this in the future releases. Not sure if it is related to your problems (I haven't studied the code of the script), however I thought it would be appropriate to mention it.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by FreeER »

Just got this mainly cause I noticed I_IBlackI_I had a problem with it. First time I've used this mod so it was a new world. The trees grew but didn't get harvested.
I noticed that when you harvested you used the i variable BUT the code is not inside of a for loop (which i is a local variable of) so I threw a for loop around the code like so:

Code: Select all

            for _,entity in pairs(entities) do
                if (entity.type=="tree") then
                    if k > 4 and glob.field[i].getitemcount("raw-wood") < 128 then    -- Yes, then start chopping
                      local rndz = math.random(1 , k)                                 -- of course a random tree
                      local rndd = 0                                                  -- random output

                      if glob.field[i].getitemcount("fertilizer") > 0 then               -- random wood-output (with/without fertilizer)
                        rndd = math.random(1 , 6)
                      else
                        rndd = math.random(1 , 3)
                      end
                      if entities[rndz].type == "tree" then    -- and of course only when the entitiy is a tree and not the field
                        entities[rndz].destroy()              -- remove tree
                        glob.field[i].getinventory(1).insert{name="raw-wood", count=rndd}    -- add wood to the container
                      end
                    end
                end
            end
and it's working for me now.

BTW have you noticed that you can simply throw down a field in the middle of a forest and have it harvest most of the trees for you? If you throw some fertilizer in before it harvests you might even be able to get more wood through the field than if you chopped it yourself, though unlikely :)


edit: also it bugs me that the chest isn't included in the selection box lol. just saying. Also if you are on the wrong side of the field you can't access the wood cause you are too far from the placement location
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: [MOD 0.3.x] Treefarm

Post by drs9999 »

No, the "i" variable is introduced in the at the beginning of the ontick event.

like this:

ontick
-------if tickcount % 600 == 0 then
-----------for i = 1 , glob.fieldcount , 1 do
-----------------everything else

so its valid in all "levels" that are in the loop.

Anyway the biggest problem for me is that everyone who tried the mod have the same problem, but I cant reproduce it... For me its still working fine and thats really sucks.
FreeER wrote:BTW have you noticed that you can simply throw down a field in the middle of a forest and have it harvest most of the trees for you? If you throw some fertilizer in before it harvests you might even be able to get more wood through the field than if you chopped it yourself, though unlikely :)
But you shouldnt be able to produce fertilizer atm ;)
Also the output is still random. So if you use it like this it also could happen that the output is lower as hand-harvesting
FreeER wrote:edit: also it bugs me that the chest isn't included in the selection box lol. just saying. Also if you are on the wrong side of the field you can't access the wood cause you are too far from the placement location
So yeah there are two options. Making the selectionbox bigger so it will also include some grass or so on the sides and the chest. or leave it like it is. Actually I like it more the way it is atm.
The reason for your second point is that you (and inserters) can only access the inv via the collision-box . Atm the collisionbox is only around the chest. I want that the inserters only can extract the wood from the chest and not from everywhere else, because it makes more sense in my opinion.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by FreeER »

yep understood all of that, except for the i variable, because if you are correct then adding a for loop should not have fixed it for me :)
i cheated to test it quickly lol
Also have you tried to download the file that everyone else is getting? it's theoretically possible that you made a change and then forgot to save before uploading or something :)

From my understanding when you declare i inside of a for loop it is still a local variable unless you explicitly export it before the end of the block.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: [MOD 0.3.x] Treefarm

Post by drs9999 »

Wow really. This is ridiculous...
So just to be on the save side I download the file from the startpost... copied into a fresh factorio-game et voila -> isnt working for me as well...
Ok I thought, another big stupid mistake.
Then I copied the mod from my normal game-folder into a frsh game and it was working

BUT THEN I compared both control files and they are identical... Really why?!? :D

I add the working mod to this post, can you be so kind and test if this one is working and if yes can you compare it with the old file, maybe I am just to tired, but I cant find any differences...
Last edited by drs9999 on Wed Apr 03, 2013 9:28 am, edited 1 time in total.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by FreeER »

Interesting... I just compared the file I'd originally downloaded and the one you just uploaded using notepad++'s compare plugin, it says they are a perfect match.
However it does work whereas the other did not. :? :?: :?

edit: um WTF. I just figured I'd try it to see what happens if I copied the original file back...it works now WTF. so just tell people that if it doesn't work the first time to recopy the file (I didn't even redownload, I just replaced the file)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by n9103 »

Wanted to test out the fertilizer on a farm, but when I try to use the console command "glob.player.insert{name="fertilizer",count=128}" I get an error about "attempt to index a field 'player' (a nil value)"

Bit lost as to why that would even occur, since this is is the same syntax I could use to start a game with some X item.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by FreeER »

Due to changes in 3.0 the proper command is

Code: Select all

game.player.character.insert{name="fertilizer",count=128}
here's why, 0.3.0 changed some commands, your particular problem is two fold, the initial problem is that you used glob.player (which was indeed used previously) though it was actually a variable containing game.getplayer(), and second the devs have separated the player and character commands. The commands that belong to the character you move around the screen are now accessed with player.character.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

Baldri
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Mar 16, 2013 9:32 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by Baldri »

FreeER wrote:Interesting... I just compared the file I'd originally downloaded and the one you just uploaded using notepad++'s compare plugin, it says they are a perfect match.
However it does work whereas the other did not. :? :?: :?

edit: um WTF. I just figured I'd try it to see what happens if I copied the original file back...it works now WTF. so just tell people that if it doesn't work the first time to recopy the file (I didn't even redownload, I just replaced the file)
Well i reinstalled it very often and your mod works then. For a time. After played for a while at least my farms dont produce anything anymore. But im fine with this workaround for now :mrgreen:.

wsensor
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Mar 29, 2013 8:40 pm
Contact:

Re: [MOD 0.3.x] Treefarm

Post by wsensor »

Could fertilizer be made out of Fish or Fish/Charcoal?

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by FreeER »

Personally I would not want to have to go fishing to create fertilizer...I'd rather have either a compost heap (where you throw wood to decompose) or getting charcoal would also give ash that could be turned into fertilizer by mixing it with wood (or maybe add both and you have to combine ash with compost to then get the fertilizer), that would of course be the early way of getting fertilizer, there should probably be a way to research the creation of fertilizer in a lab where you can then combine a certain amount of either science packs, or actual minerals/nutrients from a special machine that processes the ground over time to extract them.
Ok, I just wrote all that and I think it would take longer than fishing would...but at it would be give more fertilizer over time once set up :)

P.S. not sure how you actually plan to do this, and I'm too lazy right now to go back through the posts to find out for sure lol
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: [MOD 0.3.x] Treefarm

Post by drs9999 »

I just released a bugfix-update that (should) solve(s) the issue that sometimes the trees are not chopped down.

If you used an older version of the mod I recommend to delete the old mod-folder first, copy the new mod-folder in your factorio-dir and start a fresh freeplay.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by kovarex »

Hi, you should use game.getrandomnumber() instead of mat.random:
https://forums.factorio.com/wiki/inde ... ndomnumber

We will disable using math.random sooner or later.

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by rk84 »

kovarex wrote:We will disable using math.random sooner or later.
Why? I assume you can't seed game.getrandomnumber. I would use math.randomseed and math.random if for some reason I need to repeat random number patterns.

It is not problem though. I can make random number generator.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by kovarex »

rk84 wrote:
kovarex wrote:We will disable using math.random sooner or later.
Why? I assume you can't seed game.getrandomnumber. I would use math.randomseed and math.random if for some reason I need to repeat random number patterns.

It is not problem though. I can make random number generator.
Because people would use it wrongly and mods would not work in reaplays/multiplayer.
You would need to save/load the state of your random generator, to avoid all of the hassle, the game.getrandomnumber function is there.
We could also trick it, so math.random would actually use the game.getrandomnumber :)

zlosynus
Global Moderator
Global Moderator
Posts: 114
Joined: Sat Feb 09, 2013 2:17 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by zlosynus »

kovarex wrote: Because people would use it wrongly and mods would not work in reaplays/multiplayer.
You would need to save/load the state of your random generator, to avoid all of the hassle, the game.getrandomnumber function is there.
We could also trick it, so math.random would actually use the game.getrandomnumber :)
Probably it is a good idea to also have some stable random generator, which is parametrized by a number / position on map and it always returns the same thing. You can use this for example for generating underground ores, without having to store it somewhere.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by ficolas »

You can use this for example for generating underground ores, without having to store it somewhere.
I tried to do something with the position to generate "random" numbers, but I failed :(

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by FreeER »

ficolas wrote:
You can use this for example for generating underground ores, without having to store it somewhere.
I tried to do something with the position to generate "random" numbers, but I failed :(
After doing a small amount of research, I'd say you might be able to do something along these lines, if you want to base it on x,y positions

Code: Select all

getResources(x,y) math.randomseed(x+y) math.random return math.random() end
then

Code: Select all

getResources(game.player.character.position.x, game.player.character.position.y)
this gives a pseudo-random number (that will not change for the same x,y coords) between 0 and 1. If you want a larger number use math.random(minValue, maxValue). or simply multiply the math.random() by 100 or something

You may notice I call math.random once before actually returning it, this is because I read that lua on some platforms (mac specifically) will return the same random number regardless of seed on the first call.
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [MOD 0.3.x] Treefarm

Post by rk84 »

y+x has some ill effects, because like (-10)+(10) = (10)+(-10) is equal. It will give zeros on y=x line and makes mirror image over opposite side of that line.

edit: forgot minus y=-x
Last edited by rk84 on Fri Apr 12, 2013 9:15 pm, edited 1 time in total.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Post Reply

Return to “Questions, reviews and ratings”