Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spike bushes #5

Open
Ezhh opened this issue Dec 22, 2017 · 8 comments
Open

Add spike bushes #5

Ezhh opened this issue Dec 22, 2017 · 8 comments

Comments

@Ezhh
Copy link
Owner

Ezhh commented Dec 22, 2017

There should be painful things to stumble into in the dark.

@Extex101
Copy link

Extex101 commented Feb 21, 2019

minetest.register_node (name..":bush", {
	description = "Spike bush",
	tiles = {"spiky_bush.png"},
	drawtype = "plantlike",
	groups = {cracky=1},
	walkable =false,
	on_timer = function(pos)
	      local objs = minetest.get_objects_inside_radius(pos, 0.8)
	       for _, player in pairs(objs) do
	            local hp = player:get_hp ()
		        if player:is_player() then
		             if hp > 0 then
		                player:set_hp(hp-1)
		            end
			        break
		        end
	       end
	       return true
    end,
    on_construct = function(pos)
          local timer = minetest.get_node_timer(pos)
	      timer:start(0.6)
    end,
})

Code for spiky bush hurts faster than normal inside block damage
Can be adjusted using the timer:start value
NOTE: may be a bit messy

@Ezhh
Copy link
Owner Author

Ezhh commented Feb 21, 2019

No need for node timers. It's much better to directly add damage. :)

@Extex101
Copy link

Have you given it a try yet?
I'm quite satisfied with how it came out

@Ezhh
Copy link
Owner Author

Ezhh commented Feb 22, 2019

It's just that it's inefficient to run nodetimers without any purpose. You only need:

damage_per_second = 1

(as an example. I might make the damage 2 or 3 instead)

@Extex101
Copy link

OK but the point was that it hurts faster
So you can't just walk straight through without gaining damage...

@Ezhh
Copy link
Owner Author

Ezhh commented Feb 24, 2019

Code I've added to the main game version:

minetest.register_node ("plants:dark_thorns", {
	description = "Dark Thorns",
	drawtype = "plantlike",
	tiles = {"plants_dark_thorns.png"},
	inventory_image = "plants_dark_thorns.png",
	paramtype = "light",
	paramtype2 = "meshoptions",
	place_param2 = 8,
	sunlight_propagstes = true,
	buildable_to = true,
	walkable = false,
	groups = {snappy = 3, attached_node = 1, flora = 1},
	selection_box = {
		type = "fixed",
		fixed = {-6/16, -0.5, -6/16, 6/16, -3/16, 6/16},
	},
	damage_per_second = 2,
})

You can't walk through without taking damage. This is the whole point of damage_per_second .

(I may make further adjustments to groups, especially once we finish tools.)

@Extex101
Copy link

Extex101 commented Feb 24, 2019

No what I was saying is that sometimes ppl can get through the block faster than 1 second

Like I've managed to fall into lava and get out again without getting damaged

@Ezhh
Copy link
Owner Author

Ezhh commented Feb 24, 2019

It's immediate. It doesn't fire after one second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants