This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
CreeperGoBoom's profile picture

Tollway not charging chest correctly

Started by CreeperGoBoom, 13 December 2019 - 08:10 PM
CreeperGoBoom #1
Posted 13 December 2019 - 09:10 PM
Hi again guys,

if i set toll to more than 64, then
if count is above toll cost it only takes one stack to open even though it is less than the toll cost


what have i missed?

Edit: see lines 101 through 151.

https://pastebin.com/QEai09dx


Also if you see any other errors please let me know. Cheers :)/>
Edited on 13 December 2019 - 08:31 PM
Lupus590 #2
Posted 13 December 2019 - 10:08 PM
are you saying that it will only open when it sees enough items but it only sucks one stack?

maybe you should try a hungry toll? I.e. you take items and count them as you take them (instead of counting them and then trying to take all of them)
CreeperGoBoom #3
Posted 13 December 2019 - 10:28 PM
are you saying that it will only open when it sees enough items but it only sucks one stack?

Correct. I wanted my toll to only take what is available only if the amount is correct.


maybe you should try a hungry toll? I.e. you take items and count them as you take them (instead of counting them and then trying to take all of them)


That make sense…. I'll consider it as maybe an option in my config.

So is there any way to fix the toll only taking one stack?

I tried changing the code that counts through if amount less than toll to this:


elseif (val < toll) and (topay > 0 ) and (val > 0) then
			  print("Counting pennies")
			  if chest.pushItem(pushdir,key,1) then
				topay=topay-1
			  end
			  print("Amount left to pay: ",topay)
			  if topay < 0 then
				print("Oops! something went wrong and chest was overcharged!")
			  end
			end

But this is terribly inefficient. in the case of toll = 96, it took about 8 seconds to count through

but i do know that the problem lies somewhere between line 120 and 126 in my pastebin.

Ill edit my post if I find a fix but right now its driving me nuts.

Also I hate leaving stuff unfinished. Being the sort of person I am. Knowing that I'm not there yet but it's so close to in my grasp is enough to make me go till its all fixed. ahh good times XD.

are there many people on this forum like me? :)/>


EDIT: [solved]

Turns out I needed a secondary check.

Pastebin Updated

BTW: This is stable release #1, I will post this once i have finalized a few details like an auto updater
Edited on 14 December 2019 - 02:40 AM