BuckarooBanzay / epic

epic -- Enhanced Programmer for Ingame Control
Other
6 stars 2 forks source link

Check armor block doesnt work #23

Closed MisterE123 closed 4 years ago

MisterE123 commented 4 years ago

Untitled

in the pic above, the check armor block is used to continue the game if the armor inv is empty, else it will "bounce" the player with a teleport block and say "take off your armor first!"

What happens actually is that it allows the game to continue despite players having armor on. It is no different than a no-op block

BuckarooBanzay commented 4 years ago

I've heard that before but wasn't sure this was actually a bug, thanks for testing :+1:

MisterE123 commented 4 years ago

when I put: minetest.chat_send_all(dump(player_inv:get_lists())) right after line 20, I get a print-out of all the lists of the player's inventory. I do not see a list named 'armor'. I wonder where player armor is stored...

MisterE123 commented 4 years ago

Yep, I can confirm that the armor inventory is a detached inventory. I should post a bugfix in a moment

MisterE123 commented 4 years ago

Ok... here is the bugfix:

change blocks/check_empty_armor.lua to read:

`


minetest.register_node("epic:check_empty_armor", {
    description = "Epic check empty armor block: checks if the armor-inventory is empty",
    tiles = {
        "epic_node_bg.png",
        "epic_node_bg.png",
        "epic_node_bg.png",
        "epic_node_bg.png",
        "epic_node_bg.png",
        "epic_node_bg.png^epic_briefcase.png",
    },
    paramtype2 = "facedir",
    groups = {cracky=3,oddly_breakable_by_hand=3,epic=1},
    on_rotate = screwdriver.rotate_simple,

    epic = {
    on_check = function(_, _, player, ctx)
            local player_name = player:get_player_name()
            local player_armor_inv = minetest.get_inventory({type="detached", name=player_name.."_armor"})

            if player_armor_inv:is_empty("armor") then

                ctx.next()
            end

    end
  }
})

`

MisterE123 commented 4 years ago

opened a pull request to fix the issue

27

BuckarooBanzay commented 4 years ago

closing this, feel free to reopen if the problem persists