Yuoki Industries - Informations, Suggestions, Questions

Energy production, weapons, handling fluids and much more - excellent graphics.

Moderator: YuokiTani

Fatmice
Filter Inserter
Filter Inserter
Posts: 808
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Fatmice »

Hello Yuoki,

I've fixed your code for yi_engines. What you were trying to do with on_tick was not allowed so that is why your modifications did not work. :) Don't blame the fluidboxes either. It wasn't their fault. Anyways, I fixed your logic as well as compressed the code to a more manageable form. I hope you will like the modifications. It should be doing what you wanted. As an added bonus, your buildings are now blue-printable and will work when placed by robots.

Code: Select all

require "defines"

game.on_init(function()

end)

game.on_load(function()

end)



-- following code by Fatmice, used with permission
game.on_event(defines.events.on_built_entity, function(event)
	Registration(event.created_entity)
end)
game.on_event(defines.events.on_robot_built_entity, function(event)
	Registration(event.created_entity)
end)
game.on_event(defines.events.on_preplayer_mined_item, function(event) 
	Unregistration(event.entity)
end)
game.on_event(defines.events.on_robot_pre_mined, function(event)
	Unregistration(event.entity)
end)
game.on_event(defines.events.on_entity_died, function(event)
	Unregistration(event.entity)
end)

function Registration(entity)
	if entity.name == "y-gearbox-power" then
		if global.YGBX == nil then
			global.YGBX = {}
		end
		local yegearboxen = {}
		yegearboxen[1] = entity
		table.insert(global.YGBX, yegearboxen)
	elseif entity.name == "ye_overheater" then
		if global.YFYO == nil then
			global.YFYO = {}
		end
		local ye_overh = {}
		ye_overh[1] = entity
		table.insert(global.YFYO, ye_overh)
	elseif entity.name == "ye_sturbine" then
		if global.YSTT == nil then
			global.YSTT = {}
		end
		local yesturbines = {}
		yesturbines[1] = entity
		table.insert(global.YSTT, yesturbines)
	end
end

function Unregistration(entity)
	if entity.name == "y-gearbox-power" then
		local found_index
		local found_entity
		for index,entry in pairs(global.YGBX) do
			if entry[1] == entity then
				found_index = index
				found_entity = entry
				break
			end
		end
		table.remove(global.YGBX, index)
	elseif entity.name == "ye_overheater" then
		local found_index
		local found_entity
		for index,entry in pairs(global.YFYO) do
			if entry[1] == entity then
				found_index = index
				found_entity = entry
				break
			end
		end
		table.remove(global.YFYO, index)
	elseif entity.name == "ye_sturbine" then
		local found_index
		local found_entity
		for index,entry in pairs(global.YSTT) do
			if entry[1] == entity then
				found_index = index
				found_entity = entry
				break
			end
		end
		table.remove(global.YSTT, index)
	end
end

game.on_event(defines.events.on_tick, function(event)
	if global.YGBX ~= nil then
		for k,YGBX in pairs(global.YGBX) do
			if YGBX[1].valid then
				local fbin=1
				local fbout=3
				local yegearboxin = {}				
				if YGBX[1].fluidbox[fbin] ~= nil then
					yegearboxin = YGBX[1].fluidbox[fbin]
				end
				if YGBX[1].fluidbox[fbout] ~= nil then
					YGBX[1].fluidbox[fbout] = {
						["type"] = YGBX[1].fluidbox[fbout].type,
						["amount"] = YGBX[1].fluidbox[fbout].amount,
						["temperature"] = yegearboxin.temperature + 100
					}
				end
			else
				table.remove(global.YGBX, k)
			end
		end
	end
	if global.YFYO ~= nil then
		for k,YFYO in pairs(global.YFYO) do
			if YFYO[1].valid then
				local fbin=1
				local fbout=2
				local ye_overh_out = {}
				if YFYO[1].fluidbox[fbin] ~= nil then
					if YFYO[1].fluidbox[fbin].temperature > 90 then
						if YFYO[1].fluidbox[fbout] ~= nil then
							YFYO[1].fluidbox[fbout] = {
								["type"] = YFYO[1].fluidbox[fbout].type,
								["amount"] = YFYO[1].fluidbox[fbout].amount,
								["temperature"] = 275
							}
						end
					end
				end
			else
				table.remove(global.YFYO, k)
			end
		end
	end
	if global.YSTT ~= nil then
		for k,YSTT in pairs(global.YSTT) do
			if YSTT[1].valid then
				local fbin=1
				local fbout_mechForce=2
				local fbout_water=3
				if YSTT[1].fluidbox[fbin] ~= nil then
					if YSTT[1].fluidbox[fbout_mechForce] ~= nil and YSTT[1].fluidbox[fbin]["temperature"] > 205 then
						YSTT[1].fluidbox[fbout_mechForce] = {
							["type"] = YSTT[1].fluidbox[fbout_mechForce].type,
							["amount"] = YSTT[1].fluidbox[fbout_mechForce].amount,
							["temperature"] = 400
						}
					end
					if YSTT[1].fluidbox[fbout_water] ~= nil and YSTT[1].fluidbox[fbin]["temperature"] > 205 then
						YSTT[1].fluidbox[fbout_water] = {
							["type"] = YSTT[1].fluidbox[fbout_water].type,
							["amount"] = YSTT[1].fluidbox[fbout_water].amount,
							["temperature"] = 90
						}
					end
				end
			else
				table.remove(global.YSTT, k)
			end
		end
	end
end)
I also modified the steam to mechanical force recipe. You vaporized 10 units of water so you should get back 10 units of water when you condense it, not 2.

Code: Select all

	{
	  type = "recipe",
	  name = "ye_steam2mf_recipe",
	  category = "yrcat_turbine", -- steam to mechanical power
	  enabled = "true",
	  energy_required = 0.10,
	  ingredients = {
		{ type = "fluid", name = "ye_steam" , amount = 120.0, },
	  },
	  results = {
		{ type = "fluid", name = "y-mechanical-force", amount = 10.0, },
		{ type = "fluid", name = "water", amount = 10.0, },
	  },
	  icon = "__yi_engines__/graphics/mf-1.png",
	  order = "0", group = "yi_engines", subgroup = "yie-engines",
	},
Last edited by Fatmice on Sat Jul 25, 2015 7:58 am, edited 1 time in total.
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
Darloth
Fast Inserter
Fast Inserter
Posts: 118
Joined: Sun Jun 08, 2014 3:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Darloth »

Just as a quick piece of balancing feedback:

There's a lot of accumulators in this pack, and while they do have differences those differences are currently not pronounced enough.

The flywheel for example is a great example of something different, high capacity, high discharge, but low charge rate. Only problem is the charge rate is still high enough that I never have any problem charging it, it's done by the time the sun is completely up even on an outpost where a pair of flywheels were providing most of the charge. The charging rate for that could be dropped to present some interesting challenges - I'd like to see circumstances where you'd want to set up the flywheels so they only cut in when the grid is struggling, because it takes maybe a whole day to recharge them otherwise.

The pink crystal accumulator seems to be generally the best, which is fine, and the various yellow crystal accumulators under that are just a better version of their non-crystal cousins. That's okay, but the upgrades seem a little minor. I'm not too sure here, because I haven't really bothered with them yet - the basic versions work just fine for my purposes.

The vanilla accumulators seem to be taking the lowtech, low capacity, high charge/discharge niche, and I like that.

There's possibly a niche spare that could be filled with something with a medium capacity, high charge rate, and very low trickle discharge - something that would keep going long after all other accumulators have quit, just so you have SOME power.

Hope those thoughts help!
YuokiTani
Smart Inserter
Smart Inserter
Posts: 1037
Joined: Thu May 08, 2014 7:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by YuokiTani »

@Fatmice

Thank you very much. I have tested the code and add 1 line to prevent a error. So next release will contain your code and the WIP-Machines. And you are right, 10 Water in, 10 should come out. The idea was to use this condensate/or a lower MF-output to self-feeding the engine itself and separete this from the energy-network. but of course without the heater the system collaps and can't restart without energy for the heater. also it's possible to use the heater-steam for a steam-engine. using this steam-turbine provides MF for the big generators.
so it's more a player-decison how complicated the power-generation can be.
it's more experimenting - i think some other mods have build this cycle in better ways.
Darloth wrote:Just as a quick piece of balancing feedback:
There's a lot of accumulators in this pack, and while they do have differences those differences are currently not pronounced enough.
The flywheel for example is a great example of something different, high capacity, high discharge, but low charge rate. Only problem is the charge rate is still high enough that I never have any problem charging it, it's done by the time the sun is completely up even on an outpost where a pair of flywheels were providing most of the charge. The charging rate for that could be dropped to present some interesting challenges - I'd like to see circumstances where you'd want to set up the flywheels so they only cut in when the grid is struggling, because it takes maybe a whole day to recharge them otherwise.
The pink crystal accumulator seems to be generally the best, which is fine, and the various yellow crystal accumulators under that are just a better version of their non-crystal cousins. That's okay, but the upgrades seem a little minor. I'm not too sure here, because I haven't really bothered with them yet - the basic versions work just fine for my purposes.
The vanilla accumulators seem to be taking the lowtech, low capacity, high charge/discharge niche, and I like that.
There's possibly a niche spare that could be filled with something with a medium capacity, high charge rate, and very low trickle discharge - something that would keep going long after all other accumulators have quit, just so you have SOME power.
Hope those thoughts help!
This thoughts help.
planed is the following because feels like every mod adds accumulators and in modpacks YI-Accumulators not compareable
- remove of small accumulator - only SCD (better graphic)
- only 1 medium accumulator (best graphic wins ^^)
- 2 big accumulators, 1 huge
- remove crystal -> changed to huge
- the flywheel will get a new recipe, focus on mechanical parts and the stored energy will be lowered.
- from Addon-PFW comes later 1 or 2 extreme high capacity-accumulators (battlefield energy-stockpile)
- from Addon-YI-Engines a fluid-based accumulator setup (if i can get it working)

factorio has no more then 3 energy-levels ... if it possible to assign level-numbers (1-10) then i can make different settings.
the flywheel charge-rate equals vanilla-accumulators. and it's designed to capture high-energy spikes (defense) with longer pause between.
Fatmice
Filter Inserter
Filter Inserter
Posts: 808
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Fatmice »

Yes, I know what you are trying to do with the water->steam->water loop. I have loops in my mod as well, a bit more complicated but same principle.

I've already exploited this mechanism with "my own engine". =) Have a look.

All nicely fitted in one chunk, blue-printable.
Steam-cycle-1.jpg
Steam-cycle-1.jpg (965.15 KiB) Viewed 6799 times
115 MW in one chunk. 12 MW upkeep, 103 MW net. A beacon with efficiency module 3 next to each of the overheater will shave another 4 MW from upkeep. ;) So 8 MW investment leads to 103 MW of net production? Yes please. :!:
Steam-cycle-2.jpg
Steam-cycle-2.jpg (678.8 KiB) Viewed 6799 times
It even makes 4 Mixed Solid Fuel Block / min, which can be put to use.
Steam-cycle-3.jpg
Steam-cycle-3.jpg (787.18 KiB) Viewed 6799 times
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
YuokiTani
Smart Inserter
Smart Inserter
Posts: 1037
Joined: Thu May 08, 2014 7:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by YuokiTani »

yep very exploiting :) - but the way is the goal - building, thinking, improve stuff and setups
it will not fit in a chunk, because the graphics should also look as they can deliver that much power - so the 3x3's to small :)
and building this piece of machinery should be a extra challange ^^

after the code works it's easy to balance this over adjusting fluid-amount, temperature or heat_capacity.
Fatmice
Filter Inserter
Filter Inserter
Posts: 808
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Fatmice »

Nothing so complicated, you only need to adjust from code. Just change the temperature of MF that's produced by the steam-turbine to balance how many rensuir can be run on it.
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
YuokiTani
Smart Inserter
Smart Inserter
Posts: 1037
Joined: Thu May 08, 2014 7:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by YuokiTani »

here thats more the planed size for this machinery ... steam-engine for size comparsion.
Image

i uploaded also a new yi_engines version (0.1.4).
description & download in yi_engines-thread
Darloth
Fast Inserter
Fast Inserter
Posts: 118
Joined: Sun Jun 08, 2014 3:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Darloth »

This is super nit-picky, but I've just noticed and now cannot unsee...

When oriented vertically, the current Steam Turbine graphic has two cogs on the end, and one large toothed wheel in the middle. These cogs turn in opposite directions, meaning one of them is wrong and would not mesh with the toothed wheel, and it looks like they're intended to do so.

They should both turn anti-clockwise since the rest of the turbine is turning clockwise.
Fatmice
Filter Inserter
Filter Inserter
Posts: 808
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Fatmice »

This is because the background art is static. Of course they will not be that way when he replaces it with the real sprite.
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
YuokiTani
Smart Inserter
Smart Inserter
Posts: 1037
Joined: Thu May 08, 2014 7:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by YuokiTani »

Darloth wrote:When oriented vertically, the current Steam Turbine graphic has two cogs on the end, and one large toothed wheel in the middle. These cogs turn in opposite directions, meaning one of them is wrong and would not mesh with the toothed wheel, and it looks like they're intended to do so.
They should both turn anti-clockwise since the rest of the turbine is turning clockwise.
you the frist one which takes a closer look at the graphics. it's true small left and right gogs should spin same direction, but as i made this animation i made little mistake, i mirrored the left cog. this makes animation easier, because i only need to animate the left side. After finishing and viewing this ingame i found this annoying but not gamebreaking ;) Also the cogs does not spin in correct speed because for animation i need to make sure i end always with a tooth at top, independently how many tooths i choose - if i don't do this, this cogs will jump - looks more weird as wrong direction.
Inside of the gearbox is also mirrored, but i spins correct directions.

yep the graphics above only placeholder for easier experimentations and the steam-turbine for this will look very different.
tmoore
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Oct 06, 2014 8:33 am
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by tmoore »

This is a really interesting mod for Factiorio, and Research would make it even more interesting.
Even though you like things simple; that can still be the case, all you would need is a config setting
in your ini file that would say "Disable_Research = True" and if its true, give you all the technology.
Otherwise you can research it bit by bit :)
Darloth
Fast Inserter
Fast Inserter
Posts: 118
Joined: Sun Jun 08, 2014 3:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Darloth »

Your storage bunkers are not accessible by the circuit network - clicking them with a circuit on the cursor just opens them.

Edit: Also, the shadow on the UPS flywheel is too dark compared to other shadows in the game.
Fatmice
Filter Inserter
Filter Inserter
Posts: 808
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Fatmice »

Yuoki, I updated yi_engines to go on a global ticker for MP compatibility.

Code: Select all

require "defines"

game.on_init(function()
	if global.TickerA == nil then
		global.TickerA = 59
	end
	if global.TickerB == nil then
		global.TickerB = 5
	end

end)

game.on_load(function()
	if global.TickerA == nil then
		global.TickerA = 59
	end
	if global.TickerB == nil then
		global.TickerB = 5
	end
end)

-- following code by Fatmice, used with permission
game.on_event(defines.events.on_built_entity, function(event)
   Registration(event.created_entity)
end)
game.on_event(defines.events.on_robot_built_entity, function(event)
   Registration(event.created_entity)
end)
game.on_event(defines.events.on_preplayer_mined_item, function(event) 
   Unregistration(event.entity)
end)
game.on_event(defines.events.on_robot_pre_mined, function(event)
   Unregistration(event.entity)
end)
game.on_event(defines.events.on_entity_died, function(event)
   Unregistration(event.entity)
end)

function Registration(entity)
   if entity.name == "y-gearbox-power" then
      if global.YGBX == nil then
         global.YGBX = {}
      end
      local yegearboxen = {}
      yegearboxen[1] = entity
      table.insert(global.YGBX, yegearboxen)
   elseif entity.name == "ye_overheater" then
      if global.YFYO == nil then
         global.YFYO = {}
      end
      local ye_overh = {}
      ye_overh[1] = entity
      table.insert(global.YFYO, ye_overh)
   elseif entity.name == "ye_sturbine" then
      if global.YSTT == nil then
         global.YSTT = {}
      end
      local yesturbines = {}
      yesturbines[1] = entity
      table.insert(global.YSTT, yesturbines)
   end
end

function Unregistration(entity)
   if entity.name == "y-gearbox-power" then
      local found_index
      local found_entity
      for index,entry in pairs(global.YGBX) do
         if entry[1] == entity then
            found_index = index
            found_entity = entry
            break
         end
      end
      table.remove(global.YGBX, index)
   elseif entity.name == "ye_overheater" then
      local found_index
      local found_entity
      for index,entry in pairs(global.YFYO) do
         if entry[1] == entity then
            found_index = index
            found_entity = entry
            break
         end
      end
      table.remove(global.YFYO, index)
   elseif entity.name == "ye_sturbine" then
      local found_index
      local found_entity
      for index,entry in pairs(global.YSTT) do
         if entry[1] == entity then
            found_index = index
            found_entity = entry
            break
         end
      end
      table.remove(global.YSTT, index)
   end
end

game.on_event(defines.events.on_tick, function(event)
	if global.TickerA == 0 then
		global.TickerA = 59
		--For things that tick each second
	else
		global.TickerA = global.TickerA - 1
	end
	if global.TickerB == 0 then
		global.TickerB = 5
		--For things that tick every 5/60th second
		gearbox()
		overHeater()
		steamTurbine()
	else
		global.TickerB = global.TickerB - 1
	end
	--For things that tick every 1/60th second
end)

function gearbox()
	if global.YGBX ~= nil then
		for k,YGBX in pairs(global.YGBX) do
			if YGBX[1].valid then
				local fbin=1
				local fbout=3
				local yegearboxin = {}   
				-- added line because aritmethic-error in line 107 
				yegearboxin.temperature = 0 		
				if YGBX[1].fluidbox[fbin] ~= nil then
					yegearboxin = YGBX[1].fluidbox[fbin]
				end
				if YGBX[1].fluidbox[fbout] ~= nil then
					YGBX[1].fluidbox[fbout] = {
						["type"] = YGBX[1].fluidbox[fbout].type,
						["amount"] = YGBX[1].fluidbox[fbout].amount,
						["temperature"] = yegearboxin.temperature + 100				  
					}
				end
			else
				table.remove(global.YGBX, k)
			end
		end
	end
end

function overHeater()
	if global.YFYO ~= nil then
		for k,YFYO in pairs(global.YFYO) do
			if YFYO[1].valid then
				local fbin=1
				local fbout=2
				if YFYO[1].fluidbox[fbin] ~= nil then
					if YFYO[1].fluidbox[fbin].temperature > 92 then
						if YFYO[1].fluidbox[fbout] ~= nil then
							YFYO[1].fluidbox[fbout] = {
								["type"] = YFYO[1].fluidbox[fbout].type,
								["amount"] = YFYO[1].fluidbox[fbout].amount,
								["temperature"] = 275
							}
						end
					end
				end
			else
				table.remove(global.YFYO, k)
			end
		end
	end
end

function steamTurbine()
	if global.YSTT ~= nil then
		for k,YSTT in pairs(global.YSTT) do
			if YSTT[1].valid then
				local fbin=1
				local fbout_mechForce=2
				local fbout_water=3
				if YSTT[1].fluidbox[fbin] ~= nil then
					if YSTT[1].fluidbox[fbout_mechForce] ~= nil and YSTT[1].fluidbox[fbin]["temperature"] > 205 then
						YSTT[1].fluidbox[fbout_mechForce] = {
							["type"] = YSTT[1].fluidbox[fbout_mechForce].type,
							["amount"] = YSTT[1].fluidbox[fbout_mechForce].amount,
							["temperature"] = 400
						}
				   end
				   if YSTT[1].fluidbox[fbout_water] ~= nil and YSTT[1].fluidbox[fbin]["temperature"] > 205 then
						YSTT[1].fluidbox[fbout_water] = {
							["type"] = YSTT[1].fluidbox[fbout_water].type,
							["amount"] = YSTT[1].fluidbox[fbout_water].amount,
							["temperature"] = 86
						}
				   end
				end
			else
				table.remove(global.YSTT, k)
			end
		end
	end
end
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by orzelek »

Did you try to use this kind of code for timing:

Code: Select all

if ( game.tick % 5 ) == 0 then ... end
Replace 5 by interval you want the functions to be executed?

You seem to be doing lots of work with those ticks that seems not really needed :D
Fatmice
Filter Inserter
Filter Inserter
Posts: 808
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Fatmice »

Modulo is defined as a % b => a - math.floor(a/b)*b, isn't that already even more work than just subtracting? ;)
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
Darloth
Fast Inserter
Fast Inserter
Posts: 118
Joined: Sun Jun 08, 2014 3:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Darloth »

That's how it's defined for humans, but there are optimizations for some hardware, especially on powers of 2.

That said, we're using lua - I doubt lua optimizes particularly well no matter the hardware.

THAT said, computers are ridiculously fast nowadays, and can perform millions of divisions per second, an extra couple per tick isn't going to slow anything down much (unless it does - but solve that when you come to it. Basically, you can afford to make things clearer at the expense of a division here and there nowadays unless you're running on an ARM or something embedded)

If you really cared, you'd need to profile it. That if then else statement isn't free either.

If you've got something that works, keep using it. If not, go for something simple, and if you need more performance optimize it then :)
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by orzelek »

I can't say much about lua - but modulo is one cpu instruction especially when done on integer. Probably irrelevant for lua :D

And when talking about those... few math operations are most likely to be faster then anything involving conditional - but my knowledge of CPU's architectures might be tad old (branching has some drawbacks).

And all that counting you are doing looks.. error prone. Modulo is simple. And with performance it's as Darloth said - most likely irrelevant.
Fatmice
Filter Inserter
Filter Inserter
Posts: 808
Joined: Thu Dec 04, 2014 11:03 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by Fatmice »

In either case, conditionals are involved (there is no going around it) and I just looked at modulo implementation for lua. It used C math library, obviously since lua is just a virtual machine, and is indeed

Code: Select all

lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2) {
  switch (op) {
    case LUA_OPADD: return luai_numadd(NULL, v1, v2);
    case LUA_OPSUB: return luai_numsub(NULL, v1, v2);
    case LUA_OPMUL: return luai_nummul(NULL, v1, v2);
    case LUA_OPDIV: return luai_numdiv(NULL, v1, v2);
    case LUA_OPMOD: return luai_nummod(NULL, v1, v2);
    case LUA_OPPOW: return luai_numpow(NULL, v1, v2);
    case LUA_OPUNM: return luai_numunm(NULL, v1);
    default: lua_assert(0); return 0;
  }
}

Code: Select all

/*
@@ The luai_num* macros define the primitive operations over numbers.
*/

/* the following operations need the math library */
#if defined(lobject_c) || defined(lvm_c)
#include <math.h>
#define luai_nummod(L,a,b)	((a) - floor((a)/(b))*(b))
#define luai_numpow(L,a,b)	(pow(a,b))
#endif
I count 4 operations just for the modulo: negation, division, multiplication, and a floor (which is at least two more operations). Add on top of that the compare operation

Code: Select all

LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
  StkId o1, o2;
  int i = 0;
  lua_lock(L);  /* may call tag method */
  o1 = index2addr(L, index1);
  o2 = index2addr(L, index2);
  if (isvalid(o1) && isvalid(o2)) {
    switch (op) {
      case LUA_OPEQ: i = equalobj(L, o1, o2); break;
      case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
      case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
      default: api_check(L, 0, "invalid option");
    }
  }
  lua_unlock(L);
  return i;
}
All of that just to operate

Code: Select all

if ( game.tick % 5 ) == 0 then ... end
Whereas, my tick counting is simply: compare, assignment, and a negation. I don't see how counting is anymore error prone than modulo. Indeed, all primitive operations are themselves either bit counting or bit shifting. Performance wise? You won't notice anything until you use very large numbers and by then modulo is limited by the size of the type of game.tick, which I'm guessing they will use a unsigned long (that gives you 2.28 years worth of game time before it overflows), whereas my counting method don't matter since my method never overflows, even if game.tick is ungodly big_int and limited by system memory.
Maintainer and developer of Atomic Power. See here for more information.
Current release: 0.6.6 - Requires 0.14.x
Example build - Requires 0.14.x
tmoore
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Oct 06, 2014 8:33 am
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by tmoore »

Youki, if you would like, I could localize your items for English. Your english isn't bad, but a few of your item names, need adjusting.
YuokiTani
Smart Inserter
Smart Inserter
Posts: 1037
Joined: Thu May 08, 2014 7:57 pm
Contact:

Re: Yuoki Industries - Informations, Suggestions, Questions

Post by YuokiTani »

tmoore wrote:Youki, if you would like, I could localize your items for English. Your english isn't bad, but a few of your item names, need adjusting.
okay ... but how you would explain all the fantasy names ? ;) - but of course you can try your best
don't use the german-translation as reference.
thanks new factorio f0.22 you don't need make any description because it destroys the right info-window if it's longer then maybe 24 chars.

thanks for all other postings !
goes directly -> ToDo-List

improved/reworked for next version - walls (not perfect but better)
Image
Post Reply

Return to “Yuoki Industries”