Giter VIP home page Giter VIP logo

boomstick's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

beanzilla

boomstick's Issues

If firing a weapon causes a crash, it will also cause a secondary crash on the next startup.

I believe projectile.lua:140: bad argument #1 to 'punch' (userdata expected, got nil) is occurring because whatever userdata was supposed to be passed to punch before the crash is now nil. The function that calls punch should return early if userdata is nil.

AsyncErr: Lua: Runtime error from mod 'boomstick' in callback luaentity_Step(): ...ua/.minetest/mods/boomstick/boomstick_api/projectile.lua:140: bad argument #1 to 'punch' (userdata expected, got nil)
stack traceback:
	[C]: in function 'punch'
	...ua/.minetest/mods/boomstick/boomstick_api/projectile.lua:140: in function 'do_damage'
	...ua/.minetest/mods/boomstick/boomstick_api/projectile.lua:178: in function <...ua/.minetest/mods/boomstick/boomstick_api/projectile.lua:166>

Code Review on boomstick_api

Hey, just thought I would let you know some spots where you could improve your code.

-- boomstick_api/weapon.lua line=175
function boomstick_api.create_new_category(name, base, category)
    -- Inherit any default values from a base, if one is provided.
    if base ~= nil then

Reorder optional parameters to the end:

I'm using {...} to indicate a table with values, just to show how it will look

-- Not inheriting from base with current code
boomstick_api.create_new_category("test", nil, {...})

-- Changing the ordering so base is at the end becomes
boomstick_api.create_new_category("test", {...})

-- Or if we were to inherit defaults from base...
boomstick_api.create_new_category("test", {...}, {...})

Why reorder? Currently the code demands that optional field to be filled in, either by a table or nil, reordering it so it's at the end allows it to become a proper optional field. (Of course if you had multiple optional fields then you'd still have to put the nil as a spacer)

Change:

-- boomstick_api/weapon.lua line=175
function boomstick_api.create_new_category(name, category, base)
    -- Inherit any default values from a base, if one is provided.
    if base ~= nil then

This should not produce any known issues.
(Current code which uses this might need to change it's order too)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.