technic_run.lua 605 B

1234567891011121314151617181920212223
  1. jumpdrive.technic_run = function(pos, node)
  2. local meta = minetest.get_meta(pos)
  3. jumpdrive.migrate_engine_meta(pos, meta)
  4. local eu_input = meta:get_int("HV_EU_input")
  5. local store = meta:get_int("powerstorage")
  6. local power_requirement = meta:get_int("power_requirement")
  7. local max_store = meta:get_int("max_powerstorage")
  8. if store < max_store then
  9. -- charge
  10. meta:set_int("HV_EU_demand", power_requirement)
  11. store = store + eu_input
  12. meta:set_int("powerstorage", math.min(store, max_store))
  13. else
  14. -- charged
  15. meta:set_int("HV_EU_demand", 0)
  16. end
  17. jumpdrive.update_infotext(meta, pos)
  18. end