actually add the api calls... oops
This commit is contained in:
parent
6b2bee3ef9
commit
f93e52b080
16
sparkapi/lua/energy.lua
Normal file
16
sparkapi/lua/energy.lua
Normal file
@ -0,0 +1,16 @@
|
||||
if not sparktech then sparktech = {} end
|
||||
|
||||
function sparktech.can_drain_energy(target_pos, ammount) ---
|
||||
--- check whether you can drain
|
||||
return minetest.get_meta(target_pos):get_int("energy") >= ammount
|
||||
end
|
||||
|
||||
function sparktech.drain_energy(target_pos, ammount)
|
||||
local target = minetest.get_meta(target_pos)
|
||||
local current = target:get_int("energy")
|
||||
if sparktech.can_drain_energy(target_pos, ammount) then
|
||||
target:set_int("energy", current - ammount)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user