set_gravity
This commit is contained in:
parent
f5b2e516fe
commit
30bd8715f5
63
blocks/set_gravity.lua
Normal file
63
blocks/set_gravity.lua
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
local use_player_monoids = minetest.global_exists("player_monoids")
|
||||||
|
|
||||||
|
local update_formspec = function(meta, pos)
|
||||||
|
local gravity = meta:get_string("gravity")
|
||||||
|
meta:set_string("infotext", "Set-gravity block: '" .. gravity .. "'")
|
||||||
|
|
||||||
|
meta:set_string("formspec", "size[8,2;]" ..
|
||||||
|
-- col 1
|
||||||
|
"field[0.2,0.5;8,1;gravity;Gravity;" .. gravity .. "]" ..
|
||||||
|
|
||||||
|
-- col 2
|
||||||
|
"button_exit[0.1,1.5;8,1;save;Save]" ..
|
||||||
|
"")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_node("epic:command", {
|
||||||
|
description = "Epic command block",
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=3,oddly_breakable_by_hand=3,epic=1},
|
||||||
|
on_rotate = screwdriver.rotate_simple,
|
||||||
|
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("gravity", "9.81")
|
||||||
|
update_formspec(meta, pos)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
|
||||||
|
if not sender or minetest.is_protected(pos, sender:get_player_name()) then
|
||||||
|
-- not allowed
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if fields.save then
|
||||||
|
meta:set_string("gravity", fields.gravity or "9.81")
|
||||||
|
update_formspec(meta, pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
|
epic = {
|
||||||
|
on_enter = function(pos, meta, player, ctx)
|
||||||
|
local gravity = tonumber(meta:get_string("gravity")) or 9.81
|
||||||
|
if use_player_monoids then
|
||||||
|
player_monoids.gravity:add_change(player, gravity, "epic:set_gravity")
|
||||||
|
else
|
||||||
|
player:set_physics_override({ gravity = gravity })
|
||||||
|
end
|
||||||
|
ctx.next()
|
||||||
|
end
|
||||||
|
}
|
||||||
|
})
|
1
init.lua
1
init.lua
@ -17,6 +17,7 @@ dofile(MP.."/blocks/command.lua")
|
|||||||
dofile(MP.."/blocks/delay.lua")
|
dofile(MP.."/blocks/delay.lua")
|
||||||
dofile(MP.."/blocks/call.lua")
|
dofile(MP.."/blocks/call.lua")
|
||||||
dofile(MP.."/blocks/branch.lua")
|
dofile(MP.."/blocks/branch.lua")
|
||||||
|
dofile(MP.."/blocks/set_gravity.lua")
|
||||||
|
|
||||||
if minetest.get_modpath("mobs") then
|
if minetest.get_modpath("mobs") then
|
||||||
dofile(MP.."/blocks/spawn_mob.lua")
|
dofile(MP.."/blocks/spawn_mob.lua")
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = epic
|
name = epic
|
||||||
description = Enhanced Programmer for Ingame Control
|
description = Enhanced Programmer for Ingame Control
|
||||||
depends = screwdriver,default
|
depends = screwdriver,default
|
||||||
optional_depends = mobs,mesecons
|
optional_depends = mobs,mesecons,player_monoids
|
||||||
|
@ -19,6 +19,7 @@ WIP
|
|||||||
* [x] Branch-multiple
|
* [x] Branch-multiple
|
||||||
* [x] Call function
|
* [x] Call function
|
||||||
* [x] Mesecon emitter
|
* [x] Mesecon emitter
|
||||||
|
* [x] Set gravity
|
||||||
* [ ] Epic: main-function
|
* [ ] Epic: main-function
|
||||||
* [ ] Epic: timeout-function
|
* [ ] Epic: timeout-function
|
||||||
|
|
||||||
@ -34,7 +35,6 @@ WIP
|
|||||||
* [ ] Unstash inventory
|
* [ ] Unstash inventory
|
||||||
* [ ] HUD vignette
|
* [ ] HUD vignette
|
||||||
* [ ] Check priv (conditional)
|
* [ ] Check priv (conditional)
|
||||||
* [ ] Set gravity
|
|
||||||
* [ ] Set skybox
|
* [ ] Set skybox
|
||||||
* [ ] Collision box
|
* [ ] Collision box
|
||||||
* [ ] Formspec message
|
* [ ] Formspec message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user