AmbiguousMonk

Member
  • Content count

    5
  • Joined

  • Last visited

  1. Looping over getBodyParts()

    Thank you for your suggestion Fenris_Wolf and you're absolutely right! However, when I implement your suggestion, like so: local parts = getPlayer():getBodyDamage():getBodyParts(); for i=0, 16 do if parts[i] then parts[i]:RestoreToFullHealth() end if not parts[i] then getPlayer():Say("uh oh") end end , the behavior I witness in game is the player character repeatedly saying "uh oh" without any healing happening at all (I'm calling the function using this code with the OnPlayerUpdate event). This leads me to believe that maybe lua isn't capable of handling the BodyPartType types java is using in these cases? I'm no expert programmer, so I'm not sure this actually is the case, but it seems that every time I attempt to refer to a BodyPart object in lua, I see this kind of erroneous behavior
  2. Looping over getBodyParts()

    I'm attempting to write a function that will loop over each of the body parts of a player and restore them to full health using RestoreToFullHealth(), but it seems that if I loop over them as so: local parts = getPlayer():getBodyDamage():getBodyParts(); for i=0, (getPlayer():getBodyDamage():getBodyParts():size() - 1) do parts[i]:RestoreToFullHealth(); end then I get a "java.lang.RuntimeException: attempted index: RestoreToFullHealth of non-table: null" error and I'm not sure why. Can anyone explain to me why this is happening and/or the appropriate way to accomplish what I'm trying to do?
  3. Does anyone happen to know if OnWeaponHitCharacter will trigger when a zombie hits a player? I know zombies are IsoGameCharacters, but I'm unsure if a zombie hitting a player counts as a HandWeapon being used, so I'm unsure if this event will trigger when it happens. If not, does anyone know what event I should be hooking with to run code when a zombie strikes a player? Additionally, can anyone explain the differences and/or purpose between the keyID field for IsoObjects and the ID field for MovingObjects? Can either of these be used to uniquely identify a IsoZombie or IsoPlayer? Specifically, can they be used to identify an IsoZombie or IsoPlayer by passing that keyID/ID value through a sendServerCommand/sendClientCommand and having the receiver check the keyID/ID against the list of players/zombies to find the specific character in question? Lastly, I understand that sendServerCommand sends a command to the client that can then trigger the event OnServerCommand, but in a multiplayer game with multiple clients, how does one specify which client to send the command to? Does sendServerCommand send that command to all clients, or does the 'player' parameter of it determine which client it gets send to?
  4. Are Persistent Variables Possible?

    Thank you both so much, this is exactly what I had needed. Originally, I wasn't sure why my global variables weren't behaving that way, but later discovered that's because of a design error that was resetting those variables. I've since fixed that. Extra kudos to nater for bringing ModData to my attention, as I didn't know doing that was a possibility and I do need these values to persist across save/load.
  5. Are Persistent Variables Possible?

    Is it possible to declare variables in a lua script that will persistent beyond the lifetime of the function and into further instances? In other words, if I have a script that's called by Events.OnPlayerUpdate.Add(), can I declare a variable that will retain it's value and be used in future instances of that script being triggered by Events.OnPlayerUpdate.Add()? What I want in the end is the ability to store a value that will increment each time that function runs, but the problem I'm having is that the variable appears to get dropped and thus never actually increments. I'm not sure if what I'm looking for is possible or not though