• How can I convert an entity output to a Lua variable?
    12 replies, posted
ex: I set the max charge of item_suitcharger to 800, and flag for citadel charger. Someone used 67 of it, how do I retrieve the new remaining charge of 733? I want to know so I can fix the animation progressing too quickly, by using Entity/SetCycle(1-(remCharge/800)) I'm not sure how to read entity outputs in Lua, and convert that into a variable. I need to read "OutRemainingCharge" I've looked through item_suitcharger and searched the wiki for both output, later input, out, in, and anything I've tried has just produced Errors, or simply didn't work. This is the last bit of code that I haven't deleted yet, of one thing I've tried. --[[ function child:KeyValue( k, v ) print("hi") if ( tostring(k) == "OutRemainingCharge" ) then self:StoreOutput( k, v ) print(v) end end ]] I assume this doesn't work mainly because I put that exact block of code inside of a GM/OnEntityCreated hook. (I commented it out after testing) I can't think of any other way to retrieve the remaining charge value of a suit charger. Could someone please help?
The animation automatically scales to the maxcharge you set with the SetCharge input
if that was true I wouldn't have made this post. Well, it is true, true-ish... The animation ends after 200 is charged. If I have more than 200 in the charger then this causes it to LOOK empty even when it's not. Starting to charge again will reset it to the appropriate position, until 200 more has been charged, then it looks empty again.
Are you referring to the animation RESETTING? Or that the animation goes to the "empty" position but you can still recharge your armor? Because your video doesn't display proof of the latter like you suggest in your previous posts.
I don't charge it down to 0. Maybe it would be more obvious if I had a way to show the charge remaining, but for that I'd need to be able to do what I made this thread for. It's never resetting. I'm never telling it to reset. This is all on the same original 800. The point is that the meter is moving faster than the charge is really depleting, when I go to charge again it corrects itself only for the first point.
I have just tested it again in all 3 - singleplayer, local and dedicated multiplayer and nothing out of the ordinary happens. I used 2 methods of setting the charge on a charger spawned through the spawnmenu. ent_fire item_suitcharger SetCharge 999 ent_fire item_suitcharger SetCharge 500 lua_run Entity(142):Fire("SetCharge", 999)
nooooooooooo not to set the max charge. I want to SEE the remaining charge, to retrieve the value. Regardless, the question is still about recording entity outputs, not just fixing a suit charger.
Also item_healthcharger does not have a :SetCharge() nor a :Recharge() input. Is there another way?
entity:GetInternalVariable("m_iJuice")) and entity:GetInternalVariable("m_iMaxJuice")) will give you the maximum charge and the current charge left in the suitcharger
Thank you, but you're both right and wrong about the animation. I said that. It works fine if the charger is set to 200, watch my video, I set the max to 800 and it does not work then. I want my charger to have extra juice so other players can return to it a few times before it's finally empty and waiting for a recharge. I'm very grateful for your help, but I wish people would actually read what I say. Either that or I'm very bad at saying things.
You will need Entity/SetSaveValue, Entity/SetKeyValue, Entity/Fire and a bunch of other fucntions to manipulate the internal workings of entities. For example, you can poke around item_suitcharger source to find some interesting things. For healthcharger, source, you can only change the sk_healthcharger ConVar to adjust the behaviour. Good luck. Also yeah, after trying it again and setting the SF_CITADEL_CHARGER flag, the suitcharger behaviour seems broken.
You should've mentioned the spawnflag in the first post. I will get it fixed for next update. You can test it yourself on the Dev branch in 15 minutes from this post.
Awesome thank you! As for changing the console variable, I tried that with the suit charger once recently and it didn't seem to work.
Sorry, you need to Log In to post a reply to this thread.