not effect bugprg wrote:The original code wasYou replaced that withCode: Select all
max_buy_amount = (slots_available * script.item_prototypes[global.buyingtradingchests.item_selected[i]].stack_size) - item_count
right? There are two changes, only one of which seems to make sense to me.Code: Select all
max_buy_amount = (slots_available * game.item_prototypes[global.buyingtradingchests.item_selected[item_selected]].stack_size) - item_count
Please fix in file help
Re: Please fix in file help
- Attachments
-
- 2015-11-14_5-59-28.jpg (26.94 KiB) Viewed 3643 times
Re: Please fix in file help
Alright, I can't tell just by reading that snippet of code what's going on. If you provide the current version of the code and steps to reproduce, I can take a closer look.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Please fix in file help
filesprg wrote:Alright, I can't tell just by reading that snippet of code what's going on. If you provide the current version of the code and steps to reproduce, I can take a closer look.
- Attachments
-
- GalacticTrade_0.6.9-1.rar
- (157.4 KiB) Downloaded 447 times
Re: Please fix in file help
Okay, since you didn't provide steps to reproduce, just randomly clicking buttons in a newly started game doesn't trigger the error and I haven't untangled things far enough to figure out when this piece of code is supposed to run I only had a look at it without actually trying it myself, and... it still says item_selected[item_selected]. You did try that with item_selected like it used to be, right? If so, please tell me what to do so I can see the error myself.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Please fix in file help
prg wrote:Okay, since you didn't provide steps to reproduce, just randomly clicking buttons in a newly started game doesn't trigger the error and I haven't untangled things far enough to figure out when this piece of code is supposed to run I only had a look at it without actually trying it myself, and... it still says item_selected[item_selected]. You did try that with item_selected like it used to be, right? If so, please tell me what to do so I can see the error myself.
yes
Re: Please fix in file help
Airat9000 wrote:yes
prg wrote:If so, please tell me what to do so I can see the error myself.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Please fix in file help
try to correct the fileprg wrote:Airat9000 wrote:yesprg wrote:If so, please tell me what to do so I can see the error myself.
i am file in add to old
Re: Please fix in file help
It appears there might be some difficulties with understanding each other. What I had been looking for was a sequence of steps so I could reproduce the issue myself, likeAirat9000 wrote:try to correct the file
i am file in add to old
- Start a new game with the mod enabled
- /c game.player.insert{name="logistic-trading-chest-buy"}
- Plop down the chest
- Open the chest
- In the resulting "Choose an item" dialog click a random item
- Enter some number in the left "Selected item" dialog
- Click the "GT" button in the top left corner
Just to make sure, in control.lua, line 1031, change
Code: Select all
max_buy_amount = (slots_available * game.item_prototypes[global.buyingtradingchests.item_selected[item_selected]].stack_size) - item_count
Code: Select all
max_buy_amount = (slots_available * game.item_prototypes[global.buyingtradingchests.item_selected[i]].stack_size) - item_count
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Please fix in file help
prg wrote:It appears there might be some difficulties with understanding each other. What I had been looking for was a sequence of steps so I could reproduce the issue myself, likeAirat9000 wrote:try to correct the file
i am file in add to old
This indeed results in "Error while running the event handler: __GalacticTrade__/control.lua:1031: attempt to index field '?' (a nil value)" which, contrary to your claims, is fixed for me by changing item_selected[item_selected] in that line back to the original code's version of item_selected, like I've been trying to suggest for a while now.
- Start a new game with the mod enabled
- /c game.player.insert{name="logistic-trading-chest-buy"}
- Plop down the chest
- Open the chest
- In the resulting "Choose an item" dialog click a random item
- Enter some number in the left "Selected item" dialog
- Click the "GT" button in the top left corner
Just to make sure, in control.lua, line 1031, changetoCode: Select all
max_buy_amount = (slots_available * game.item_prototypes[global.buyingtradingchests.item_selected[item_selected]].stack_size) - item_count
You're still claiming this doesn't make a difference for you? What is the reason you made that change in the first place? Can you provide steps to reproduce the issue with the changed code?Code: Select all
max_buy_amount = (slots_available * game.item_prototypes[global.buyingtradingchests.item_selected[i]].stack_size) - item_count
understood you. You can view the file as was the change?
Re: Please fix in file help
I'm sorry, I don't quite understand you. How I was able to view differences between files? There's this handy "diff" utility.Airat9000 wrote:understood you. You can view the file as was the change?
Code: Select all
$ diff -bru GalacticTrade_0.6.[59]/
[...]
@@ -1028,7 +1028,7 @@
end
if slots_available>0 then
- max_buy_amount = (slots_available * script.item_prototypes[global.buyingtradingchests.item_selected[i]].stack_size) - item_count
+ max_buy_amount = (slots_available * game.item_prototypes[global.buyingtradingchests.item_selected[item_selected]].stack_size) - item_count
if item_difference > max_buy_amount then
item_difference = max_buy_amount
end
[...]
Code: Select all
@@ -550,14 +550,14 @@
for name, amount in pairs(contents) do
global.buyingtradingchests.chest[chest_index].get_inventory(1).insert({name = name, count = amount})
if name ~= global.buyingtradingchests.item_selected[chest_index] then
- slots_available = slots_available - math.ceil(amount/script.item_prototypes[global.buyingtradingchests.item_selected[chest_index]].stack_size)
+ slots_available = slots_available - math.ceil(amount/game.item_prototypes[global.buyingtradingchests.item_selected[item_index]].localised_name.stack_size)
end
end
Also, you've still missed a few get_localised_item_name calls.
Code: Select all
$ grep -n get_localised -r GalacticTrade_0.6.9/
GalacticTrade_0.6.9/prototypes/control.lua:794: p.gui.left.tradingchest_buy.item_view_table.add{type="label",name="item_label",caption=game.get_localised_item_name(global.buyingtradingchests.item_selected[item_index])}
GalacticTrade_0.6.9/prototypes/scripts/trading-chest.lua:350: p.gui.left.tradingchest_buy.item_view_table.item_label.caption = game.get_localised_item_name(global.buyingtradingchests.item_selected[chest_index])
GalacticTrade_0.6.9/prototypes/prototypes/scripts/trading-chest.lua:350: p.gui.left.tradingchest_buy.item_view_table.item_label.caption = game.get_localised_item_name(global.buyingtradingchests.item_selected[chest_index])
GalacticTrade_0.6.9/prototypes/prototypes/scripts/trading-chest.lua:397: p.gui.left.tradingchest_buy.item_view_table.item_label.caption = game.get_localised_item_name(item.name)
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Please fix in file help
the script makes recalculation of price again not to start the game again, simply restart the file already startedprg wrote:I'm sorry, I don't quite understand you. How I was able to view differences between files? There's this handy "diff" utility.Airat9000 wrote:understood you. You can view the file as was the change?
This also shows another suspicious change on line 553:Code: Select all
$ diff -bru GalacticTrade_0.6.[59]/ [...] @@ -1028,7 +1028,7 @@ end if slots_available>0 then - max_buy_amount = (slots_available * script.item_prototypes[global.buyingtradingchests.item_selected[i]].stack_size) - item_count + max_buy_amount = (slots_available * game.item_prototypes[global.buyingtradingchests.item_selected[item_selected]].stack_size) - item_count if item_difference > max_buy_amount then item_difference = max_buy_amount end [...]
You changed chest_index into item_index which isn't defined anywhere in that function and added a .localised_name in front of the .stack_size which totally doesn't make sense. (And the whole thing is inside an "if chest == chest" which doesn't appear to be terribly useful to me, but seems like it was that way already in the original.)Code: Select all
@@ -550,14 +550,14 @@ for name, amount in pairs(contents) do global.buyingtradingchests.chest[chest_index].get_inventory(1).insert({name = name, count = amount}) if name ~= global.buyingtradingchests.item_selected[chest_index] then - slots_available = slots_available - math.ceil(amount/script.item_prototypes[global.buyingtradingchests.item_selected[chest_index]].stack_size) + slots_available = slots_available - math.ceil(amount/game.item_prototypes[global.buyingtradingchests.item_selected[item_index]].localised_name.stack_size) end end
Also, you've still missed a few get_localised_item_name calls.
(Why are there scripts containing game logic inside the prototypes/ directory? And then again inside prototypes/prototypes/? I'm a bit scared of that code I need to admit.)Code: Select all
$ grep -n get_localised -r GalacticTrade_0.6.9/ GalacticTrade_0.6.9/prototypes/control.lua:794: p.gui.left.tradingchest_buy.item_view_table.add{type="label",name="item_label",caption=game.get_localised_item_name(global.buyingtradingchests.item_selected[item_index])} GalacticTrade_0.6.9/prototypes/scripts/trading-chest.lua:350: p.gui.left.tradingchest_buy.item_view_table.item_label.caption = game.get_localised_item_name(global.buyingtradingchests.item_selected[chest_index]) GalacticTrade_0.6.9/prototypes/prototypes/scripts/trading-chest.lua:350: p.gui.left.tradingchest_buy.item_view_table.item_label.caption = game.get_localised_item_name(global.buyingtradingchests.item_selected[chest_index]) GalacticTrade_0.6.9/prototypes/prototypes/scripts/trading-chest.lua:397: p.gui.left.tradingchest_buy.item_view_table.item_label.caption = game.get_localised_item_name(item.name)
others form a message of those things that can not be sold.
Re: Please fix in file help
Again I'm not sure what you're trying to say here. Yes, the mod precalculates some values at the beginning for some reason and there's a button to recalculate them in a running game. Not sure how that's relevant to the things I pointed out. The issues mentioned do cause breakage, try buying two different things with the same buying chest or try copy/pasting with the buttons in the "Selected item" dialog.Airat9000 wrote:the script makes recalculation of price again not to start the game again, simply restart the file already started
others form a message of those things that can not be sold.
Also the organisation of the files does not make sense, a script does not need to be placed in prototypes/ to be able to access game.item_prototypes (or what was the reasoning here?)
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!