#Automatically accomodate nonexistent frames

1 messages · Page 1 of 1 (latest)

umbral swallow
#

My .frames file, currently:

{  
  "frameGrid" : {
    "size" : [40, 10],
    "dimensions" : [5, 1],
    "names" : [
      ["absent", "present.5", "present.4", "present.3", "present.2"]
    ]
  },
  
  "alises": {
    "present.default": "present.5",
    "present.0": "present.2",
    "present.1": "present.2"
  }
}

Relevant section of the .animation file:

{
"properties" : {
  "zLevel" : 4,
  "centered" : true,
  "image" : "<partImage>:present",
  "offset" : [0, 0],
  "transformationGroups" : ["weapon"]
},

"partStates" : {
  "mag" : {
    "present": {
      "properties": {
        "image": "<partImage>:present.<ammo>"
      }
    },
    "absent": {
      "properties": {
        "image": "<partImage>:absent"
      }
    }
  }
}
}

Without having to type an alias for each amount of ammo, how do I accomplish rendering either present.5 and present.2, depending on the amount of ammo remaining in the mag? (The max ammo of the gun is 8)

A workaround I thought of is defining "magAnimRange": [2, 5] in the .weaponability or .activeitem file and doing

animator.setGlobalTag("ammo",
    self.magAnimRange[2] < storage.ammo and self.magAnimRange[2] or
    storage.ammo < self.magAnimRange[1] and self.magAnimRange[1] or
    storage.ammo)

Is there another way to do this?

shrewd fern
#

am a little confused

#

for absent do ""

#

for image

#

then just do 1, 2, 3, 4 instead of present

#

but whatcha mean by the rest @umbral swallow

#

OH do you mean

#

you have 4 frames

#

8 bullets

#

it changes every 2 in this case?

#
local ammoFrame = math.floor(self.magazineFrames * (1 - self.ammo/self.maxAmmo))
animator.setGobalTag("ammoFrame", ammoFrame)
#

thats how i do it

umbral swallow
#

oooh math.floor 😮

#

wait actually idk if that'll work

#

think of the mag as belt-fed into the bottom

#

when the mag is quite full most of the ammo is hidden inside the mag

#

and the mag just loops the ammo (i'll send the updated mag frames later, i altered it a while ago)

#

then as ammo goes lower the belt is fed into the gun, until the tail of the belt is inside the gun

#

doesn't mean there isn't any ammo left - the remaining ammo is hidden within the gun

#

like

8: mag looks full, 3 inside mag, 3 bullets visible, 2 are inside the gun
7: mag looks full, 2 inside mag, 3 bullets visible, 2 are inside the gun
6: 1 in mag, 3 visible, 2 in gun
5: 0 in mag, 3 visible, 2 in gun
4: 0 in mag, 2 visible, 2 in gun
3: 0 in mag, 1 visible, 2 in gun
2: 0 in mag, 0 visible, 2 in gun
1: 0 in mag, 0 visible, 1 in gun
0: 0 in mag, 0 visible, 0 in gun
#

but the math method is kinda giving me an idea lol\

shrewd fern
#

youre still confusing