Jump to content

Remaining uses/drainable level in lua?


ThePengu

Recommended Posts

So I am looking for any information on retrieving and altering the remaining durability of a battery in code.

 

I'm not finding much documentation on their use. Or any mods that make use of them in order to see how it is done.

 

By the looks of things, in a multiplayer game I can use a torch, deplete the battery partially. Extract the battery and it is returned to max life. 

From the look of the recipes, taking the battery out just seems to craft a brand new one. Though I may be mistaken.

Does this mean storing the depletion of a battery is not implemented yet? (Build 27)

 

I would be really happy for any information regarding retrieving or altering the life of a battery in lua.

 

Also greetings! ~ 

Link to comment
Share on other sites

hello,

 

if you have a handle to the battery item in lua then you can use item:getDelta() and item:setDelta() for the power the battery currently has, this is defined as a float number 0.0 to 1.0.

for the usage delta per use (defined in the items.txt script usually) you can use item:getUseDelta() and item:setUseDelta(), same float as above.

 

also, this mod uses batteries for most of its devices so maybe snooping around in the code may be helpfull to what your trying to do.

(try this one for example: media/lua/shared/ApCom/items/ApComTapeRecorder.lua)

 

regards,

turbo

Link to comment
Share on other sites

So I am looking for any information on retrieving and altering the remaining durability of a battery in code.

 

I'm not finding much documentation on their use. Or any mods that make use of them in order to see how it is done.

 

By the looks of things, in a multiplayer game I can use a torch, deplete the battery partially. Extract the battery and it is returned to max life. 

From the look of the recipes, taking the battery out just seems to craft a brand new one. Though I may be mistaken.

Does this mean storing the depletion of a battery is not implemented yet? (Build 27)

 

I would be really happy for any information regarding retrieving or altering the life of a battery in lua.

 

Also greetings! ~ 

Welcome, if you like follow your future topics for notification for new post like this one. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...