From 55221272978a4f8bb283747c66cb08743bbbc9a8 Mon Sep 17 00:00:00 2001 From: cheapie Date: Mon, 1 Feb 2016 16:24:16 -0600 Subject: Simplify behavior --- README | 6 +----- init.lua | 23 +++-------------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/README b/README index c96ee24..5168c5c 100644 --- a/README +++ b/README @@ -23,13 +23,9 @@ Use: Punch anything with a "Car" to turn into a car. You will only be able to see it from third-person view (press F7). This has the following effects: -* Takes your "Car" -* Gives you an "Un-Car" * Makes you appear to be a car * Makes you faster (if anticheat is off), unable to jump, and heavier Note that it does *not* change your collision box or anything related to that, in an attempt to maintain compatibility with narrow roads. -Once you are a car, you can punch anything with an "Un-Car" to restore everything to normal. - -If you leave and rejoin, you will be a human (or whatever you normally are) again, but still have an "Un-Car". Punch anything with it to turn it back into a "Car". +Once you are a car, you can punch anything with a "car" (again) to restore everything to normal. diff --git a/init.lua b/init.lua index 0e09fc2..6616555 100644 --- a/init.lua +++ b/init.lua @@ -1,39 +1,22 @@ -cars = {} -cars.current_cars = {} - +cars = {["current_cars"]={}} minetest.register_craftitem("cars:car",{ description = "Car", inventory_image = "cars_car_inv.png", - stack_max = 1, on_use = function(_,user) local name = user:get_player_name() if cars.current_cars[name] == nil then cars.current_cars[name] = {} cars.current_cars[name].properties = user:get_properties() cars.current_cars[name].physics_override = user:get_physics_override() - user:set_properties({mesh="cars_car.obj",textures={"cars_car.png"}}) + user:set_properties({visual="mesh",visual_size={x=1,y=1},mesh="cars_car.obj",textures={"cars_car.png"}}) user:set_physics_override({speed=(minetest.setting_getbool("disable_anticheat")== true and 1.5 or 1),jump=0,gravity=2}) - end - return ItemStack("cars:uncar 1") - end} -) - -minetest.register_craftitem("cars:uncar",{ - description = "Un-Car", - inventory_image = "cars_uncar_inv.png", - stack_max = 1, - groups = {not_in_creative_inventory=1}, - on_use = function(_,user) - local name = user:get_player_name() - if cars.current_cars[name] ~= nil then + else user:set_properties(cars.current_cars[name].properties) user:set_physics_override(cars.current_cars[name].physics_override) cars.current_cars[name] = nil end - return ItemStack("cars:car 1") end} ) - minetest.register_craft({output="cars:car 1",recipe={ {"default:glass","default:steel_ingot",""}, {"homedecor:motor","default:steel_ingot","default:steel_ingot"}, -- cgit v1.2.3