diff --git a/LuaScriptsLibExt/Readme_For_colliders.lua/example.lvl b/LuaScriptsLibExt/Readme_For_colliders.lua/example.lvl new file mode 100644 index 000000000..6a5753149 --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_colliders.lua/example.lvl @@ -0,0 +1,2318 @@ +64 +0 +"" +-200000 +-200600 +-200000 +-199200 +0 +0 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +-199930 +-200214 +24 +54 +0 +0 +0 +0 +-200032 +-200192 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200000 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200000 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200000 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200000 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200000 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199968 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199968 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199968 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199968 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199968 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199936 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199936 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199936 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199936 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199936 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199904 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199904 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199904 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199904 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199904 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199872 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199872 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199872 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199872 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199872 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199840 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199840 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199840 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199840 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199840 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199808 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199808 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199808 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199808 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199808 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199776 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199776 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199776 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199776 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199776 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199744 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199744 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199744 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199744 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199744 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199712 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199712 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199712 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199712 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199712 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199680 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199680 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199680 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199680 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199680 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199648 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199648 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199648 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199648 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199648 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200160 +32 +32 +315 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200128 +32 +32 +257 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199584 +-200128 +32 +128 +319 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199584 +-200096 +32 +128 +320 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199584 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199584 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199552 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199552 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199520 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199520 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199488 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199488 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199456 +-200128 +32 +32 +316 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199456 +-200096 +32 +32 +258 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199456 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199456 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199424 +-200160 +32 +64 +365 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199424 +-200128 +32 +32 +258 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199424 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199424 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199424 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199392 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199392 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199392 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199392 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200192 +32 +64 +365 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200160 +32 +32 +258 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199328 +-200160 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199328 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199328 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199328 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199328 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200192 +32 +64 +366 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200160 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199264 +-200160 +32 +32 +257 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199264 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199264 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199264 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199264 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199232 +-200160 +32 +32 +250 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199232 +-200128 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199232 +-200096 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199232 +-200064 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199232 +-200032 +32 +32 +251 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199200 +-200192 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"next" +"next" +"next" +"next" +"next" +"Default" +#FALSE# +"Destroyed Blocks" +#TRUE# +"Spawned NPCs" +#FALSE# +"next" +"Level - Start" +"" +0 +0 +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +"" +0 +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +"P Switch - Start" +"" +0 +0 +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +"" +0 +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +"P Switch - End" +"" +0 +0 +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +"" +0 +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 diff --git a/LuaScriptsLibExt/Readme_For_colliders.lua/example/lunadll.lua b/LuaScriptsLibExt/Readme_For_colliders.lua/example/lunadll.lua new file mode 100644 index 000000000..e6dc0cf9d --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_colliders.lua/example/lunadll.lua @@ -0,0 +1,43 @@ +colliders = loadSharedAPI("colliders"); + +local point = colliders.Point(-199824, -200208); +point:Debug(true); + +local box = colliders.Box(-199740, -200224, 32, 32); +box:Debug(true); + +local circle = colliders.Circle(-199624, -200208, 16); +circle:Debug(true); + +local tri = colliders.Tri(-199524, -200208, {-16,16}, {0,-16}, {16, 16}); +tri:Debug(true); + +local poly = colliders.Poly(-199424, -200208, {-16,16}, {0,-16}, {16, 16}, {0,0}); +poly:Debug(true); + +function onLoop() + local s = {}; + + if colliders.collide(player, point) then + table.insert(s, "point"); + end + if colliders.collide(player, box) then + table.insert(s, "box"); + end + if colliders.collide(player, circle) then + table.insert(s, "circle"); + end + if colliders.collide(player, tri) then + table.insert(s, "tri"); + end + if colliders.collide(player, poly) then + table.insert(s, "poly"); + end + + + local y = 0; + for _,v in ipairs(s) do + printText(v,0,y); + y = y + 20; + end +end \ No newline at end of file diff --git a/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/lunaworld.lua b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/lunaworld.lua new file mode 100644 index 000000000..aff7dcadc --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/lunaworld.lua @@ -0,0 +1,7 @@ +_smb3overhaul = loadAPI("smb3overhaul"); + +function onLoad() + _smb3overhaul.setSecondsLeft(200); + _smb3overhaul.setTimerState(true); +end + diff --git a/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/test.lvl b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/test.lvl new file mode 100644 index 000000000..e3a709ff2 --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/test.lvl @@ -0,0 +1,4102 @@ +64 +0 +"World 1-1" +-200192 +-201120 +-199936 +-196800 +1 +0 +#FALSE# +#FALSE# +1 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +16291944 +#FALSE# +#FALSE# +0 +#FALSE# +#FALSE# +"" +-199898 +-200086 +24 +54 +-199938 +-200092 +24 +60 +-200032 +-200032 +32 +32 +7 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200032 +-200000 +32 +32 +15 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200032 +-199968 +32 +32 +15 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-200000 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199968 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199936 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199904 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199872 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199840 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199808 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199776 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199744 +-200160 +32 +32 +4 +1034 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199744 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199712 +-200160 +32 +32 +5 +1 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199712 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199680 +-200160 +32 +32 +4 +1034 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199680 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199648 +-200160 +32 +32 +5 +1 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199648 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200160 +32 +32 +4 +1034 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199616 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199584 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199584 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199552 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199552 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199520 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199520 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199488 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199488 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199456 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199456 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199424 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199424 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199392 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199392 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199360 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199328 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199328 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199296 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199264 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199264 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199232 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199232 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199200 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199200 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199168 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199168 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199136 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199104 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199072 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199040 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-199008 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198976 +-200160 +32 +32 +5 +1 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198976 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198944 +-200160 +32 +32 +5 +1 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198944 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198912 +-200288 +32 +32 +5 +1 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198912 +-200160 +128 +64 +25 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198912 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198880 +-200288 +32 +32 +5 +1 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198880 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198848 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198816 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198784 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198752 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198720 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198688 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198656 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198624 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198592 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198560 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198528 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198496 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198464 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198432 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198400 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198368 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198336 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198304 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198304 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198272 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198272 +-200128 +96 +160 +25 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198272 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198240 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198240 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198208 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198208 +-200224 +192 +224 +27 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198208 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198176 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198176 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198144 +-200960 +32 +32 +5 +1090 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198144 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198144 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198112 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198112 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198080 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198080 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198048 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198048 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198016 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-198016 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197984 +-200832 +32 +32 +8 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197984 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197952 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197920 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197888 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197856 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197824 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197792 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197760 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197728 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197696 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197664 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197632 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197600 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197568 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197536 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197504 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197472 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197440 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197408 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197376 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197344 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197312 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197280 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197248 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197216 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197184 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197152 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197120 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197088 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197056 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-197024 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-196992 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-196960 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-196928 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-196896 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-196864 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-196832 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +-196800 +-200032 +32 +32 +3 +0 +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"next" +-200256 +-200000 +12 +"Default" +-200192 +-200000 +12 +"Default" +-200128 +-200000 +12 +"Default" +-200064 +-200000 +12 +"Default" +-200000 +-200000 +12 +"Default" +-199936 +-200000 +12 +"Default" +-199872 +-200000 +12 +"Default" +-199808 +-200000 +12 +"Default" +-199744 +-200000 +12 +"Default" +-199680 +-200000 +12 +"Default" +-199616 +-200000 +12 +"Default" +-199552 +-200000 +12 +"Default" +-199488 +-200000 +12 +"Default" +-199424 +-200000 +12 +"Default" +-199360 +-200000 +12 +"Default" +-199296 +-200000 +12 +"Default" +-199232 +-200000 +12 +"Default" +-199168 +-200000 +12 +"Default" +-199104 +-200000 +12 +"Default" +-199040 +-200000 +12 +"Default" +-198976 +-200000 +12 +"Default" +-198912 +-200000 +12 +"Default" +-198848 +-200000 +12 +"Default" +-198784 +-200000 +12 +"Default" +-198720 +-200000 +12 +"Default" +-198656 +-200000 +12 +"Default" +-198592 +-200000 +12 +"Default" +-198528 +-200000 +12 +"Default" +-198464 +-200000 +12 +"Default" +-198400 +-200000 +12 +"Default" +-198336 +-200000 +12 +"Default" +-198272 +-200000 +12 +"Default" +-198208 +-200000 +12 +"Default" +-198144 +-200000 +12 +"Default" +-198080 +-200000 +12 +"Default" +-198016 +-200000 +12 +"Default" +-197952 +-200000 +12 +"Default" +-197888 +-200000 +12 +"Default" +-197824 +-200000 +12 +"Default" +-197760 +-200000 +12 +"Default" +-197696 +-200000 +12 +"Default" +-197632 +-201152 +11 +"Default" +-197632 +-200576 +11 +"Default" +-197632 +-200960 +11 +"Default" +-197632 +-200128 +11 +"Default" +-197632 +-200448 +11 +"Default" +-197632 +-200640 +11 +"Default" +-197632 +-200512 +11 +"Default" +-197632 +-200704 +11 +"Default" +-197632 +-200768 +11 +"Default" +-197632 +-200320 +11 +"Default" +-197632 +-200064 +11 +"Default" +-197632 +-200384 +11 +"Default" +-197632 +-201088 +11 +"Default" +-197632 +-200256 +11 +"Default" +-197632 +-200832 +11 +"Default" +-197632 +-200000 +12 +"Default" +-197632 +-200192 +11 +"Default" +-197632 +-201024 +11 +"Default" +-197632 +-200896 +11 +"Default" +-197632 +-200000 +11 +"Default" +-197568 +-200704 +60 +"Default" +-197568 +-200832 +60 +"Default" +-197568 +-201120 +61 +"Default" +-197568 +-200064 +60 +"Default" +-197568 +-200320 +60 +"Default" +-197568 +-200576 +60 +"Default" +-197568 +-200448 +60 +"Default" +-197568 +-201088 +60 +"Default" +-197568 +-200000 +12 +"Default" +-197568 +-200960 +60 +"Default" +-197568 +-200192 +60 +"Default" +-197536 +-201120 +61 +"Default" +-197504 +-200000 +12 +"Default" +-197504 +-201120 +61 +"Default" +-197472 +-201120 +61 +"Default" +-197440 +-201120 +61 +"Default" +-197440 +-200576 +60 +"Default" +-197440 +-200704 +60 +"Default" +-197440 +-200000 +12 +"Default" +-197440 +-200448 +60 +"Default" +-197440 +-201088 +60 +"Default" +-197440 +-200192 +60 +"Default" +-197440 +-200064 +60 +"Default" +-197440 +-200960 +60 +"Default" +-197440 +-200320 +60 +"Default" +-197440 +-200832 +60 +"Default" +-197408 +-201120 +61 +"Default" +-197376 +-201120 +61 +"Default" +-197376 +-200000 +12 +"Default" +-197344 +-201120 +61 +"Default" +-197312 +-200576 +60 +"Default" +-197312 +-200448 +60 +"Default" +-197312 +-200960 +60 +"Default" +-197312 +-200320 +60 +"Default" +-197312 +-200704 +60 +"Default" +-197312 +-200192 +60 +"Default" +-197312 +-201088 +60 +"Default" +-197312 +-200064 +60 +"Default" +-197312 +-200832 +60 +"Default" +-197312 +-201120 +61 +"Default" +-197280 +-201120 +61 +"Default" +-197248 +-201120 +61 +"Default" +-197216 +-201120 +61 +"Default" +-197184 +-200576 +60 +"Default" +-197184 +-200064 +60 +"Default" +-197184 +-200320 +60 +"Default" +-197184 +-201120 +61 +"Default" +-197184 +-200704 +60 +"Default" +-197184 +-201088 +60 +"Default" +-197184 +-200960 +60 +"Default" +-197184 +-200832 +60 +"Default" +-197184 +-200448 +60 +"Default" +-197184 +-200192 +60 +"Default" +-197152 +-201120 +61 +"Default" +-197120 +-201120 +61 +"Default" +-197088 +-201120 +61 +"Default" +-197056 +-200832 +60 +"Default" +-197056 +-200448 +60 +"Default" +-197056 +-200192 +60 +"Default" +-197056 +-200320 +60 +"Default" +-197056 +-200064 +60 +"Default" +-197056 +-201088 +60 +"Default" +-197056 +-200576 +60 +"Default" +-197056 +-201120 +61 +"Default" +-197056 +-200960 +60 +"Default" +-197056 +-200704 +60 +"Default" +-197024 +-201120 +61 +"Default" +-196992 +-201120 +61 +"Default" +-196960 +-201120 +61 +"Default" +-196928 +-200576 +60 +"Default" +-196928 +-200192 +60 +"Default" +-196928 +-201120 +61 +"Default" +-196928 +-200960 +60 +"Default" +-196928 +-200704 +60 +"Default" +-196928 +-200448 +60 +"Default" +-196928 +-200064 +60 +"Default" +-196928 +-200320 +60 +"Default" +-196928 +-201088 +60 +"Default" +-196928 +-200832 +60 +"Default" +-196896 +-201120 +61 +"Default" +-196864 +-201120 +61 +"Default" +-196832 +-201120 +61 +"Default" +-199968 +-200128 +2 +"Default" +-198624 +-200160 +7 +"Default" +-197856 +-200288 +8 +"Default" +-197472 +-200256 +33 +"Default" +-197440 +-200352 +34 +"Default" +-197440 +-200512 +33 +"Default" +-197440 +-200992 +34 +"Default" +-197408 +-200672 +34 +"Default" +-197248 +-200384 +33 +"Default" +-197216 +-200128 +2 +"Default" +-197196 +-200204 +13 +"Default" +-197088 +-200800 +34 +"Default" +-197056 +-200480 +34 +"Default" +-197024 +-200928 +34 +"Default" +-197024 +-200320 +34 +"Default" +-196960 +-200384 +33 +"Default" +-199520 +-200064 +1 +"Default" +-199488 +-200064 +1 +"Default" +-199456 +-200064 +1 +"Default" +-199424 +-200064 +1 +"Default" +-199168 +-200064 +1 +"Default" +-199136 +-200064 +1 +"Default" +-197472 +-200064 +1 +"Default" +-197440 +-200064 +1 +"Default" +-197408 +-200064 +1 +"Default" +-197376 +-200064 +1 +"Default" +-197024 +-200064 +1 +"Default" +-196992 +-200064 +1 +"Default" +-196960 +-200064 +1 +"Default" +-196928 +-200064 +1 +"Default" +"next" +-198848 +-200064 +-1 +1 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199232 +-200064 +-1 +1 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199422 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199454 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198622 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198526 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199358 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198176 +-200160 +-1 +6 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198558 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199390 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199326 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198590 +-200160 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-197184 +-200192 +-1 +11 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198078 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198110 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198014 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199870 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198142 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199902 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199934 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-198046 +-200320 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199646 +-200448 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199582 +-200448 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199614 +-200448 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199038 +-200576 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199006 +-200608 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199038 +-200640 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199006 +-200672 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199038 +-200704 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199006 +-200736 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199038 +-200768 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199006 +-200800 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199038 +-200832 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199518 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199550 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199294 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199230 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199582 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199454 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199262 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199166 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199198 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199422 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199614 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199486 +-200928 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199326 +-200992 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199358 +-200992 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199486 +-200992 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199422 +-200992 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199294 +-200992 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199390 +-200992 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +-199454 +-200992 +-1 +10 +#FALSE# +"" +#FALSE# +#FALSE# +#FALSE# +"Default" +"" +"" +"" +"" +"" +"next" +"next" +"next" +"Default" +#FALSE# +"Destroyed Blocks" +#TRUE# +"Spawned NPCs" +#FALSE# +"next" +"Level - Start" +"" +0 +0 +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +"" +0 +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +"P Switch - Start" +"" +0 +0 +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +"" +0 +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 +"P Switch - End" +"" +0 +0 +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +"" +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +-1 +-1 +-1 +0 +0 +0 +"" +0 +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +"" +0 +0 +0 +0 +0 diff --git a/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/world.wld b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/world.wld new file mode 100644 index 000000000..0be919004 --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/EXAMPLE LEVEL/world.wld @@ -0,0 +1,709 @@ +64 +"SMB3 Roulette Test" +#FALSE# +#FALSE# +#FALSE# +#FALSE# +#FALSE# +"" +#FALSE# +#FALSE# +0 +"" +"" +"" +"" +"" +256 +192 +11 +256 +224 +11 +256 +256 +11 +256 +288 +11 +256 +320 +11 +288 +320 +11 +320 +352 +11 +352 +352 +11 +384 +320 +11 +416 +288 +11 +416 +256 +11 +416 +224 +11 +384 +224 +11 +352 +192 +11 +320 +192 +11 +320 +224 +11 +288 +224 +11 +288 +256 +11 +320 +256 +11 +320 +288 +11 +352 +288 +11 +352 +256 +11 +352 +224 +11 +288 +288 +11 +320 +320 +11 +352 +320 +11 +384 +288 +11 +384 +256 +11 +288 +192 +11 +384 +192 +11 +416 +192 +11 +416 +320 +11 +416 +352 +11 +384 +352 +11 +320 +384 +11 +256 +352 +11 +256 +384 +11 +288 +384 +11 +288 +352 +11 +288 +416 +11 +320 +416 +11 +352 +416 +11 +352 +384 +11 +384 +384 +11 +416 +384 +11 +384 +416 +11 +416 +416 +11 +448 +416 +11 +480 +416 +11 +480 +384 +11 +480 +352 +11 +480 +320 +11 +480 +288 +11 +480 +256 +11 +480 +224 +11 +448 +192 +11 +416 +160 +11 +384 +160 +11 +448 +352 +11 +448 +384 +11 +448 +320 +11 +448 +288 +11 +448 +256 +11 +448 +224 +11 +224 +288 +11 +224 +320 +11 +224 +352 +11 +224 +384 +11 +256 +416 +11 +224 +256 +11 +224 +224 +11 +224 +192 +11 +224 +160 +11 +256 +160 +11 +288 +160 +11 +320 +160 +11 +352 +160 +11 +448 +160 +11 +480 +192 +11 +480 +160 +11 +224 +416 +11 +192 +160 +23 +192 +192 +23 +192 +224 +23 +192 +256 +23 +192 +288 +23 +192 +320 +23 +192 +352 +23 +192 +384 +23 +192 +416 +23 +224 +448 +26 +256 +448 +26 +288 +448 +26 +320 +448 +26 +352 +448 +26 +384 +448 +26 +416 +448 +26 +448 +448 +26 +480 +448 +26 +512 +416 +24 +512 +384 +24 +512 +352 +24 +512 +320 +24 +512 +288 +24 +512 +256 +24 +512 +224 +24 +512 +192 +24 +512 +160 +24 +480 +128 +21 +448 +128 +21 +416 +128 +21 +384 +128 +21 +352 +128 +21 +320 +128 +21 +288 +128 +21 +256 +128 +21 +224 +128 +21 +192 +128 +20 +192 +448 +25 +512 +448 +17 +512 +128 +22 +192 +480 +27 +320 +480 +27 +448 +480 +27 +544 +128 +27 +544 +256 +27 +576 +416 +27 +704 +448 +27 +704 +320 +27 +672 +192 +27 +352 +0 +27 +224 +0 +27 +96 +0 +27 +0 +128 +27 +0 +256 +27 +32 +384 +27 +32 +512 +27 +480 +0 +27 +608 +0 +27 +736 +0 +27 +672 +128 +14 +672 +160 +14 +704 +160 +14 +704 +128 +14 +736 +128 +14 +768 +128 +14 +768 +160 +14 +736 +160 +14 +640 +384 +14 +608 +384 +14 +576 +384 +14 +544 +384 +14 +544 +416 +14 +672 +320 +14 +672 +352 +14 +672 +384 +14 +544 +448 +14 +576 +544 +14 +608 +544 +14 +640 +544 +14 +640 +576 +14 +672 +576 +14 +704 +576 +14 +736 +576 +14 +768 +576 +14 +672 +544 +14 +608 +576 +14 +576 +576 +14 +160 +544 +14 +160 +576 +14 +160 +512 +14 +160 +480 +14 +160 +448 +14 +160 +416 +14 +160 +384 +14 +160 +352 +14 +160 +320 +14 +160 +288 +14 +160 +256 +14 +160 +224 +14 +160 +192 +14 +160 +160 +14 +160 +128 +14 +128 +160 +14 +128 +192 +14 +128 +224 +14 +128 +256 +14 +128 +288 +14 +128 +320 +14 +128 +352 +14 +128 +128 +14 +64 +32 +14 +64 +0 +14 +64 +-32 +14 +0 +0 +14 +32 +0 +14 +32 +32 +14 +0 +32 +14 +0 +64 +14 +0 +96 +14 +64 +96 +14 +64 +64 +14 +32 +64 +14 +32 +96 +14 +0 +384 +14 +0 +416 +14 +0 +448 +14 +0 +480 +14 +0 +512 +14 +0 +544 +14 +0 +576 +14 +"next" +288 +272 +1 +416 +272 +1 +352 +224 +1 +352 +352 +1 +"next" +352 +256 +22 +320 +288 +22 +352 +320 +22 +384 +288 +22 +384 +256 +22 +320 +320 +22 +320 +256 +22 +384 +320 +22 +"next" +352 +288 +26 +"test.lvl" +"Level 1-1" +-1 +-1 +-1 +-1 +0 +#FALSE# +#FALSE# +#TRUE# +-1 +-1 +#FALSE# +"next" +352 +288 +2 +"next" diff --git a/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/EXAMPLE LUNAWORLD.lua b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/EXAMPLE LUNAWORLD.lua new file mode 100644 index 000000000..673a29606 --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/EXAMPLE LUNAWORLD.lua @@ -0,0 +1,10 @@ +_smb3overhaul = loadAPI("smb3overhaul"); + +function onLoad() + _smb3overhaul.setSecondsLeft(300); + _smb3overhaul.setTimerState(true); + _smb3overhaul.usesPBar(true); + _smb3overhaul.useEasyMode(true); + _smb3overhaul.usesCard(true); + _smb3overhaul.disableSpinJump(true); +end diff --git a/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/How to use.txt b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/How to use.txt new file mode 100644 index 000000000..1333c985a --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/How to use.txt @@ -0,0 +1,17 @@ +HOW TO USE + +--SETUP-- +1 . Copy/Paste the smb3overhaul.lua file and smb3overhaul folder into your LuaScriptsLib folder which should be in the root of your SMBX folder. (../SMBX/LuaScriptsLib/) + +--IMPLEMENTING INTO YOUR SMBX EPISODE/LEVEL-- +1 . Make a new file in your worlds folder called LunaWorld.lua. +2 . Add "_smb3overhaul = loadAPI("smb3overhaul");" to the file. +3 . In your onLoad function, you can toggle certain settings on/off. + + _smb3overhaul.setSecondsLeft(TIME); + _smb3overhaul.setTimerState(true/false); + _smb3overhaul.usesPBar(true/false); + _smb3overhaul.useEasyMode(true/false); + _smb3overhaul.usesCard(true/false); + _smb3overhaul.disableSpinJump(true/false); + diff --git a/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/Readme.txt b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/Readme.txt new file mode 100644 index 000000000..ca573974e --- /dev/null +++ b/LuaScriptsLibExt/Readme_For_smb3overhaul.lua/README/Readme.txt @@ -0,0 +1,4 @@ +Credit to Mike Santiago for the timer api. +Special thanks to Mike Santiago and Kevsoft for the help and support. + +This API combines the "leveltimer" api and the "smb3goalcard" api, while also adding new features. To avoid any issues, it is advised that you do not use the two api with this one. \ No newline at end of file diff --git a/LuaScriptsLibExt/colliders.lua b/LuaScriptsLibExt/colliders.lua index 48b7dba2e..4dc25c62a 100644 --- a/LuaScriptsLibExt/colliders.lua +++ b/LuaScriptsLibExt/colliders.lua @@ -1,7 +1,20 @@ ---colliders.lua ---v2.0.1 ---Created by Hoeloe, 2015 +--*********************************************-- +--** _____ _ _ _ _ **-- +--** / ____| | | (_) | | **-- +--** | | ___ | | |_ __| | ___ _ __ ___ **-- +--** | | / _ \| | | |/ _` |/ _ \ '__/ __| **-- +--** | |___| (_) | | | | (_| | __/ | \__ \ **-- +--** \_____\___/|_|_|_|\__,_|\___|_| |___/ **-- +--** **-- +--*********************************************-- +-------------Created by Hoeloe - 2015------------ +-----Open-Source Collision Detection Library----- +--------------For Super Mario Bros X------------- +---------------------v2.1.2---------------------- +---------------REQUIRES VECTR.lua---------------- + local colliders = {} +local vect = loadSharedAPI("vectr"); local TYPE_PLAYER = 1; local TYPE_NPC = 2; @@ -57,65 +70,6 @@ end local colliderList = {}; -local Vector = {} - -function Vector.dot(v1, v2) - return (v1.x*v2.x) + (v1.y*v2.y); -end - -function Vector:normalise() - return colliders.Vector(self.x/self.magnitude, self.y/self.magnitude); -end - -function Vector:normalize() - return self:normalise(); -end - -function Vector.add(a,b) - if(type(a) == 'number') then return Vector.add(colliders.Vector(a,a),b); - elseif(type(b) == 'number') then return Vector.add(a,colliders.Vector(b,b)); - else return colliders.Vector(a.x+b.x,a.y+b.y); - end -end - -function Vector.subtract(a,b) - if(type(a) == 'number') then return Vector.subtract(colliders.Vector(a,a),b); - elseif(type(b) == 'number') then return Vector.subtract(a,colliders.Vector(b,b)); - else return colliders.Vector(a.x-b.x,a.y-b.y); - end -end - -function Vector.mul(v,c) - if(type(v) == 'number') then return Vector.mul(c,v); - else return colliders.Vector(v.x*c,v.y*c); - end -end - -function Vector.div(v,c) - return colliders.Vector(v.x/c, v.y/c); -end - -local Vectormt = {} - -function colliders.Vector(x,y) - local v = {} - setmetatable(v,Vectormt); - v.x = x; - v.y = y; - v.sqrMagnitude = x*x + y*y; - v.magnitude = math.sqrt(v.sqrMagnitude); - return v; -end - -Vectormt.__index = Vector; -Vectormt.__eq = function(a,b) return a.x == b.x and a.y == b.y; end -Vectormt.__add = Vector.add; -Vectormt.__sub = Vector.subtract; -Vectormt.__mul = Vector.mul; -Vectormt.__div = Vector.div; -Vectormt.__unm = function(a) return colliders.Vector(-a.x, -a.y) end -Vectormt.__tostring = function(a) return "("..tostring(a.x)..", "..tostring(a.y)..")"; end - local debugList = {} local function createMeta(t) @@ -365,11 +319,11 @@ local function convertPoints(p) if(p.x == nil) then a = p; b = colliders.Point(p[1],p[2]); - c = colliders.Vector(p[1],p[2]); - elseif(p.magnitude == nil) then + c = vect.v2(p[1],p[2]); + elseif(p._type == nil) then a = {p.x, p.y}; b = p; - c = colliders.Vector(p.x,p.y); + c = vect.v2(p.x,p.y); else a = {p.x, p.y}; b = colliders.Point(p.x,p.y); @@ -394,14 +348,14 @@ local function testBoxCircle(ta,tb) if(tb.x > ta.x and tb.x < ta.x+ta.width and tb.y > ta.y and tb.y < ta.y+ta.height) then return true; end; - local vs = { colliders.Vector(ta.x - tb.x,ta.y - tb.y), - colliders.Vector(ta.x+ta.width - tb.x,ta.y - tb.y), - colliders.Vector(ta.x - tb.x,ta.y+ta.height - tb.y), - colliders.Vector(ta.x+ta.width - tb.x,ta.y+ta.height - tb.y) }; + local vs = { vect.v2(ta.x - tb.x,ta.y - tb.y), + vect.v2(ta.x+ta.width - tb.x,ta.y - tb.y), + vect.v2(ta.x - tb.x,ta.y+ta.height - tb.y), + vect.v2(ta.x+ta.width - tb.x,ta.y+ta.height - tb.y) }; for _,v in pairs(vs) do - if(v.magnitude < tb.radius) then + if(v.length < tb.radius) then return true; end end @@ -418,7 +372,7 @@ end local function testCirclePoint(a,b) local _,p = convertPoints(b); - return (colliders.Vector(a.x-p.x,a.y-p.y).magnitude < a.radius); + return (vect.v2(a.x-p.x,a.y-p.y).length < a.radius); end local function isLeft(a, p0, p1) @@ -452,7 +406,7 @@ local function testTriBox(a,b) return true; end - if(colliders.raycast(a:Get(1),a:Get(2), b) or colliders.raycast(a:Get(2), a:Get(3), b) or colliders.raycast(a:Get(3), a:Get(1), b)) then + if(colliders.linecast(a:Get(1),a:Get(2), b) or colliders.linecast(a:Get(2), a:Get(3), b) or colliders.linecast(a:Get(3), a:Get(1), b)) then return true; else return false; @@ -471,7 +425,7 @@ local function testTriTri(a,b) return true; end - if(colliders.raycast(a:Get(1),a:Get(2), b) or colliders.raycast(a:Get(2), a:Get(3), b) or colliders.raycast(a:Get(3), a:Get(1), b)) then + if(colliders.linecast(a:Get(1),a:Get(2), b) or colliders.linecast(a:Get(2), a:Get(3), b) or colliders.linecast(a:Get(3), a:Get(1), b)) then return true; else return false; @@ -673,6 +627,38 @@ local function intersect(a1, a2, b1, b2) end +--Determines whether two line segments are intersecting, and returns the intersection point as a second argument. +local function intersectpoint(a1, a2, b1, b2) + + if(not intersect(a1,a2,b1,b2)) then + return false, nil; + end + + local div = 1/((a1[1]-a2[1])*(b1[2]-b2[2]) - (a1[2]-a2[2])*(b1[1]-b2[1])) + local ma = a1[1]*a2[2] - a1[2]*a2[1]; + local mb = b1[1]*b2[2] - b1[2]*b2[1] + + local px = (ma*(b1[1]-b2[1]) - mb*(a1[1]-a2[1]))*div; + local py = (ma*(b1[2]-b2[2]) - mb*(a1[2]-a2[2]))*div; + + --[[local maxxa = math.max(a1[1],a2[1]); + local maxya = math.max(a1[2],a2[2]); + local minxa = math.min(a1[1],a2[1]); + local minya = math.min(a1[2],a2[2]); + local maxxb = math.max(b1[1],b2[1]); + local maxyb = math.max(b1[2],b2[2]); + local minxb = math.min(b1[1],b2[1]); + local minyb = math.min(b1[2],b2[2]); + + if(px > maxxa or px < minxxa or py > maxya or py < minya or + px > maxxb or px < minxxb or py > maxyb or py < minyb) then + return false, vectr.zero2; + end]] + + return true, vect.v2(px,py); + +end + local function testPolyPoly(a,b) local bba = colliders.Box(a.minX+a.x, a.minY+a.y, a.maxX-a.minX, a.maxY-a.minY); local bbb = colliders.Box(b.minX+b.x, b.minY+b.y, b.maxX-b.minX, b.maxY-b.minY); @@ -709,44 +695,134 @@ local function testPolyCircle(a,b) return false; end -function colliders.raycast(startPoint,endPoint,collider) - local c = colliders.getHitbox(collider); +function colliders.linecast(startPoint,endPoint,collider) local a,sp,v1 = convertPoints(startPoint); local b,ep,v2 = convertPoints(endPoint); + local c1n = collider[1] ~= nil; + local c0n = collider[0] ~= nil; + + + if(collider[1] ~= nil) then + local hit; + local norm; + local col; + for _,v in pairs(collider) do + local bl,pt,nm = colliders.linecast(startPoint,endPoint,v); + if(bl and (hit == nil or (pt-v1).sqrlength < (hit-v1).sqrlength)) then + hit = pt; + norm = nm; + col = v; + end + end + if(hit ~= nil) then + return true, hit, norm, col; + else + return false, nil, nil, nil; + end + end + + local c = colliders.getHitbox(collider); + + local aabb = colliders.Box(math.min(v1.x,v2.x),math.min(v1.y,v2.y),math.abs(v2.x-v1.x),math.abs(v2.y-v1.y)); + local cbb = colliders.getAABB(collider); + + if(not colliders.collide(aabb,cbb)) then + return false, nil, nil, nil; + end + if(sp.x == ep.x and sp.y == ep.y) then - return colliders.collide(sp,c); + local b = colliders.collide(sp,c); + if(b) then + return true, vect.v2(sp), vect.zero2, collider; + else + return false, nil, nil, nil; + end end - if(colliders.collide(sp,c) or colliders.collide(ep,c)) then - return true; + if(colliders.collide(sp,c) and --[[or]] colliders.collide(ep,c)) then + return true,v1,vect.zero2, collider; end local t = getType(c); --NOTE: t CANNOT be a non-primitive collider here, because getHitbox always returns a primitive collider. if(t == TYPE_BOX) then - return (intersect(a,b,{c.x,c.y},{c.x+c.width,c.y}) + --[[return (intersect(a,b,{c.x,c.y},{c.x+c.width,c.y}) or intersect(a,b,{c.x+c.width,c.y},{c.x+c.width,c.y+c.height}) or intersect(a,b,{c.x+c.width,c.y+c.height},{c.x,c.y+c.height}) - or intersect(a,b,{c.x,c.y+c.height},{c.x,c.y})); + or intersect(a,b,{c.x,c.y+c.height},{c.x,c.y}));--]] + local hit,nm; + local col,p = intersectpoint(a,b,{c.x,c.y},{c.x+c.width,c.y}); + if(col) then + hit = p; + nm = -vect.up2; + end + col,p = intersectpoint(a,b,{c.x+c.width,c.y},{c.x+c.width,c.y+c.height}) + if(col and (hit == nil or (p-v1).sqrlength < (hit-v1).sqrlength)) then + hit = p; + nm = vect.right2; + end + col,p = intersectpoint(a,b,{c.x+c.width,c.y+c.height},{c.x,c.y+c.height}) + if(col and (hit == nil or (p-v1).sqrlength < (hit-v1).sqrlength)) then + hit = p; + nm = vect.up2; + end + col,p = intersectpoint(a,b,{c.x,c.y+c.height},{c.x,c.y}) + if(col and (hit == nil or (p-v1).sqrlength < (hit-v1).sqrlength)) then + hit = p; + nm = -vect.right2; + end + if(hit ~= nil) then + return true, hit, nm, collider; + else + return false, nil, nil, nil; + end elseif(t == TYPE_CIRCLE) then - local l2 = (ep.x-sp.x)*(ep.x-sp.x) + (ep.y-sp.y)*(ep.y-sp.y); - local p = colliders.Vector(c.x,c.y); - local t = ((p:subtract(v1)):dot(v2:subtract(v1))):mul(1/l2); + local centre = vect.v2(c.x,c.y); + local t1 = v1-centre; + local t2 = v2-centre; + local dx = t2.x-t1.x; + local dy = t2.y-t1.y; + local dr = math.sqrt(dx*dx + dy*dy); + local D = t1.x*t2.y - t2.x*t1.y; + local delta = c.radius*c.radius*dr*dr - D*D; + if(delta < 0) then + return false, nil, nil, nil; + else + local sdy; + if(dy < 0) then sdy=-1; else sdy = 1; end + local qx = sdy*dx*math.sqrt(delta); + local qy = math.abs(dy)*math.sqrt(delta); + local px1 = (D*dy + qx)/(dr*dr); + local px2 = (D*dy - qx)/(dr*dr); + local py1 = (-D*dx + qy)/(dr*dr); + local py2 = (-D*dx - qy)/(dr*dr); + local p1 = vect.v2(px1,py1); + local p2 = vect.v2(px2,py2); + if((p2-t1).sqrlength < (p1-t1).sqrlength) then + return true, p2+centre, (p2):normalise(), collider; + else + return true, p1+centre, (p1):normalise(), collider; + end + end + --[[local l2 = (ep.x-sp.x)*(ep.x-sp.x) + (ep.y-sp.y)*(ep.y-sp.y); + local p = vect.v2(c.x,c.y); + local t = ((p-v1)..(v2-v1))/l2; if(t < 0) then return colliders.collide(c,sp); elseif(t > 1) then return colliders.collide(c,ep); else - local pr = v1:add((v2:subtract(v1)):mul(t)); - return (p:subtract(pr)).magnitude <= c.radius; - end + local pr = v1+((v2-v1)*t); + return (p-pr).length <= c.radius; + end]] + elseif(t == TYPE_POINT) then - local p = colliders.Vector(c.x,c.y); - return math.abs(v2:subtract(p).magnitude + v1:subtract(p).magnitude - v2:subtract(v1).magnitude) < 0.001; + local p = vect.v2(c.x,c.y); + return math.abs((v2-p).length + (v1-p).length - (v2-v1).length) < 0.001, p, (v2-v1):normalise(), collider; elseif(t == TYPE_POLY) then - local bb = colliders.Box(c.minX+c.x, c.minY+c.y, c.maxX-c.minX, c.maxY-c.minY); - if(not colliders.raycast(startPoint, endPoint, bb)) then return false; end + --[[ local bb = colliders.Box(c.minX+c.x, c.minY+c.y, c.maxX-c.minX, c.maxY-c.minY); + if(not colliders.linecast(startPoint, endPoint, bb)) then return false,nil,nil; end for k,v in ipairs(c.v) do local n = c.v[k+1]; @@ -756,18 +832,68 @@ function colliders.raycast(startPoint,endPoint,collider) n = {n[1]+c.x,n[2]+c.y}; local m = {v[1]+c.x,v[2]+c.y}; - if(intersect(m,n,a,b)) then return true; end + local inter,point = intersectpoint(m,n,a,b) + if(inter) then + local ray = v2-v1; + local ln = vect.v2(n[1]-m[1],n[2]-m[2]); + local norm = (ray:tov3()^ln:tov3()):tov2(); + return true,point,norm; + end end - return false; + return false;]] + local bb = colliders.Box(c.minX+c.x, c.minY+c.y, c.maxX-c.minX, c.maxY-c.minY); + if(not colliders.linecast(startPoint, endPoint, bb)) then return false,nil,nil,nil; end + + local hit; + local norm; + + for k,v in ipairs(c.tris) do + local ht,pt,nm = colliders.linecast(startPoint,endPoint,v); + if(ht and (hit == nil or (pt-v1).sqrlength < (hit-v1).sqrlength)) then + hit = pt; + norm = nm; + end + end + + if(hit ~= nil) then + return true,hit,norm, collider; + else + return false, nil, nil, nil; + end + elseif(t == TYPE_TRI) then local bb = colliders.Box(c.minX+c.x, c.minY+c.y, c.maxX-c.minX, c.maxY-c.minY); - if(not colliders.raycast(startPoint, endPoint, bb)) then return false; end + if(not colliders.linecast(startPoint, endPoint, bb)) then return false,nil,nil,nil; end + + local hit; + local dir; + + for i=1,3,1 do + local j = i+1; + if(j > 3) then j = 1; end + local col,pt = intersectpoint(a,b,c:Get(i),c:Get(j)); + if(col and (hit == nil or (pt-v1).sqrlength < (hit-v1).sqrlength)) then + hit = pt; + dir = vect.v2(c:Get(j)[1]-c:Get(i)[1],c:Get(j)[2]-c:Get(i)[2]); + end + end - if(intersect(a,b,c:Get(1),c:Get(2)) or intersect(a,b,c:Get(2), c:Get(3)) or intersect(a,b,c:Get(3),c:Get(1))) then return true; - else return false end; + if(hit ~= nil) then + return true,hit,(dir:tov3()^vect.v3(0,0,1)):tov2():normalise(), collider; + else + return false, nil, nil, nil; + end + else + return false,nil,nil, nil; end end +function colliders.raycast(startPoint,direction,collider) + local _,_,sp = convertPoints(startPoint); + local _,_,dir = convertPoints(direction); + return colliders.linecast(sp,sp-dir,collider); +end + local function getBlockHitbox(id, x, y, wid, hei) -- /| @@ -822,6 +948,7 @@ end function colliders.getAABB(a) local ta = getType(a); + if(a.TYPE == TYPE_BOX) then return a; end @@ -1034,7 +1161,7 @@ function colliders.collide(a,b) if(tb == TYPE_BOX) then --Check each side of both boxes return testBoxCircle(b,a); elseif(tb == TYPE_CIRCLE) then --Check each corner of the box with the circle - return (colliders.Vector(a.x-b.x,a.y-b.y).magnitude < (a.radius + b.radius)); + return (vect.v2(a.x-b.x,a.y-b.y).length < (a.radius + b.radius)); elseif(tb == TYPE_POINT) then --Check if the point is inside the circle return testCirclePoint(a,b); elseif(tb == TYPE_POLY) then --Check poly with sampled circle @@ -1112,101 +1239,144 @@ function colliders.speedCollide(a,b) return colliders.collide(ca,cb); end -function colliders.collideNPCBlock(a,b) - local idA = type(a) == 'number'; - local idB = type(b) == 'number'; +local function contains(a,b) + if(type(a) == 'number') then return a == b; end + for _,v in ipairs(a) do + if(v == b) then + return true; + end + end + return false; +end + +function colliders.collideNPCBlock(a,b,sec) + local idA = type(a) == 'number' or (a[1] ~= nil and type(a[1]) == 'number'); + local idB = type(b) == 'number' or (b[1] ~= nil and type(b[1]) == 'number'); local c = 0; + local cpairs = {}; + sec = sec or -1; if(idA and idB) then - for _,v in pairs(NPC.get(a,-1)) do + for _,v in pairs(NPC.get(a,sec)) do local hb = colliders.getAABB(v); - for _,v2 in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do - if(v2.id == b and colliders.collide(v,v2)) then - c = c + 1; + if(hb ~= nil) then + for _,v2 in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do + if(contains(b,v2.id) and colliders.collide(v,v2)) then + c = c + 1; + table.insert(cpairs,{v,v2}); + end end end end elseif(idA and not idB) then - local _,count = colliders.collideNPC(b,a); + local _,count,ps = colliders.collideNPC(b,a); c = count; + cpairs = ps; elseif(not idA and idB) then - local _,count = colliders.collideBlock(a,b); + local _,count,ps = colliders.collideBlock(a,b); c = count; + cpairs = ps; else if(colliders.collide(a,b)) then c = 1; else c = 0; end; end - return c>0,c; + return c>0,c,cpairs; end -function colliders.collideBlock(a,b) - local npcA = type(a) == 'number'; - local npcB = type(b) == 'number'; +function colliders.collideBlock(a,b,sec) + local npcA = type(a) == 'number' or (a[1] ~= nil and type(a[1]) == 'number'); + local npcB = type(b) == 'number' or (b[1] ~= nil and type(b[1]) == 'number'); local c = 0; + local cpairs = {}; + sec = sec or -1; if(npcA and npcB) then - for _,v in pairs(Block.get(a,-1)) do + for _,v in pairs(Block.get(a,sec)) do local hb = colliders.getAABB(v); - for _,v2 in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do - if(v2.id == b and colliders.collide(v,v2)) then - c = c + 1; + if(hb ~= nil) then + for _,v2 in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do + if(contains(b,v2.id) and colliders.collide(v,v2)) then + c = c + 1; + table.insert(cpairs,{v,v2}); + end end end end elseif(npcA and not npcB) then local hb = colliders.getAABB(b); - for _,v in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do - if(v.id == a and colliders.collide(v,b)) then - c = c + 1; + if(hb ~= nil) then + for _,v in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do + if(contains(a,v.id) and colliders.collide(v,b)) then + c = c + 1; + table.insert(cpairs,v); + end end end elseif(not npcA and npcB) then local hb = colliders.getAABB(a); - for _,v in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do - if(v.id == b and colliders.collide(v,a)) then - c = c + 1; + if(hb ~= nil) then + for _,v in pairs(Block.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do + if(contains(b,v.id) and colliders.collide(v,a)) then + c = c + 1; + table.insert(cpairs,v); + end end end else if(colliders.collide(a,b)) then c = 1; else c = 0; end; end - return c>0,c; + return c>0,c,cpairs; end -function colliders.collideNPC(a,b) - local npcA = type(a) == 'number'; - local npcB = type(b) == 'number'; +function colliders.collideNPC(a,b,sec) + local npcA = type(a) == 'number' or (a[1] ~= nil and type(a[1]) == 'number'); + local npcB = type(b) == 'number' or (b[1] ~= nil and type(b[1]) == 'number'); local c = 0; + local cpairs = {}; + sec = sec or -1; if(npcA and npcB) then - for _,v in pairs(NPC.get(a,-1)) do + for _,v in pairs(NPC.get(a,sec)) do local hb = colliders.getAABB(v); - for _,v2 in pairs(NPC.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do - if(v2.id == b and colliders.collide(v,v2)) then - c = c + 1; + if(hb ~= nil) then + for _,v2 in pairs(NPC.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do + if(contains(b,v2.id) and colliders.collide(v,v2)) then + c = c + 1; + table.insert(cpairs,{v,v2}); + end end end end elseif(npcA and not npcB) then local hb = colliders.getAABB(b); - for _,v in pairs(NPC.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do - if(v.id == a and colliders.collide(v,b)) then - c = c + 1; + if(hb ~= nil) then + for _,v in pairs(NPC.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do + if(contains(a,v.id) and colliders.collide(v,b)) then + c = c + 1; + table.insert(cpairs,v); + end end end elseif(not npcA and npcB) then local hb = colliders.getAABB(a); - for _,v in pairs(NPC.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do - if(v.id == b and colliders.collide(v,a)) then - c = c + 1; + if(hb ~= nil) then + for _,v in pairs(NPC.getIntersecting(hb.x,hb.y,hb.x+hb.width,hb.y+hb.height)) do + if(contains(b,v.id) and colliders.collide(v,a)) then + c = c + 1; + table.insert(cpairs,v); + end end end else - if(colliders.collide(a,b)) then c = 1; else c = 0; end; + if(colliders.collide(a,b)) then + c = 1; + else + c = 0; + end; end - return c>0,c; + return c>0,c,cpairs; end function colliders.update() diff --git a/LuaScriptsLibExt/leveltimer.lua b/LuaScriptsLibExt/leveltimer.lua index c1039078d..7e1a128dd 100644 --- a/LuaScriptsLibExt/leveltimer.lua +++ b/LuaScriptsLibExt/leveltimer.lua @@ -1,144 +1,193 @@ -local __title = "Level Timer"; -local __version = "1.1.0.0"; -local __author = "Mike Santiago"; -local __url = "http://mrmiketheripper.x10.mx/leveltimer" - -local lf_levelTimerApi = {} --instance - -local secondsleft = 300; --The amount of seconds left. -local framecounter = 0; --Counts the amount of frames -local postWinFrameCounter = 0; --Counts frams since after the win -local player1 = Player(); --The player variable -local player2 = Player(2); -local playerkilled = false; --If the player was killed already so we don't kill him 21390840239 times -local passTime = true; --Whether or not to pass time, if false, time will stop. -local timerEnabled = true; --Whether or not the timer itself is actually enabled or not -local warnedPlayer = false; --Whether or not we've warned the player that time is running out -local resPath = getSMBXPath() .. "\\LuaScriptsLib\\leveltimer"; --res path -local uiImage = Graphics.loadImage(resPath .. "\\ui.png"); --ui thing - -lf_levelTimerApi.GUIPosition_NoStars = {x = 252, y = 50} -lf_levelTimerApi.GUIPosition_Stars = {x = 252, y = 66} - -function lf_levelTimerApi.onInitAPI() - timerEnabled = false; --user must start it - registerEvent(lf_levelTimerApi, "onLoop", "onLoopOverride"); -end - -function lf_levelTimerApi.onLoopOverride() - if(timerEnabled == true) then - timeelapsed = round(framecounter / 60, 0); - if(tonumber(mem(0x00B251E0, FIELD_DWORD)) > 0) then - Graphics.placeSprite(1, uiImage, lf_levelTimerApi.GUIPosition_Stars.x, lf_levelTimerApi.GUIPosition_Stars.y, "", 2); - Text.print(tostring(secondsleft - timeelapsed), 1, lf_levelTimerApi.GUIPosition_Stars.x + 44, lf_levelTimerApi.GUIPosition_Stars.y + 1); - elseif (tonumber(mem(0x00B251E0, FIELD_DWORD)) == 0) then - Graphics.placeSprite(1, uiImage, lf_levelTimerApi.GUIPosition_NoStars.x, lf_levelTimerApi.GUIPosition_NoStars.y, "", 2); - Text.print(tostring(secondsleft - timeelapsed), 1, lf_levelTimerApi.GUIPosition_NoStars.x + 44, lf_levelTimerApi.GUIPosition_NoStars.y + 1); - end - - if (passTime == true) then - framecounter = framecounter + 1; - end - if(timeelapsed >= secondsleft) then - passTime = false; - if(playerkilled == false) then - player1:kill(); - if(player2 ~= nil) then - if(player2.isValid) then - player2:kill(); - end - end - playerkilled = true; - end - end - if((secondsleft - timeelapsed) <= 100) then - if(warnedPlayer == false) then - warnedPlayer = true; - playSFXSDL(resPath .. "\\warning.wav"); - --test = "-----WARNING!-----\n\nYou're running out of time!"; - --Text.showMessageBox(type(test)); - end - end - - if(Level.winState() > 0) then - passTime = false; - postWinFrameCounter = postWinFrameCounter + 1; - lf_levelTimerApi.doEndingStuffs(); - end - end -end - -local added = false; -local showTimeLeft = false; -local showPointCalc = false; -local showAddPoints = false; - -function lf_levelTimerApi.doEndingStuffs() - local timeLeftDrawPoint = {x = 288, y = 150} - local pointCalculationDrawPoint = {x = 247, y = 170} - local addPointsDrawPoint = {x = 461, y = 70}; - local timeleft = secondsleft - timeelapsed; - - local newPoints = tonumber(mem(0x00B2C8E4, FIELD_DWORD)) + (timeleft * 50); - - Text.print("COURSE CLEAR", 288, 150); - - timeelapsed = round(postWinFrameCounter / 60, 0); - if(timeelapsed > 1) then - showPointCalc = true; - end - if(timeelapsed > 2) then - if(added ~= true) then - showAddPoints = true; - end - end - if(timeelapsed == 4) then - if(added ~= true) then - mem(0x00B2C8E4, FIELD_DWORD, newPoints); - added = true; - showAddPoints = false; - end - end - - if(showPointCalc) then - Text.print(tostring(timeleft) .. " x 50 = " .. tostring(timeleft * 50), pointCalculationDrawPoint.x, pointCalculationDrawPoint.y); - end - if(showAddPoints == true) then - Text.print("+" .. tostring(timeleft * 50), 3, addPointsDrawPoint.x, addPointsDrawPoint.y); - end -end - -function lf_levelTimerApi.getSecondsLeft() - return secondsleft; -end - -function lf_levelTimerApi.setSecondsLeft(to_set) - if (to_set > 999) then - secondsleft = 999; - elseif (to_set < 0) then - setSecondsLeft = 0; - else - secondsleft = to_set; - end -end - -function lf_levelTimerApi.pauseTimer() - passTime = false; -end - -function lf_levelTimerApi.setTimerState(b_tf) - timerEnabled = b_tf; -end - -local clock = os.clock; -function sleep(n) -- seconds - local t0 = clock(); - while clock() - t0 <= n do end -end - -function round(num, idp) - local mult = 10^(idp or 0) - return math.floor(num * mult + 0.5) / mult -end - -return lf_levelTimerApi; +local __title = "Level Timer"; +local __version = "1.1.1.0"; +local __description = "A simple script to provide a level timer, a la Super Mario World and Super Mario Bros. 3."; +local __author = "Mike Santiago, edited by XNBlank"; +local __url = "http://mrmiketheripper.x10.mx/leveltimer" + +local lf_levelTimerApi = {} --instance + +local secondsleft = 300; --The amount of seconds left. +local framecounter = 0; --Counts the amount of frames +local postWinFrameCounter = 0; --Counts frams since after the win +local player1 = Player(); --The player variable +local player2 = Player(2); +local beatLevel = false; +local getSeconds = false; +local takeTime = 0; +local playerkilled = false; --If the player was killed already so we don't kill him 21390840239 times +local passTime = true; --Whether or not to pass time, if false, time will stop. +local timerEnabled = true; --Whether or not the timer itself is actually enabled or not +local warnedPlayer = false; --Whether or not we've warned the player that time is running out +local resPath = getSMBXPath() .. "\\LuaScriptsLib\\leveltimer"; --res path +local uiImage = Graphics.loadImage(resPath .. "\\ui.png"); --ui thing + +lf_levelTimerApi.GUIPosition_NoStars = {x = 252, y = 50} +lf_levelTimerApi.GUIPosition_Stars = {x = 252, y = 66} + +function lf_levelTimerApi.onInitAPI() + timerEnabled = false; --user must start it + registerEvent(lf_levelTimerApi, "onLoop", "onLoopOverride"); +end + +function lf_levelTimerApi.onLoopOverride() + if(timerEnabled == true) then + timeelapsed = round(framecounter / 60, 0); + if(tonumber(mem(0x00B251E0, FIELD_DWORD)) > 0) and (beatLevel == false) then + Graphics.placeSprite(1, uiImage, lf_levelTimerApi.GUIPosition_Stars.x, lf_levelTimerApi.GUIPosition_Stars.y, "", 2); + Text.print(tostring(secondsleft - timeelapsed), 1, lf_levelTimerApi.GUIPosition_Stars.x + 44, lf_levelTimerApi.GUIPosition_Stars.y + 1); + elseif (tonumber(mem(0x00B251E0, FIELD_DWORD)) == 0) and (beatLevel == false) then + Graphics.placeSprite(1, uiImage, lf_levelTimerApi.GUIPosition_NoStars.x, lf_levelTimerApi.GUIPosition_NoStars.y, "", 2); + Text.print(tostring(secondsleft - timeelapsed), 1, lf_levelTimerApi.GUIPosition_NoStars.x + 44, lf_levelTimerApi.GUIPosition_NoStars.y + 1); + end + + --Text.print("Time to take..." .. tostring(takeTime), 0, 0); + --Text.print("Seconds left..." .. tostring(secondsleft - timeelapsed), 0, 15); + + + if (passTime == true) then + framecounter = framecounter + 1; + end + if(timeelapsed >= secondsleft) then + passTime = false; + if(beatLevel == false) then + if(playerkilled == false) then + player1:kill(); + if(player2 ~= nil) then + if(player2.isValid) then + player2:kill(); + end + end + playerkilled = true; + end + end + end + if((secondsleft - timeelapsed) <= 100) then + if(passTime == true) then + if(warnedPlayer == false) then + warnedPlayer = true; + playSFXSDL(resPath .. "\\warning.wav"); + --test = "-----WARNING!-----\n\nYou're running out of time!"; + --Text.showMessageBox(type(test)); + end + end + end + + if(Level.winState() > 0) then + + beatLevel = true; + passTime = false; + postWinFrameCounter = postWinFrameCounter + 1; + lf_levelTimerApi.doEndingStuffs(); + end + end +end + +local added = false; +local showTimeLeft = false; +local showPointCalc = false; +local showAddPoints = false; +local countPoints = false; + +function lf_levelTimerApi.doEndingStuffs() + local timeLeftDrawPoint = {x = 288, y = 150} + local pointCalculationDrawPoint = {x = 247, y = 170} + local addPointsDrawPoint = {x = 461, y = 70}; + local timeleft = secondsleft - timeelapsed; + + if(getSeconds == false) then + takeTime = secondsleft - timeelapsed; + getSeconds = true; + end + + local newPoints = tonumber(mem(0x00B2C8E4, FIELD_DWORD)) + (timeleft * 50); + + Text.print("COURSE CLEAR", 288, 150); + + if(tonumber(mem(0x00B251E0, FIELD_DWORD)) > 0) and (beatLevel == true) then + Graphics.placeSprite(1, uiImage, lf_levelTimerApi.GUIPosition_Stars.x, lf_levelTimerApi.GUIPosition_Stars.y, "", 2); + Text.print(tostring(takeTime), 1, lf_levelTimerApi.GUIPosition_Stars.x + 44, lf_levelTimerApi.GUIPosition_Stars.y + 1); +elseif (tonumber(mem(0x00B251E0, FIELD_DWORD)) == 0) and (beatLevel == true) then + Graphics.placeSprite(1, uiImage, lf_levelTimerApi.GUIPosition_NoStars.x, lf_levelTimerApi.GUIPosition_NoStars.y, "", 2); + Text.print(tostring(takeTime), 1, lf_levelTimerApi.GUIPosition_NoStars.x + 44, lf_levelTimerApi.GUIPosition_NoStars.y + 1); +end + + + timeelapsed = round(postWinFrameCounter / 60, 0); + if(timeelapsed > 0) then + showPointCalc = true; + end + + if(timeelapsed > 1) then + if(added ~= true) then + showAddPoints = true; + countPoints = true; + end + end + + if(timeelapsed == 4) and (takeTime <= 0) then + if(added ~= true) then + mem(0x00B2C8E4, FIELD_DWORD, newPoints); + added = true; + showAddPoints = false; + end + end + + if(countPoints == true) then + if(takeTime > 100) then + takeTime = takeTime - 10; + playSFXSDL(resPath .. "\\drumroll.wav"); + elseif(takeTime >= 1) then + takeTime = takeTime - 1; + playSFXSDL(resPath .. "\\drumroll.wav"); + elseif(takeTime <= 0) then + takeTime = 0; + countPoints = false; + end + end + + + + + if(showPointCalc) then + Text.print(tostring(timeleft) .. " x 50 = " .. tostring(timeleft * 50), pointCalculationDrawPoint.x, pointCalculationDrawPoint.y); + end + if(showAddPoints == true) then + Text.print("+" .. tostring(timeleft * 50), 3, addPointsDrawPoint.x, addPointsDrawPoint.y); + + end +end + +function lf_levelTimerApi.getSecondsLeft() + return secondsleft; +end + +function lf_levelTimerApi.setSecondsLeft(to_set) + if (to_set > 999) then + secondsleft = 999; + elseif (to_set < 0) then + setSecondsLeft = 0; + else + secondsleft = to_set; + end +end + +function lf_levelTimerApi.pauseTimer() + passTime = false; +end + +function lf_levelTimerApi.setTimerState(b_tf) + timerEnabled = b_tf; +end + +local clock = os.clock; +function sleep(n) -- seconds + local t0 = clock(); + while clock() - t0 <= n do end +end + +function round(num, idp) + local mult = 10^(idp or 0) + return math.floor(num * mult + 0.5) / mult +end + +return lf_levelTimerApi; diff --git a/LuaScriptsLibExt/leveltimer/drumroll.wav b/LuaScriptsLibExt/leveltimer/drumroll.wav new file mode 100644 index 000000000..05b385dee Binary files /dev/null and b/LuaScriptsLibExt/leveltimer/drumroll.wav differ diff --git a/LuaScriptsLibExt/smb3overhaul.lua b/LuaScriptsLibExt/smb3overhaul.lua new file mode 100644 index 000000000..bbd430fba --- /dev/null +++ b/LuaScriptsLibExt/smb3overhaul.lua @@ -0,0 +1,678 @@ +local __title = "SMB3 Overhaul Mod"; +local __version = "1.0.2"; +local __description = "Makes SMBX more like SMB3. Credit to Mike Santiago for the timer api."; +local __author = "XNBlank"; +local __url = "https://github.com/XNBlank"; + +local smb_threeHud_API = {} --instance + + +--Let's load all of the graphics first. +local resPath = getSMBXPath() .. "\\LuaScriptsLib\\smb3overhaul"; --res path +local back = Graphics.loadImage(resPath .. "\\back.png"); --ui thing +local lifecounter = Graphics.loadImage(resPath .. "\\lifecounter.png"); --ui thing +local coincounter = Graphics.loadImage(resPath .. "\\coincounter.png"); --ui thing +local starcounter = Graphics.loadImage(resPath .. "\\starcounter.png"); --ui thing +local pbarGfx = Graphics.loadImage(resPath .. "\\pbar.png"); --ui thing +local pbarGfx_arrow = Graphics.loadImage(resPath .. "\\pbar_arrow.png"); --ui thing +local pbarGfx_active = Graphics.loadImage(resPath .. "\\pbar_active.png"); --ui thing +local useReserve = false; +local toggleEasyMode = true; +local usePBar = true; +local pbarCount = 0; +local reduceTimer = 6; +local lastpowerup = 0; +local disableSpinJump = true; + +--Load leveltimer vars (by LuigiFan2010) +local secondsleft = 300; --The amount of seconds left. +local framecounter = 0; --Counts the amount of frames +local postWinFrameCounter = 0; --Counts frams since after the win +local player1 = Player(); --The player variable +local player2 = Player(2); +local beatLevel = false; +local getSeconds = false; +local takeTime = 0; +local playerkilled = false; --If the player was killed already so we don't kill him 21390840239 times +local passTime = true; --Whether or not to pass time, if false, time will stop. +local timerEnabled = true; --Whether or not the timer itself is actually enabled or not +local warnedPlayer = false; --Whether or not we've warned the player that time is running out +local uiImage = Graphics.loadImage(resPath .. "\\ui.png"); --ui thing + +smb_threeHud_API.GUIPosition_NoStars = {x = 252, y = 50} +smb_threeHud_API.GUIPosition_Stars = {x = 252, y = 66} + +--Load Goal Card vars +local card1 = -1; -- basically a bool. Checks if card is used +local card2 = -1; +local card3 = -1; +local cards = 0; +local goalcard = NPC(11); +local getframe = 0; +local postWinFrameCounter = 0; +local endLevelTimer = 0; +local gotcard = false; +local addCard = false; +local doesUseCard = true; +local playOnce = false; +local timer = 1; +local mushroomcard = Graphics.loadImage(resPath .. "\\mushroom.png"); +local flowercard = Graphics.loadImage(resPath .. "\\flower.png"); +local starcard = Graphics.loadImage(resPath .. "\\star.png"); + +local oneup = Graphics.loadImage(resPath .. "\\1up.png"); +local twoup = Graphics.loadImage(resPath .. "\\2up.png"); +local threeup = Graphics.loadImage(resPath .. "\\3up.png"); +local fiveup = Graphics.loadImage(resPath .. "\\5up.png"); + +local curLivesCount = mem(0x00B2C5AC, FIELD_FLOAT); + +local dataInstance = Data(Data.DATA_WORLD,"SMB3 Cards", true); + +local levelFinished = false; +local firstRun = true + +smb_threeHud_API.GUIPosition1 = {x = 594, y = 542} +smb_threeHud_API.GUIPosition2 = {x = 642, y = 542} +smb_threeHud_API.GUIPosition3 = {x = 690, y = 542} + + +function smb_threeHud_API.onInitAPI() + timerEnabled = false; + hud(false); + Graphics.placeSprite(1,back,0,0); + Graphics.placeSprite(1,lifecounter,85, 568); + Graphics.placeSprite(1,coincounter,496, 548); + Graphics.placeSprite(1,starcounter,158, 568); + + if(usePBar == true) then + Graphics.placeSprite(1,pbarGfx,300, 570); + end + + gotcard = false; + addCard = false; + cards = tonumber(dataInstance:get("cards")); + card1 = tonumber(dataInstance:get("card1")); + card2 = tonumber(dataInstance:get("card2")); + card3 = tonumber(dataInstance:get("card3")); + + Defines.smb3RouletteScoreValueStar = 4; + Defines.smb3RouletteScoreValueMushroom = 2; + Defines.smb3RouletteScoreValueFlower = 3; + + registerEvent(smb_threeHud_API, "onLoop", "onLoopOverride"); + registerEvent(smb_threeHud_API, "onInputUpdate", "onInputUpdateOverride"); + +end + +function smb_threeHud_API.onLoad() + + +end + +function smb_threeHud_API.onLoopOverride() + if(useReserve == false) then + player.reservePowerup = 0; + end + + --[[ + --This was used to test for collisions for disabling spin jump + + Text.print("If the player is touching the ground or ", 0, 0); + Text.print("a slope, disable Spin Jump.", 0, 16); + Text.print("Sprite standing on " .. tostring(player:mem(0x176, FIELD_WORD)), 0, 48); + Text.print("Climbing " .. tostring(player:mem(0x40, FIELD_WORD)), 0, 64); + if(player.altJumpKeyPressing == true) then + Text.print("Player IS pressing Spin Jump", 0, 80); + elseif(player.altJumpKeyPressing == false) then + Text.print("Player IS NOT pressing Spin Jump", 0, 80); + end + ]] + + + if(toggleEasyMode == true) then + local isHurt = player:mem(0x140, FIELD_WORD); + + if(player.powerup > 2) then + lastpowerup = player.powerup; + end + + if(lastpowerup > 2) and (isHurt > 50) then + player.powerup = 2; + lastpowerup = player.powerup; + end + + --Text.print(tostring(isHurt), 0 ,0); + --Text.print(tostring(player.powerup), 0 ,16); + end + + + --Load internal functions and variables + local score = mem(0x00B2C8E4, FIELD_DWORD); + local lives = mem(0x00B2C5AC, FIELD_FLOAT); + local coins = mem(0x00B2C5A8, FIELD_DWORD); + local stars = mem(0x00B251E0, FIELD_DWORD); + + local isFlying = player:mem(0x16E, FIELD_WORD); + + + local levelname = Level.name(); + local level_length = string.len(levelname); + local speed = player.speedX; + local pwingSound = Audio.SfxOpen(resPath .. "\\pmeter.wav"); + + + if(levelname == "") or (level_length > 11) then + levelname = "Level"; + end + + --Draw HUD Elements. + Text.print(string.format("%02d",coins), 1,542, 550); + Text.print(tostring(stars), 1,204, 570); + --Text.print("Score ", 250, 549); + Text.print(string.format("%08d", score),1,300, 550); + Text.print(tostring(lives), 1,140, 570); + + Text.print(levelname,85, 549); + --Text.print(tostring(canFly), 0, 0); + --Text.print(tostring(pbarCount), 0, 16); + --Text.print(tostring(isFlying), 0, 32); + + --Start PWing Events + if(usePBar == true) then + + + if(reduceTimer <= 0) then + reduceTimer = 0; + end + + if(player.runKeyPressing == true) or (player.altRunKeyPressing == true) then + if(pbarCount >= 10) or (isFlying == -1) then + Graphics.placeSprite(1,pbarGfx_arrow,300, 570); + reduceTimer = reduceTimer - 1; + end + + if(pbarCount >= 15) or (isFlying == -1) then + Graphics.placeSprite(1,pbarGfx_arrow,316, 570); + reduceTimer = reduceTimer - 1; + end + + if(pbarCount >= 20) or (isFlying == -1) then + Graphics.placeSprite(1,pbarGfx_arrow,332, 570); + reduceTimer = reduceTimer - 1; + end + + if(pbarCount >= 25) or (isFlying == -1) then + Graphics.placeSprite(1,pbarGfx_arrow,348, 570); + reduceTimer = reduceTimer - 1; + end + + if(pbarCount >= 30) or (isFlying == -1) then + Graphics.placeSprite(1,pbarGfx_arrow,364, 570); + reduceTimer = reduceTimer - 1; + end + + if(pbarCount >= 35) or (isFlying == -1) then + Graphics.placeSprite(1,pbarGfx_arrow,380, 570); + reduceTimer = reduceTimer - 1; + end + + end + + if(speed >= 6) or (speed <= -6) or (isFlying == -1) then + + pbarCount = pbarCount + 1; + + if(pbarCount >= 40) then + pbarCount = 40; + if(Audio.SfxIsPlaying(1) ~= 1) then + Audio.SfxPlayCh(1, pwingSound, 1); + Graphics.placeSprite(1,pbarGfx_active,398, 570); + end + end + else + pbarCount = pbarCount - 1; + Graphics.unplaceSprites(pbarGfx_active); + end + + if(pbarCount <= 0) then + pbarCount = 0; + end + + if(pbarCount <= 9) and (reduceTimer == 0) then + Graphics.unplaceSprites(pbarGfx_arrow, 300, 570); + end + if(pbarCount <= 14) and (reduceTimer == 0) then + Graphics.unplaceSprites(pbarGfx_arrow, 316, 570); + end + if(pbarCount <= 19) and (reduceTimer == 0) then + Graphics.unplaceSprites(pbarGfx_arrow, 332, 570); + end + if(pbarCount <= 24) and (reduceTimer == 0) then + Graphics.unplaceSprites(pbarGfx_arrow, 348, 570); + end + if(pbarCount <= 29) and (reduceTimer == 0) then + Graphics.unplaceSprites(pbarGfx_arrow, 364, 570); + end + if(pbarCount <= 34) and (reduceTimer == 0) then + Graphics.unplaceSprites(pbarGfx_arrow, 380, 570); + end + + + --end + end + + + + + + + --Start Timer Events + + if(timerEnabled == true) then + timeelapsed = round(framecounter / 60, 0); + if(beatLevel == false) then + Graphics.placeSprite(1, uiImage, 486, 569, "", 2); + Text.print(string.format("%03d",secondsleft - timeelapsed), 1, 524, 570); + end + + + --Text.print("Time to take..." .. tostring(takeTime), 0, 0); + --Text.print("Seconds left..." .. tostring(secondsleft - timeelapsed), 0, 15); + + + if (passTime == true) then + framecounter = framecounter + 1; + end + if(timeelapsed >= secondsleft) then + passTime = false; + if(beatLevel == false) then + if(playerkilled == false) then + player1:kill(); + if(player2 ~= nil) then + if(player2.isValid) then + player2:kill(); + end + end + playerkilled = true; + end + end + end + if((secondsleft - timeelapsed) <= 100) then + if(passTime == true) then + if(warnedPlayer == false) then + warnedPlayer = true; + playSFXSDL(resPath .. "\\warning.wav"); + --test = "-----WARNING!-----\n\nYou're running out of time!"; + --Text.showMessageBox(type(test)); + end + end + end + + if(Level.winState() > 0) then + + beatLevel = true; + passTime = false; + postWinFrameCounter = postWinFrameCounter + 1; + smb_threeHud_API.doEndingStuffs(); + end + end + + + local added = false; + local showTimeLeft = false; + local showPointCalc = false; + local showAddPoints = false; + local countPoints = false; + + + +-- Start SMB3 Cards events + + if(firstRun)then + + if(card1 == 0) then + Graphics.placeSprite(1, starcard, smb_threeHud_API.GUIPosition1.x, smb_threeHud_API.GUIPosition1.y); + elseif(card1 == 1) then + Graphics.placeSprite(1, mushroomcard, smb_threeHud_API.GUIPosition1.x, smb_threeHud_API.GUIPosition1.y); + elseif(card1 == 2) then + Graphics.placeSprite(1, flowercard, smb_threeHud_API.GUIPosition1.x, smb_threeHud_API.GUIPosition1.y); + end + + if(card2 == 0) then + Graphics.placeSprite(1, starcard, smb_threeHud_API.GUIPosition2.x, smb_threeHud_API.GUIPosition2.y); + elseif(card2 == 1) then + Graphics.placeSprite(1, mushroomcard, smb_threeHud_API.GUIPosition2.x, smb_threeHud_API.GUIPosition2.y); + elseif(card2 == 2) then + Graphics.placeSprite(1, flowercard, smb_threeHud_API.GUIPosition2.x, smb_threeHud_API.GUIPosition2.y); + end + + if(card3 == 0) then + Graphics.placeSprite(1, starcard, smb_threeHud_API.GUIPosition3.x, smb_threeHud_API.GUIPosition3.y); + elseif(card3 == 1) then + Graphics.placeSprite(1, mushroomcard, smb_threeHud_API.GUIPosition3.x, smb_threeHud_API.GUIPosition3.y); + elseif(card3 == 2) then + Graphics.placeSprite(1, flowercard, smb_threeHud_API.GUIPosition3.x, smb_threeHud_API.GUIPosition3.y); + end + + + firstRun = false + end + + temp = NPC.get(11, -1); + + if(temp == nil) then + + elseif(temp[1] ~= nil) then + thiscard = (temp[1]:mem(0xE4, FIELD_WORD)); + -- Text.print(tostring(temp[1]:mem(0xE4, FIELD_WORD)), 0, 0); + end + + --temp[0]:mem(0xE4, FIELD_WORD); + + + + if(Level.winState() > 0) then + smb_threeHud_API.endLevel(); + + end + + + + +end + +function smb_threeHud_API.doEndingStuffs() + local timeLeftDrawPoint = {x = 288, y = 150} + local pointCalculationDrawPoint = {x = 247, y = 170} + local addPointsDrawPoint = {x = 365, y = 515}; + local timeleft = secondsleft - timeelapsed; + + if(getSeconds == false) then + takeTime = secondsleft - timeelapsed; + getSeconds = true; + end + + local newPoints = tonumber(mem(0x00B2C8E4, FIELD_DWORD)) + (timeleft * 50); + + Text.print("COURSE CLEAR", 288, 150); + + Graphics.placeSprite(1, uiImage, 486, 569, "", 2); + Text.print(string.format("%03d",takeTime), 1, 524, 570); + + + timeelapsed = round(postWinFrameCounter / 60, 0); + if(timeelapsed > 0) then + showPointCalc = true; + end + + if(timeelapsed > 1) then + if(added ~= true) then + showAddPoints = true; + countPoints = true; + end + end + + if(timeelapsed == 4) or (takeTime <= 0) then + if(added ~= true) then + mem(0x00B2C8E4, FIELD_DWORD, newPoints); + added = true; + showAddPoints = false; + end + end + + if(countPoints == true) then + if(takeTime > 100) then + takeTime = takeTime - 10; + playSFXSDL(resPath .. "\\drumroll.wav"); + elseif(takeTime >= 1) then + takeTime = takeTime - 1; + playSFXSDL(resPath .. "\\drumroll.wav"); + elseif(takeTime <= 0) then + takeTime = 0; + countPoints = false; + end + end + + + + + if(showPointCalc) then + Text.print(tostring(timeleft) .. " x 50 = " .. tostring(timeleft * 50), pointCalculationDrawPoint.x, pointCalculationDrawPoint.y); + end + if(showAddPoints == true) then + Text.print("+" .. tostring(timeleft * 50), 3, addPointsDrawPoint.x, addPointsDrawPoint.y); + + end +end + + +function smb_threeHud_API.getSecondsLeft() + return secondsleft; +end + +function smb_threeHud_API.setSecondsLeft(to_set) + if (to_set > 999) then + secondsleft = 999; + elseif (to_set < 0) then + setSecondsLeft = 0; + else + secondsleft = to_set; + end +end + +function smb_threeHud_API.pauseTimer() + passTime = false; +end + +function smb_threeHud_API.setTimerState(b_tf) + timerEnabled = b_tf; +end + +local clock = os.clock; +function sleep(n) -- seconds + local t0 = clock(); + while clock() - t0 <= n do end +end + +function round(num, idp) + local mult = 10^(idp or 0) + return math.floor(num * mult + 0.5) / mult +end + +function smb_threeHud_API.endLevel() + + levelFinished = true; + + if(doesUseCard == true) then + + if(Level.winState() == 1) then + + postWinFrameCounter = postWinFrameCounter + 1; + local endLevelTimer = round(postWinFrameCounter / 60, 0); + + if (addCard == false) then + if(cards == nil) then + cards = 0; + end + + if(cards >= 4) then + cards = 0; + addCard = true; + elseif(cards < 3) then + local newcard = 1; + cards = cards + newcard; + addCard = true; + end + end + + gotcard = true; + + if (card1 == nil) then + card1 = -1; + end + if (card2 == nil) then + card2 = -1; + end + if (card3 == nil) then + card3 = -1; + end + + + if(cards == 1) then + if(card1 < 0) then + card1 = tonumber(thiscard); + dCard1 = card1; + dataInstance:set("card1", tostring(card1)); + end + + if(card1 == 0) then + Graphics.placeSprite(1, starcard, smb_threeHud_API.GUIPosition1.x, smb_threeHud_API.GUIPosition1.y); + elseif(card1 == 1) then + Graphics.placeSprite(1, mushroomcard, smb_threeHud_API.GUIPosition1.x, smb_threeHud_API.GUIPosition1.y); + elseif(card1 == 2) then + Graphics.placeSprite(1, flowercard, smb_threeHud_API.GUIPosition1.x, smb_threeHud_API.GUIPosition1.y); + end + end + + if(cards == 2) then + if(card2 < 0) then + card2 = tonumber(thiscard); + dCard2 = card2; + dataInstance:set("card2", tostring(card2)); + end + + if(card2 == 0) then + Graphics.placeSprite(1, starcard, smb_threeHud_API.GUIPosition2.x, smb_threeHud_API.GUIPosition2.y); + elseif(card2 == 1) then + Graphics.placeSprite(1, mushroomcard, smb_threeHud_API.GUIPosition2.x, smb_threeHud_API.GUIPosition2.y); + elseif(card2 == 2) then + Graphics.placeSprite(1, flowercard, smb_threeHud_API.GUIPosition2.x, smb_threeHud_API.GUIPosition2.y); + end + end + + if(cards == 3) then + if(card3 < 0) then + card3 = tonumber(thiscard); + dCard3 = card3; + dataInstance:set("card3", tostring(card3)); + end + + if(card3 == 0) then + Graphics.placeSprite(1, starcard, smb_threeHud_API.GUIPosition3.x, smb_threeHud_API.GUIPosition3.y); + elseif(card3 == 1) then + Graphics.placeSprite(1, mushroomcard, smb_threeHud_API.GUIPosition3.x, smb_threeHud_API.GUIPosition3.y); + elseif(card3 == 2) then + Graphics.placeSprite(1, flowercard, smb_threeHud_API.GUIPosition3.x, smb_threeHud_API.GUIPosition3.y); + end + end + + Text.print("Got Card!", 280, 115) + if(thiscard == 1) then + Graphics.placeSprite(1,mushroomcard,450,96, "", 2); + local dCard1 = tonumber(dataInstance:get("card1 ")); + elseif(thiscard == 2) then + Graphics.placeSprite(1,flowercard,450,96, "", 2); + local dCard2 = tonumber(dataInstance:get("card2 ")); + elseif(thiscard == 0) then + Graphics.placeSprite(1,starcard,450,96, "", 2); + local dCard3 = tonumber(dataInstance:get("card3 ")); + end + + + + + if(cards == 1) then + --Text.print("set card1 to " .. tostring(card1), 0, 45); + + elseif(cards == 2) then + --Text.print("set card2 to " .. tostring(card2), 0, 45); + + elseif(cards == 3) then + --Text.print("set card3 to " .. tostring(card3), 0, 45); + + if(card1 == 0) and (card2 == 0) and (card3 == 0) then + mem(0x00B2C5AC, FIELD_FLOAT, (curLivesCount + 5)); + if(playOnce == false) then + playSFXSDL(resPath .. "\\1up.wav"); + playOnce = true; + end + Graphics.placeSprite(1,fiveup,500,110); + elseif(card1 == 1) and (card2 == 1) and (card3 == 1) then + mem(0x00B2C5AC, FIELD_FLOAT, (curLivesCount + 2)); + if(playOnce == false) then + playSFXSDL(resPath .. "\\1up.wav"); + playOnce = true; + end + Graphics.placeSprite(1,twoup,500,110); + elseif(card1 == 2) and (card2 == 2) and (card3 == 2) then + mem(0x00B2C5AC, FIELD_FLOAT, (curLivesCount + 3)); + if(playOnce == false) then + playSFXSDL(resPath .. "\\1up.wav"); + playOnce = true; + end + Graphics.placeSprite(1,threeup,500,110); + else + mem(0x00B2C5AC, FIELD_FLOAT, (curLivesCount + 1)); + if(playOnce == false) then + playSFXSDL(resPath .. "\\1up.wav"); + playOnce = true; + end + Graphics.placeSprite(1,oneup,500,110); + end + + if(endLevelTimer >= 1) then + card1 = -1; + card2 = -1; + card3 = -1; + cards = 0; + dataInstance:set("card1", tostring(card1)); + dataInstance:set("card2", tostring(card2)); + dataInstance:set("card3", tostring(card3)); + end + end + + dataInstance:set("cards", tostring(cards)); + + dataInstance:save(); + end + end + +end + + +function smb_threeHud_API.usesCard(me) + doesUseCard = me; +end + +function smb_threeHud_API.usesPBar(me) + usePBar = me; +end + +function smb_threeHud_API.useEasyMode(me) + toggleEasyMode = me; +end + +function smb_threeHud_API.disableSpinJump(me) + disableSpinJump = me; +end + +function smb_threeHud_API.onInputUpdateOverride() + + + if(disableSpinJump == true) then + if(player.altJumpKeyPressing == true) and (timer == 1) and (player:mem(0x146, FIELD_WORD) == 2) or (player.altJumpKeyPressing == true) and (timer == 1) and (player:mem(0x48, FIELD_WORD) > 0) or (player.altJumpKeyPressing == true) and (timer == 1) and (player:mem(0x176, FIELD_WORD) > 0) or (player.altJumpKeyPressing == true) and (timer == 1) and (player:mem(0x40, FIELD_WORD) > 0) then + player.altJumpKeyPressing = false; + player:mem(0x50, FIELD_WORD, 0); + player:mem(0x11C, FIELD_WORD, 15); + player.jumpKeyPressing = true; + timer = 0; + elseif(player.altJumpKeyPressing == false) and (timer == 0) then + timer = 1; + end + end + +end + + +return smb_threeHud_API; \ No newline at end of file diff --git a/LuaScriptsLibExt/smb3overhaul/1up.png b/LuaScriptsLibExt/smb3overhaul/1up.png new file mode 100644 index 000000000..ca2895ac7 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/1up.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/1up.wav b/LuaScriptsLibExt/smb3overhaul/1up.wav new file mode 100644 index 000000000..1d219754f Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/1up.wav differ diff --git a/LuaScriptsLibExt/smb3overhaul/2up.png b/LuaScriptsLibExt/smb3overhaul/2up.png new file mode 100644 index 000000000..4065c4e3d Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/2up.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/3up.png b/LuaScriptsLibExt/smb3overhaul/3up.png new file mode 100644 index 000000000..2a5448aaa Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/3up.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/5up.png b/LuaScriptsLibExt/smb3overhaul/5up.png new file mode 100644 index 000000000..f48316ec9 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/5up.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/back.png b/LuaScriptsLibExt/smb3overhaul/back.png new file mode 100644 index 000000000..498920061 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/back.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/coincounter.png b/LuaScriptsLibExt/smb3overhaul/coincounter.png new file mode 100644 index 000000000..2d21bbac3 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/coincounter.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/drumroll.wav b/LuaScriptsLibExt/smb3overhaul/drumroll.wav new file mode 100644 index 000000000..05b385dee Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/drumroll.wav differ diff --git a/LuaScriptsLibExt/smb3overhaul/flower.png b/LuaScriptsLibExt/smb3overhaul/flower.png new file mode 100644 index 000000000..35527960a Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/flower.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/lifecounter.png b/LuaScriptsLibExt/smb3overhaul/lifecounter.png new file mode 100644 index 000000000..df4967836 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/lifecounter.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/mushroom.png b/LuaScriptsLibExt/smb3overhaul/mushroom.png new file mode 100644 index 000000000..2e8bc4bfa Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/mushroom.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/pbar.png b/LuaScriptsLibExt/smb3overhaul/pbar.png new file mode 100644 index 000000000..303d55645 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/pbar.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/pbar_active.png b/LuaScriptsLibExt/smb3overhaul/pbar_active.png new file mode 100644 index 000000000..1112f56c0 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/pbar_active.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/pbar_arrow.png b/LuaScriptsLibExt/smb3overhaul/pbar_arrow.png new file mode 100644 index 000000000..2db961fac Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/pbar_arrow.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/pmeter.wav b/LuaScriptsLibExt/smb3overhaul/pmeter.wav new file mode 100644 index 000000000..7a36c0024 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/pmeter.wav differ diff --git a/LuaScriptsLibExt/smb3overhaul/star.png b/LuaScriptsLibExt/smb3overhaul/star.png new file mode 100644 index 000000000..acfa17e8d Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/star.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/starcounter.png b/LuaScriptsLibExt/smb3overhaul/starcounter.png new file mode 100644 index 000000000..74337e639 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/starcounter.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/ui.png b/LuaScriptsLibExt/smb3overhaul/ui.png new file mode 100644 index 000000000..cbb614b7d Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/ui.png differ diff --git a/LuaScriptsLibExt/smb3overhaul/warning.wav b/LuaScriptsLibExt/smb3overhaul/warning.wav new file mode 100644 index 000000000..c008697e1 Binary files /dev/null and b/LuaScriptsLibExt/smb3overhaul/warning.wav differ diff --git a/LuaScriptsLibExt/vectr.lua b/LuaScriptsLibExt/vectr.lua new file mode 100644 index 000000000..b1ac88de2 --- /dev/null +++ b/LuaScriptsLibExt/vectr.lua @@ -0,0 +1,1724 @@ +--********************************-- +--** _ __ __ ____ **-- +--**| | / /__ _____/ /_/ __ \ **-- +--**| | / / _ \/ ___/ __/ /_/ / **-- +--**| |/ / __/ /__/ /_/ _, _/ **-- +--**|___/\___/\___/\__/_/ |_| **-- +--** **-- +--********************************-- +------Created by Hoeloe - 2015------ +-----Open-Source Vector Library----- +-------For Super Mario Bros X------- +----------------v1.0---------------- + +local vectr = {}; +local version = "1.0"; + +local function mthide(a) + return {}; +end + +do --VECTOR + +local function proj(a,b) + local n = b:normalise(); + return (a..n)*n; +end + +do --Vector 2 + +--METATABLE +local createmt2; +local v2mt = {}; +function v2mt.dot(a,b) + return a.x*b.x + a.y*b.y +end + +function v2mt.typecheck(a) + if(type(a) == "number") then + return "number"; + elseif(a._type ~= nil and a._type == "vector2") then + return "vector2"; + else + error("Calculation cannot be performed on an object of this type.", 2); + end +end + +function v2mt.newindex(obj,key,val) + if(key == "x") then setmetatable(obj,createmt2(val,obj.y)) + elseif(key == "y") then setmetatable(obj,createmt2(obj.x,val)) + elseif(key == "length" or key == "sqrlength") then + error("Cannot set the length of a vector directly. Try changing the component values.",2) + elseif(key == "_type") then + error("Cannot set the type of an object.",2) + else + error("Field "..key.." does not exist in the vector2 data structure.",2); + end +end + +function v2mt.tostring(obj) + return "("..tostring(obj.x)..", "..tostring(obj.y)..")" +end + +function v2mt.add(a,b) + local ta = v2mt.typecheck(a); + local tb = v2mt.typecheck(b); + if(ta == "number") then + if(tb == "number") then + return a+b; + else + return vectr.v2(a+b.x,a+b.y) + end + elseif(type(b) == "number") then + return vectr.v2(a.x+b,a.y+b) + else + return vectr.v2(a.x+b.x,a.y+b.y) + end +end + +function v2mt.sub(a,b) + local ta = v2mt.typecheck(a); + local tb = v2mt.typecheck(b); + if(ta == "number") then + if(tb == "number") then + return a-b; + else + return vectr.v2(a-b.x,a-b.y) + end + elseif(type(b) == "number") then + return vectr.v2(a.x-b,a.y-b) + else + return vectr.v2(a.x-b.x,a.y-b.y) + end +end + +function v2mt.neg(a) + return vectr.v2(-a.x,-a.y) +end + +function v2mt.mul(a,b) + local ta = v2mt.typecheck(a); + local tb = v2mt.typecheck(b); + if(ta == "number") then + if(tb == "number") then + return a*b; + else + return vectr.v2(a*b.x,a*b.y) + end + elseif(tb == "number") then + return vectr.v2(a.x*b,a.y*b) + else + return vectr.v2(a.x*b.x,a.y*b.y) + end +end + +function v2mt.div(a,b) + local ta = v2mt.typecheck(a); + local tb = v2mt.typecheck(b); + if(ta == "number") then + if(tb == "number") then + return a/b; + else + return vectr.v2(a/b.x,a/b.y) + end + elseif(tb == "number") then + return vectr.v2(a.x/b,a.y/b) + else + return vectr.v2(a.x/b.x,a.y/b.y) + end +end + +function v2mt.equals(a,b) + if(a == nil or b == nil or typecheck(a) ~= "vector2" or typecheck(b) ~= "vector2") then + return false; + else + return a.x==b.x and a.y==b.y + end +end + +function v2mt.len(a) + return 2; +end + +createmt2 = function(x,y,sl,l) + local mt = {} + mt.__index = + function(obj,key) + if(key == "x") then return x + elseif(key == "y") then return y + elseif(key == "sqrlength") then + if(sl == nil) then + local sm = x*x + y*y; + setmetatable(obj,createmt2(x,y,sm)); + return sm; + else + return sl; + end + elseif(key == "length") then + if(l == nil) then + local sm = sl or (x*x + y*y); + local mag = math.sqrt(sm); + setmetatable(obj,createmt2(x,y,sm,mag)); + return mag; + else + return l; + end + elseif(key == "_type") then + return "vector2"; + else + return nil; + end + end + mt.__newindex = v2mt.newindex; + mt.__tostring = v2mt.tostring; + mt.__add = v2mt.add; + mt.__sub = v2mt.sub; + mt.__unm = v2mt.neg; + mt.__mul = v2mt.mul; + mt.__div = v2mt.div; + mt.__concat = v2mt.dot; + mt.__mod = proj; + mt.__eq = v2mt.equals; + mt.__len = v2mt.len; + --mt.__metatable = mthide; + + return mt; +end + +--CLASS DEF +local vect2 = {}; +function vect2.normalise(a) + if(a.sqrlength == 0) then + return vectr.v2(0,0) + elseif(a.sqrlength == 1) then + return a; + else + return vectr.v2(a.x/a.length,a.y/a.length); + end +end + +function vect2.rotate(a,d) + local r = d*0.0174534; --deg2rad + local sr = math.sin(r); + local cr = math.cos(r); + return vectr.v2(a.x*cr - a.y*sr, a.x*sr + a.y*cr); +end + +function vect2.lookat(a,x1,y1) + local v; + local t = v2mt.typecheck(x1); + if(t == "number") then + v = vectr.v2(x1,y1):normalise(); + else + v = x1:normalise(); + end + return v*a.length; +end + +function vect2.tov3(a) + return vectr.v3(a.x,a.y,0); +end + +function vect2.tov4(a) + return vectr.v3(a.x,a.y,0,0); +end + +vect2.normalize = vect2.normalise; +vect2.dot = v2mt.dot; +vect2.project = proj; + +--CONSTRUCTOR +function vectr.v2(x,y) + local v = {}; + + for m,n in pairs(vect2) do + v[m] = n; + end + + if(type(x) == "number") then + y = y or x; + elseif(x ~= nil and x._type ~= nil and x._type == "vector2") then + y = x.y; + x = x.x; + else + error("Invalid vector definition.",2) + end + + setmetatable(v,createmt2(x,y)); + return v; +end + +end + +do --Vector 3 + +--METATABLE +local createmt3; + +local v3mt = {} +function v3mt.dot(a,b) + return a.x*b.x + a.y*b.y + a.z*b.z +end + +function v3mt.cross(a,b) + return vectr.v3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x) +end + +function v3mt.typecheck(a) + if(type(a) == "number") then + return "number"; + elseif(a._type ~= nil and a._type == "vector3") then + return "vector3"; + else + error("Calculation cannot be performed on an object of this type.", 2); + end +end + +function v3mt.newindex(obj,key,val) + if(key == "x") then setmetatable(obj,createmt3(val,obj.y,obj.z)) + elseif(key == "y") then setmetatable(obj,createmt3(obj.x,val,obj.z)) + elseif(key == "z") then setmetatable(obj,createmt3(obj.x,obj.y,val)) + elseif(key == "length" or key == "sqrlength") then + error("Cannot set the length of a vector directly. Try changing the component values.",2) + elseif(key == "_type") then + error("Cannot set the type of an object.",2) + else + error("Field "..key.." does not exist in the vector3 data structure.",2); + end +end + +function v3mt.tostring(obj) + return "("..tostring(obj.x)..", "..tostring(obj.y)..", "..tostring(obj.z)..")" +end + +function v3mt.add(a,b) + local ta = v3mt.typecheck(a); + local tb = v3mt.typecheck(b); + if(ta == "number") then + if(ta == "number") then + return a+b; + else + return vectr.v3(a+b.x,a+b.y,a+b.z) + end + elseif(tb == "number") then + return vectr.v3(a.x+b,a.y+b,a.z+b) + else + return vectr.v3(a.x+b.x,a.y+b.y,a.z+b.z) + end +end + +function v3mt.sub(a,b) + local ta = v3mt.typecheck(a); + local tb = v3mt.typecheck(b); + if(ta == "number") then + if(ta == "number") then + return a-b; + else + return vectr.v3(a-b.x,a-b.y,a-b.z) + end + elseif(tb == "number") then + return vectr.v3(a.x-b,a.y-b,a.z-b) + else + return vectr.v3(a.x-b.x,a.y-b.y,a.z-b.z) + end +end + +function v3mt.neg(a) + return vectr.v3(-a.x,-a.y,-a.z) +end + + +function v3mt.mul(a,b) + local ta = v3mt.typecheck(a); + local tb = v3mt.typecheck(b); + if(ta == "number") then + if(tb == "number") then + return a*b; + else + return vectr.v3(a*b.x,a*b.y,a*b.z) + end + elseif(tb == "number") then + return vectr.v3(a.x*b,a.y*b,a.z*b) + else + return vectr.v3(a.x*b.x,a.y*b.y,a.z*b.z) + end +end + +function v3mt.div(a,b) + local ta = v3mt.typecheck(a); + local tb = v3mt.typecheck(b); + if(ta == "number") then + if(ta == "number") then + return a/b; + else + return vectr.v3(a/b.x,a/b.y,a/b.z) + end + elseif(tb == "number") then + return vectr.v3(a.x/b,a.y/b,a.z/b) + else + return vectr.v3(a.x/b.x,a.y/b.y,a.z/b.z) + end +end + +function v3mt.equals(a,b) + return (a.x==b.x) and (a.y==b.y) and (a.z==b.z) +end + +function v3mt.len(a) + return 3; +end + +createmt3 = function(x,y,z,sl,l) + local mt = {} + mt.__index = + function(obj,key) + if(key == "x") then return x + elseif(key == "y") then return y + elseif(key == "z") then return z + elseif(key == "sqrlength") then + if(sl == nil) then + local sm = x*x + y*y + z*z; + setmetatable(obj,createmt3(x,y,z,sm)); + return sm; + else + return sl; + end + elseif(key == "length") then + if(l == nil) then + local sm = sl or (x*x + y*y + z*z); + local mag = math.sqrt(sm); + setmetatable(obj,createmt3(x,y,z,sm,mag)); + return mag; + else + return l; + end + elseif(key == "_type") then + return "vector3"; + else + return nil; + end + end + + mt.__newindex = v3mt.newindex; + mt.__tostring = v3mt.tostring; + mt.__add = v3mt.add; + mt.__sub = v3mt.sub; + mt.__unm = v3mt.neg; + mt.__mul = v3mt.mul; + mt.__div = v3mt.div; + mt.__concat = v3mt.dot; + mt.__pow = v3mt.cross; + mt.__mod = proj; + mt.__eq = v3mt.equals; + mt.__len = v3mt.len; + --mt.__metatable = mthide; + + return mt; +end + +--CLASS DEF +local vect3 = {} +function vect3.normalise(a) + if(a.sqrlength == 0) then + return vectr.v3(0,0,0) + elseif(a.sqrlength == 1) then + return a; + else + return vectr.v3(a.x/a.length,a.y/a.length,a.z/a.length); + end +end + +function vect3.rotate(a,roll,pitch,yaw) + if(type(pitch) == "number") then --euler + local r_r = roll*0.0174534; --deg2rad + local p_r = pitch*0.0174534; --deg2rad + local y_r = yaw*0.0174534; --deg2rad + + local cosx = math.cos(r_r); + local sinx = math.sin(r_r); + local cosy = math.cos(p_r); + local siny = math.sin(p_r); + local cosz = math.cos(y_r); + local sinz = math.sin(y_r); + + local x = a.x; + local y = a.y; + local z = a.z; + + --rotz + x = x*cosz - y*sinz; + y = x*sinz + y*cosz; + + --rot y + x = x*cosy + z*siny; + z = -x*siny + z*cosy; + + --rot x + y = y*cosx - z*sinx + z = y*sinx + z*cosx; + + return vectr.v3(x,y,z); + elseif(pitch ~= nil and pitch._type ~= nil and pitch._type == "vector3") then --angleaxis + local p = pitch:normalise(); + local x = roll*0.0174534; --deg2rad + local cosx = math.cos(x); + local sinx = math.sin(x); + return cosx*a + sinx*(p^a) + (1-cosx)*(p..a)*p; + elseif(roll ~= nil and roll._type ~= nil and roll._type == "mat3") then --matrix + return roll*a; + else + error("Invalid rotation format specified.",2) + end +end + +function vect3.lookat(a,x1,y1,z1) + local v3; + local t = v3mt.typecheck(x1); + if(t == "number") then + v3 = vectr.v3(x1,y1,z1):normalise(); + else + v3 = x1:normalise(); + end + return v3*a.length; +end + +function vect3.planeproject(a,b) + b = b:normalise(); + local n = a%b; + return a-n; +end + +function vect3.tov2(a) + return vectr.v2(a.x,a.y); +end + +function vect3.tov4(a) + return vectr.v4(a.x,a.y,a.z,0); +end + +vect3.normalize = vect3.normalise; +vect3.dot = v3mt.dot; +vect3.cross = v3mt.cross; +vect3.project = proj; + +--CONSTRUCTOR +function vectr.v3(x,y,z) + local v = {}; + + for m,n in pairs(vect3) do + v[m] = n; + end + + if(type(x) == "number") then + y = y or x; + z = z or y; + elseif(x ~= nil and x._type ~= nil and x._type == "vector2") then + y = x.y; + z = 0; + x = x.x; + elseif(x ~= nil and x._type ~= nil and x._type == "vector3") then + y = x.y; + z = x.z; + x = x.x; + else + error("Invalid vector definition.",2) + end + + setmetatable(v,createmt3(x,y,z)); + return v; +end + +end + +do --Vector 4 + +--METATABLE +local createmt4; +local v4mt = {} + +function v4mt.dot(a,b) + return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w; +end + +function v4mt.typecheck(a) + if(type(a) == "number") then + return "number"; + elseif(a._type ~= nil and a._type == "vector4") then + return "vector4"; + else + error("Calculation cannot be performed on an object of this type.", 2); + end +end + +function v4mt.newindex(obj,key,value) + if(key == "x") then setmetatable(obj,createmt4(val,obj.y,obj.z,obj.w)) + elseif(key == "y") then setmetatable(obj,createmt4(obj.x,val,obj.z,obj.w)) + elseif(key == "z") then setmetatable(obj,createmt4(obj.x,obj.y,val,obj.w)) + elseif(key == "w") then setmetatable(obj,createmt4(obj.x,obj.y,obj.z,val)) + elseif(key == "length" or key == "sqrlength") then + error("Cannot set the length of a vector directly. Try changing the component values.",2) + elseif(key == "_type") then + error("Cannot set the type of an object.",2) + else + error("Field "..key.." does not exist in the vector4 data structure.",2); + end +end + +function v4mt.tostring(obj) + return "("..tostring(obj.x)..", "..tostring(obj.y)..", "..tostring(obj.z)..", "..tostring(obj.w)..")" +end + +function v4mt.add(a,b) + local ta = v4mt.typecheck(a); + local tb = v4mt.typecheck(b); + if(ta == "number") then + if(ta == "number") then + return a+b; + else + return vectr.v4(a+b.x,a+b.y,a+b.z,a+b.w) + end + elseif(tb == "number") then + return vectr.v4(a.x+b,a.y+b,a.z+b,a.w+b) + else + return vectr.v4(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w) + end +end + +function v4mt.sub(a,b) + local ta = v4mt.typecheck(a); + local tb = v4mt.typecheck(b); + if(ta == "number") then + if(ta == "number") then + return a-b; + else + return vectr.v4(a-b.x,a-b.y,a-b.z,a-b.w) + end + elseif(tb == "number") then + return vectr.v4(a.x-b,a.y-b,a.z-b,a.w-b) + else + return vectr.v4(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w) + end +end + +function v4mt.neg(a) + return vectr.v4(-a.x,-a.y,-a.z,-a.w) +end + +function v4mt.mul(a,b) + local ta = v3mt.typecheck(a); + local tb = v3mt.typecheck(b); + if(ta == "number") then + if(ta == "number") then + return a*b; + else + return vectr.v4(a*b.x,a*b.y,a*b.z,a*b.w) + end + elseif(tb == "number") then + return vectr.v4(a.x*b,a.y*b,a.z*b,a.w*b) + else + return vectr.v4(a.x*b.x,a.y*b.y,a.z*b.z,a.w*b.w) + end +end + +function v4mt.div(a,b) + local ta = v4mt.typecheck(a); + local tb = v4mt.typecheck(b); + if(ta == "number") then + if(ta == "number") then + return a/b; + else + return vectr.v4(a/b.x,a/b.y,a/b.z,a/b.w) + end + elseif(tb == "number") then + return vectr.v4(a.x/b,a.y/b,a.z/b,a.w/b) + else + return vectr.v4(a.x/b.x,a.y/b.y,a.z/b.z,a.w/b.w) + end +end + +function v4mt.equals(a,b) + return (a.x==b.x) and (a.y==b.y) and (a.z==b.z) and (a.w==b.w) +end + +function v4mt.len(a) + return 4; +end + +createmt4 = function(x,y,z,w,sl,l) + local mt = {} + mt.__index = + function(obj,key) + if(key == "x") then return x + elseif(key == "y") then return y + elseif(key == "z") then return z + elseif(key == "w") then return w + elseif(key == "sqrlength") then + if(sl == nil) then + local sm = x*x + y*y + z*z + w*w; + setmetatable(obj,createmt4(x,y,z,w,sm)); + return sm; + else + return sl; + end + elseif(key == "length") then + if(l == nil) then + local sm = sl or (x*x + y*y + z*z + w*w); + local mag = math.sqrt(sm); + setmetatable(obj,createmt4(x,y,z,w,sm,mag)); + return mag; + else + return l; + end + elseif(key == "_type") then + return "vector4"; + else + return nil; + end + end + + mt.__newindex = v4mt.newindex; + mt.__tostring = v4mt.tostring; + mt.__add = v4mt.add; + mt.__sub = v4mt.sub; + mt.__unm = v4mt.neg; + mt.__mul = v4mt.mul; + mt.__div = v4mt.div; + mt.__concat = v4mt.dot; + mt.__mod = proj; + mt.__eq = v4mt.equals; + mt.__len = v4mt.len; + --mt.__metatable = mthide; + + return mt; +end + +--CLASS DEF +local vect4 = {} +function vect4.normalise(a) + if(a.sqrlength == 0) then + return vectr.v4(0,0,0,0) + elseif(a.sqrlength == 1) then + return a; + else + return vectr.v4(a.x/a.length,a.y/a.length,a.z/a.length,a.w/a.length); + end +end + +function vect4.rotate(a,roll,pitch,yaw) + if(type(pitch) == "number") then --euler + local r_r = roll*0.0174534; --deg2rad + local p_r = pitch*0.0174534; --deg2rad + local y_r = yaw*0.0174534; --deg2rad + + local cosx = math.cos(r_r); + local sinx = math.sin(r_r); + local cosy = math.cos(p_r); + local siny = math.sin(p_r); + local cosz = math.cos(y_r); + local sinz = math.sin(y_r); + + local x = a.x; + local y = a.y; + local z = a.z; + + --rotz + x = x*cosz - y*sinz; + y = x*sinz + y*cosz; + + --rot y + x = x*cosy + z*siny; + z = -x*siny + z*cosy; + + --rot x + y = y*cosx - z*sinx + z = y*sinx + z*cosx; + + return vectr.v4(x,y,z,a.w); + elseif(pitch ~= nil and pitch._type ~= nil and pitch._type == "vector3") then --angleaxis + local p = pitch:normalise(); + local x = roll*0.0174534; --deg2rad + local cosx = math.cos(x); + local sinx = math.sin(x); + local a3 = a:tov3(); + a3 = cosx*a3 + sinx*(p^a3) + (1-cosx)*(p..a3)*p; + return vectr.v4(a3.x,a3.y,a3.z,a.w); + elseif(roll ~= nil and roll._type ~= nil and roll._type == "mat3") then --3matrix + local a3 = a:tov3(); + a3 = roll*a3; + return vectr.v4(a3.x,a3.y,a3.z,a.w); + elseif(roll ~= nil and roll._type ~= nil and roll._type == "mat4") then --4matrix + return roll*a; + else + error("Invalid rotation format specified.",2) + end +end + +function vect4.lookat(a,x1,y1,z1) + local v3; + if(type(x1) == "number") then + v3 = vectr.v4(x1,y1,z1):normalise(); + elseif(x1 ~= nil and x1._type ~= nil and x1._type == "vector3") then + v3 = x1:normalise(); + else + error("Invalid lookat vector.",2) + end + v3 = v3*(a:tov3()).length; + return vectr.v4(v3.x,v3.y,v3.z,a.w) +end + +function vect4.planeproject(a,b) + b = b:normalise(); + local n = a%b; + return a-n; +end + +function vect4.tov2(a) + return vectr.v2(a.x,a.y); +end + +function vect4.tov3(a) + return vectr.v3(a.x,a.y,a.z); +end + +vect4.normalize = vect4.normalise; +vect4.dot = v4mt.dot; +vect4.project = proj; + +--CONSTRUCTOR +function vectr.v4(x,y,z,w) + local v = {}; + + for m,n in pairs(vect4) do + v[m] = n; + end + + if(type(x) == "number") then + y = y or x; + z = z or y; + w = w or 1; + elseif(x ~= nil and x._type ~= nil and x._type == "vector2") then + y = x.y; + z = 0; + w = 1; + x = x.x; + elseif(x ~= nil and x._type ~= nil and x._type == "vector3") then + y = x.y; + z = x.z; + w = 1; + x = x.x; + elseif(x ~= nil and x._type ~= nil and x._type == "vector4") then + y = x.y; + z = x.z; + w = x.w; + x = x.x; + else + error("Invalid vector definition.",2) + end + setmetatable(v,createmt4(x,y,z,w)); + return v; +end + +end + +end + +do --MATRIX + +local function trace(a,c) + local t = 0; + for i=1,c,1 do + t = t+a[i][i]; + end + return t; +end + +do --Matrix 2x2 + +--METATABLE +local mat2_mt = {} +mat2_mt.__index = function(obj,key) + if(key == "det") then + return obj[1][1]*obj[2][2] - obj[1][2]*obj[2][1]; + elseif(key == "trace") then + return trace(obj,2); + elseif(key == "inverse") then + local d = obj.det; + if(d == 0) then + return nil; --Matrix is singular and has no inverse. + end + return vectr.mat2({obj[2][2], -obj[1][2]}, {-obj[2][1],obj[1][1]})/d; + elseif(key == "transpose") then + return vectr.mat2({obj[1][1],obj[2][1]},{obj[1][2],obj[2][2]}); + elseif(key == "_type") then + return "mat2"; + else + return nil; + end +end + +function mat2_mt.typecheck(a,b) + if(type(a) == "number") then + return "number"; + elseif(b and a._type ~= nil and a._type == "vector2") then + return "vector2"; + elseif(a._type ~= nil and a._type == "mat2") then + return "mat2"; + else + error("Calculation cannot be performed on an object of this type.", 2); + end +end + +mat2_mt.__newindex = function(obj,key,val) + if(key == "det") then + error("Cannot set the determinant of a matrix.",2) + elseif(key == "trace") then + error("Cannot set the trace of a matrix.",2) + elseif(key == "inverse") then + error("Cannot set the inverse of a matrix.",2) + elseif(key == "transpose") then + error("Cannot set the transpose of a matrix.",2) + elseif(key == "_type") then + error("Cannot set the type of an object.",2) + else + error("Field "..key.." does not exist in the mat2 data structure.",2); + end +end + +mat2_mt.__add = function(a,b) + local ta = mat2_mt.typecheck(a,false); + local tb = mat2_mt.typecheck(b,false); + if(ta == "number") then + if(tb == "number") then + return a+b; + else + local t = vectr.mat2(b); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]+a; + end + end + return t; + end + elseif(tb == "number") then + local t = vectr.mat2(a); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]+b; + end + end + return t; + else + local t = vectr.mat2(a); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]+b[i][j]; + end + end + return t; + end +end +mat2_mt.__sub = function(a,b) + local ta = mat2_mt.typecheck(a,false); + local tb = mat2_mt.typecheck(b,false); + if(ta == "number") then + if(tb == "number") then + return a-b; + else + local t = vectr.mat2(b); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = a-t[i][j]; + end + end + return t; + end + elseif(tb == "number") then + local t = vectr.mat2(a); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]-b; + end + end + return t; + else + local t = vectr.mat2(a); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]-b[i][j]; + end + end + return t; + end +end +mat2_mt.__unm = function(a) + local t = vectr.mat2(a); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = -t[i][j]; + end + end + return t; +end +mat2_mt.__mul = +function(a,b) + local ta = mat2_mt.typecheck(a,true); + local tb = mat2_mt.typecheck(b,true); + if(ta == "number") then + if(tb == "number" or tb == "vector2") then + return a*b; + else + local t = vectr.mat2(b); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]*a; + end + end + return t; + end + elseif(ta == "vector2") then + if(tb == "mat2") then + error("Invalid matrix multiplication.",2); + else + return a*b; + end + elseif(ta == "mat2") then + if(tb == "number") then + local t = vectr.mat2(a); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]*b; + end + end + return t; + elseif(tb == "vector2") then + local t = {0,0}; + local v = {b.x,b.y}; + for i=1,2,1 do + for j=1,2,1 do + t[i] = t[i] + v[j]*a[i][j]; + end + end + return vectr.v2(t[1],t[2]) + elseif(b._type == "mat2") then + local t = vectr.mat2({0,0},{0,0}) + for i=1,2,1 do + for j=1,2,1 do + for k=1,2,1 do + t[i][j] = t[i][j] + a[i][k]*b[k][j]; + end + end + end + return t; + else + error("Invalid matrix multiplication.",2); + end + else + error("Invalid matrix multiplication.",2); + end +end +mat2_mt.__div = +function(a,b) + local ta = mat2_mt.typecheck(a,true); + local tb = mat2_mt.typecheck(b,true); + if(tb == "mat2") then + if(ta ~= "vector2") then + return a*b.inverse; + else + error("Invalid matrix operation.",2); + end + elseif(tb == "vector2") then + if(ta == "vector2" or ta == "number") then + return a/b; + else + error("Invalid matrix operation.",2); + end + else + if(ta == "vector2" or ta == "number") then + return a/b; + else + local t = vectr.mat2(a); + for i=1,2,1 do + for j=1,2,1 do + t[i][j] = t[i][j]/b; + end + end + return t; + end + end +end +mat2_mt.__eq = function(a,b) + for i=1,2,1 do + for j=1,2,1 do + if(a[i][j] ~= b[i][j]) then + return false; + end + end + end + return true; +end +mat2_mt.__tostring = function(obj) return "(("..tostring(obj[1][1])..", "..tostring(obj[1][2]).."), ("..tostring(obj[2][1])..", "..tostring(obj[2][2]).."))"; end +mat2_mt.__metatable = mthide; +mat2_mt.__len = function(a) return 2; end + +--CONSTRUCTOR +function vectr.mat2(row1,row2) + if(row1._type ~= nil and row1._type == "mat2") then + row2 = row1[2]; + row1 = row1[1]; + elseif(row1._type ~= nil and row1._type ~= "mat2") then + error("Invalid matrix definition - invalid arguments.",2) + elseif(#row1 ~= 2 or row2 == nil or #row2 ~= 2) then + error("Invalid matrix definition - wrong number of matrix elements.",2) + end + local m = {row1,row2} + m.tomat3 = function(a) + return vectr.mat3({a[1][1],a[1][2],0},{a[2][1],a[2][2],0},{0,0,1}); + end + + m.tomat4 = function(a) + return vectr.mat4({a[1][1],a[1][2],0,0},{a[2][1],a[2][2],0,0},{0,0,1,0},{0,0,0,1}); + end + + setmetatable(m,mat2_mt) + return m; +end + +end + +do --Matrix 3x3 + +local mat3_mt = {} +mat3_mt.__index = function(obj,key) + if(key == "det") then + return obj[1][1]*(obj[2][2]*obj[3][3] - obj[2][3]*obj[3][2]) - obj[1][2]*(obj[2][1]*obj[3][3] - obj[2][3]*obj[3][1]) + obj[1][3]*(obj[2][1]*obj[3][2] - obj[2][2]*obj[3][1]) + elseif(key == "trace") then + return trace(obj,3) + elseif(key == "inverse") then + local d = obj.det; + if(d == 0) then + return nil; --Matrix is singular and has no inverse. + end + local t = vectr.mat3({0,0,0},{0,0,0},{0,0,0}); + for i=1,3,1 do + local i2 = (i%3)+1; + local i3 = (i2%3)+1 + for j=1,3,1 do + local j2 = (j%3)+1; + local j3 = (j2%3)+1 + t[i][j] = obj[j2][i2]*obj[j3][i3] - obj[j3][i2]*obj[j2][i3]; + end + end + return t/d; + elseif(key == "transpose") then + return vectr.mat3({obj[1][1],obj[2][1],obj[3][1]},{obj[1][2],obj[2][2],obj[3][2]},{obj[1][3],obj[2][3],obj[3][3]}); + elseif(key == "_type") then + return "mat3"; + else + return nil; + end +end + +function mat3_mt.typecheck(a,b) + if(type(a) == "number") then + return "number"; + elseif(b and a._type ~= nil and a._type == "vector3") then + return "vector3"; + elseif(a._type ~= nil and a._type == "mat3") then + return "mat3"; + else + error("Calculation cannot be performed on an object of this type.", 2); + end +end + +mat3_mt.__newindex = function(obj,key,val) + if(key == "det") then + error("Cannot set the determinant of a matrix.",2) + elseif(key == "trace") then + error("Cannot set the trace of a matrix.",2) + elseif(key == "inverse") then + error("Cannot set the inverse of a matrix.",2) + elseif(key == "transpose") then + error("Cannot set the transpose of a matrix.",2) + elseif(key == "_type") then + error("Cannot set the type of an object.",2) + else + error("Field "..key.." does not exist in the mat3 data structure.",2); + end +end +mat3_mt.__add = function(a,b) + local ta = mat3_mt.typecheck(a,false); + local tb = mat3_mt.typecheck(b,false); + if(ta == "number") then + if(tb == "number") then + return a+b; + else + local t = vectr.mat3(b); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]+a; + end + end + return t; + end + elseif(tb == "number") then + local t = vectr.mat3(a); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]+b; + end + end + return t; + else + local t = vectr.mat3(a); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]+b[i][j]; + end + end + return t; + end +end +mat3_mt.__sub = function(a,b) + local ta = mat3_mt.typecheck(a,false); + local tb = mat3_mt.typecheck(b,false); + if(ta == "number") then + if(tb == "number") then + return a-b; + else + local t = vectr.mat3(b); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = a-t[i][j]; + end + end + return t; + end + elseif(tb == "number") then + local t = vectr.mat3(a); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]-b; + end + end + return t; + else + local t = vectr.mat3(a); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]-b[i][j]; + end + end + return t; + end +end +mat3_mt.__unm = +function(a) + local t = vectr.mat3(a); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = -t[i][j]; + end + end + return t; +end + +mat3_mt.__mul = function(a,b) + local ta = mat3_mt.typecheck(a,true); + local tb = mat3_mt.typecheck(b,true); + if(ta == "number") then + if(tb == "number" or tb == "vector3") then + return a*b; + else + local t = vectr.mat3(b); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]*a; + end + end + return t; + end + elseif(ta == "vector3") then + if(tb == "mat3") then + error("Invalid matrix multiplication.",2); + else + return a*b; + end + elseif(ta == "mat3") then + if(tb == "number") then + local t = vectr.mat3(a); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]*b; + end + end + return t; + elseif(tb == "vector3") then + local t = {0,0,0}; + local v = {b.x,b.y,b.z}; + for i=1,3,1 do + for j=1,3,1 do + t[i] = t[i] + v[j]*a[i][j]; + end + end + return vectr.v3(t[1],t[2],t[3]) + elseif(b._type == "mat3") then + local t = vectr.mat3({0,0,0},{0,0,0},{0,0,0}) + for i=1,3,1 do + for j=1,3,1 do + for k=1,3,1 do + t[i][j] = t[i][j] + a[i][k]*b[k][j]; + end + end + end + return t; + else + error("Invalid matrix multiplication.",2); + end + else + error("Invalid matrix multiplication.",2); + end +end + +mat3_mt.__div = +function(a,b) + local ta = mat3_mt.typecheck(a,true); + local tb = mat3_mt.typecheck(b,true); + if(tb == "mat3") then + if(ta ~= "vector3") then + return a*b.inverse; + else + error("Invalid matrix operation.",2); + end + elseif(tb == "vector3") then + if(ta == "vector3" or ta == "number") then + return a/b; + else + error("Invalid matrix operation.",2); + end + else + if(ta == "vector3" or ta == "number") then + return a/b; + else + local t = vectr.mat3(a); + for i=1,3,1 do + for j=1,3,1 do + t[i][j] = t[i][j]/b; + end + end + return t; + end + end +end + +mat3_mt.__eq = function(a,b) + for i=1,3,1 do + for j=1,3,1 do + if(a[i][j] ~= b[i][j]) then + return false; + end + end + end + return true; +end +mat3_mt.__tostring = function(obj) return "(("..tostring(obj[1][1])..", "..tostring(obj[1][2])..", "..tostring(obj[1][3]).."), ("..tostring(obj[2][1])..", "..tostring(obj[2][2])..", "..tostring(obj[2][3]).."), ("..tostring(obj[3][1])..", "..tostring(obj[3][2])..", "..tostring(obj[3][3]).."))"; end +mat3_mt.__metatable = mthide; +mat3_mt.__len = function(a) return 3; end + +--CONSTRUCTOR +function vectr.mat3(row1,row2,row3) + if(row1._type ~= nil and row1._type == "mat3") then + row3 = row1[3]; + row2 = row1[2]; + row1 = row1[1]; + elseif(row1._type ~= nil and row1._type ~= "mat3") then + error("Invalid matrix definition - invalid arguments.",2) + elseif(#row1 ~= 3 or row2 == nil or #row2 ~= 3 or row3 == nil or #row3 ~= 3) then + error("Invalid matrix definition - wrong number of matrix elements.",2) + end + local m = {row1,row2,row3} + m.tomat2 = function(a) + return vectr.mat2({a[1][1],a[1][2]},{a[2][1],a[2][2]}); + end + + m.tomat4 = function(a) + return vectr.mat4({a[1][1],a[1][2],a[1][3],0},{a[2][1],a[2][2],a[2][3],0},{a[3][1],a[3][2],a[3][3],0},{0,0,0,1}); + end + + setmetatable(m,mat3_mt) + return m; +end + +end + +do --Matrix 4x4 + +--METATABLE +local mat4_mt = {} +mat4_mt.__index = function(obj,key) + if(key == "det") then + return obj[1][4]*(obj[2][3]*(obj[3][2]*obj[4][1] - obj[3][1]*obj[4][2]) + obj[2][2]*(obj[3][1]*obj[4][3] - obj[3][3]*obj[4][1]) + obj[2][1]*(obj[3][3]*obj[4][2] - obj[3][2]*obj[4][3])) + + obj[1][2]*obj[2][1]*(obj[3][4]*obj[4][3] - obj[3][3]*obj[4][4]) + obj[1][2]*(obj[2][4]*(obj[3][3]*obj[4][1] - obj[3][1]*obj[4][3]) + obj[2][3]*(obj[3][1]*obj[4][4] - obj[3][4]*obj[4][1])) + + obj[1][3]*(obj[2][4]*(obj[3][1]*obj[4][2]-obj[3][2]*obj[4][1]) + obj[2][2]*(obj[3][4]*obj[4][1]-obj[3][1]*obj[4][4]) + obj[2][1]*(obj[3][2]*obj[4][4]-obj[3][4]*obj[4][2])) + + obj[1][1]*(obj[2][4]*(obj[3][2]*obj[4][3]-obj[3][3]*obj[4][2]) + obj[2][3]*(obj[3][4]*obj[4][2]-obj[3][2]*obj[4][4]) + obj[2][2]*(obj[3][3]*obj[4][4]-obj[3][4]*obj[4][3])) + elseif(key == "trace") then + return trace(obj,4); + elseif(key == "inverse") then + return (1/obj.det)*vectr.mat4({-obj[4][2]*(obj[2][4]*obj[3][3]-obj[2][3]*obj[3][4]) + obj[4][3]*(obj[2][4]*obj[3][2] - obj[2][2]*obj[3][4]) - obj[4][4]*(obj[2][3]*obj[3][2] - obj[2][2]*obj[3][3]), + obj[4][2]*(obj[1][4]*obj[3][3]-obj[1][3]*obj[3][4]) - obj[4][3]*(obj[1][4]*obj[3][2] - obj[1][2]*obj[3][4]) + obj[4][4]*(obj[1][3]*obj[3][2] - obj[1][2]*obj[3][3]), + -obj[4][2]*(obj[1][4]*obj[2][3]-obj[1][3]*obj[2][4]) + obj[4][3]*(obj[1][4]*obj[2][2] - obj[1][2]*obj[2][4]) - obj[4][4]*(obj[1][3]*obj[2][2] - obj[1][2]*obj[2][3]), + obj[3][2]*(obj[1][4]*obj[2][3]-obj[1][3]*obj[2][4]) - obj[3][3]*(obj[1][4]*obj[2][2] - obj[1][2]*obj[2][4]) + obj[3][4]*(obj[1][3]*obj[2][2] - obj[1][2]*obj[2][3])}, + + { obj[4][1]*(obj[2][4]*obj[3][3]-obj[2][3]*obj[3][4]) - obj[4][3]*(obj[2][4]*obj[3][1] - obj[2][1]*obj[3][4]) + obj[4][4]*(obj[2][3]*obj[3][1] - obj[2][1]*obj[3][3]), + -obj[4][1]*(obj[1][4]*obj[3][3]-obj[1][3]*obj[3][4]) + obj[4][3]*(obj[1][4]*obj[3][1] - obj[1][1]*obj[3][4]) - obj[4][4]*(obj[1][3]*obj[3][1] - obj[1][1]*obj[3][3]), + obj[4][1]*(obj[1][4]*obj[2][3]-obj[1][3]*obj[2][4]) - obj[4][3]*(obj[1][4]*obj[2][1] - obj[1][1]*obj[2][4]) + obj[4][4]*(obj[1][3]*obj[2][1] - obj[1][1]*obj[2][3]), + -obj[3][1]*(obj[1][4]*obj[2][3]-obj[1][3]*obj[2][4]) + obj[3][3]*(obj[1][4]*obj[2][1] - obj[1][1]*obj[2][4]) - obj[3][4]*(obj[1][3]*obj[2][1] - obj[1][1]*obj[2][3])}, + + {-obj[4][1]*(obj[2][4]*obj[3][2]-obj[2][2]*obj[3][4]) + obj[4][2]*(obj[2][4]*obj[3][1] - obj[2][1]*obj[3][4]) - obj[4][4]*(obj[2][2]*obj[3][1] - obj[2][1]*obj[3][2]), + obj[4][1]*(obj[1][4]*obj[3][2]-obj[1][2]*obj[3][4]) - obj[4][2]*(obj[1][4]*obj[3][1] - obj[1][1]*obj[3][4]) + obj[4][4]*(obj[1][2]*obj[3][1] - obj[1][1]*obj[3][2]), + -obj[4][1]*(obj[1][4]*obj[2][2]-obj[1][2]*obj[2][4]) + obj[4][2]*(obj[1][4]*obj[2][1] - obj[1][1]*obj[2][4]) - obj[4][4]*(obj[1][2]*obj[2][1] - obj[1][1]*obj[2][2]), + obj[3][1]*(obj[1][4]*obj[2][2]-obj[1][2]*obj[2][4]) - obj[3][2]*(obj[1][4]*obj[2][1] - obj[1][1]*obj[2][4]) + obj[3][4]*(obj[1][2]*obj[2][1] - obj[1][1]*obj[2][2])}, + + { obj[4][1]*(obj[2][3]*obj[3][2]-obj[2][2]*obj[3][3]) - obj[4][2]*(obj[2][3]*obj[3][1] - obj[2][1]*obj[3][3]) + obj[4][3]*(obj[2][2]*obj[3][1] - obj[2][1]*obj[3][2]), + -obj[4][1]*(obj[1][3]*obj[3][2]-obj[1][2]*obj[3][3]) + obj[4][2]*(obj[1][3]*obj[3][1] - obj[1][1]*obj[3][3]) - obj[4][3]*(obj[1][2]*obj[3][1] - obj[1][1]*obj[3][2]), + obj[4][1]*(obj[1][3]*obj[2][2]-obj[1][2]*obj[2][3]) - obj[4][2]*(obj[1][3]*obj[2][1] - obj[1][1]*obj[2][3]) + obj[4][3]*(obj[1][2]*obj[2][1] - obj[1][1]*obj[2][2]), + -obj[3][1]*(obj[1][3]*obj[2][2]-obj[1][2]*obj[2][3]) + obj[3][2]*(obj[1][3]*obj[2][1] - obj[1][1]*obj[2][3]) - obj[3][3]*(obj[1][2]*obj[2][1] - obj[1][1]*obj[2][2])}); + elseif(key == "transpose") then + return vectr.mat4({obj[1][1],obj[2][1],obj[3][1],obj[4][1]},{obj[1][2],obj[2][2],obj[3][2],obj[4][2]},{obj[1][3],obj[2][3],obj[3][3],obj[4][3]},{obj[1][4],obj[2][4],obj[3][4],obj[4][4]}); + elseif(key == "_type") then + return "mat4"; + else + return nil; + end +end + +function mat4_mt.typecheck(a,b) + if(type(a) == "number") then + return "number"; + elseif(b and a._type ~= nil and a._type == "vector4") then + return "vector4"; + elseif(a._type ~= nil and a._type == "mat4") then + return "mat4"; + else + error("Calculation cannot be performed on an object of this type.", 2); + end +end + +mat4_mt.__newindex = function(obj,key,val) + if(key == "det") then + error("Cannot set the determinant of a matrix.",2) + elseif(key == "trace") then + error("Cannot set the trace of a matrix.",2) + elseif(key == "inverse") then + error("Cannot set the inverse of a matrix.",2) + elseif(key == "transpose") then + error("Cannot set the transpose of a matrix.",2) + elseif(key == "_type") then + error("Cannot set the type of an object.",2) + else + error("Field "..key.." does not exist in the mat4 data structure.",2); + end +end +mat4_mt.__add = function(a,b) + local ta = mat4_mt.typecheck(a,false); + local tb = mat4_mt.typecheck(b,false); + if(ta == "number") then + if(tb == "number") then + return a+b; + else + local t = vectr.mat4(b); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]+a; + end + end + return t; + end + elseif(tb == "number") then + local t = vectr.mat4(a); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]+b; + end + end + return t; + else + local t = vectr.mat4(a); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]+b[i][j]; + end + end + return t; + end +end + +mat4_mt.__sub = function(a,b) + local ta = mat4_mt.typecheck(a,false); + local tb = mat4_mt.typecheck(b,false); + if(ta == "number") then + if(tb == "number") then + return a-b; + else + local t = vectr.mat4(b); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = a-t[i][j]; + end + end + return t; + end + elseif(tb == "number") then + local t = vectr.mat4(a); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]-b; + end + end + return t; + else + local t = vectr.mat4(a); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]-b[i][j]; + end + end + return t; + end +end + +mat4_mt.__unm = function(a) + local t = vectr.mat4(a); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = -t[i][j]; + end + end + return t; +end + +mat4_mt.__mul = +function(a,b) + local ta = mat4_mt.typecheck(a,true); + local tb = mat4_mt.typecheck(b,true); + if(ta == "number") then + if(tb == "number" or tb == "vector4") then + return a*b; + else + local t = vectr.mat4(b); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]*a; + end + end + return t; + end + elseif(ta == "vector4") then + if(tb == "mat4") then + error("Invalid matrix multiplication.",2); + else + return a*b; + end + elseif(ta == "mat4") then + if(tb == "number") then + local t = vectr.mat4(a); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]*b; + end + end + return t; + elseif(tb == "vector4") then + local t = {0,0,0,0}; + local v = {b.x,b.y,b.z,b.w}; + for i=1,4,1 do + for j=1,4,1 do + t[i] = t[i] + v[j]*a[i][j]; + end + end + return vectr.v4(t[1],t[2],t[3],t[4]) + elseif(b._type == "mat4") then + local t = vectr.mat4({0,0,0,0},{0,0,0,0},{0,0,0,0}) + for i=1,4,1 do + for j=1,4,1 do + for k=1,4,1 do + t[i][j] = t[i][j] + a[i][k]*b[k][j]; + end + end + end + return t; + else + error("Invalid matrix multiplication.",2); + end + else + error("Invalid matrix multiplication.",2); + end +end + +mat4_mt.__div = +function(a,b) + local ta = mat4_mt.typecheck(a,true); + local tb = mat4_mt.typecheck(b,true); + if(tb == "mat4") then + if(ta ~= "vector4") then + return a*b.inverse; + else + error("Invalid matrix operation.",2); + end + elseif(tb == "vector4") then + if(ta == "vector4" or ta == "number") then + return a/b; + else + error("Invalid matrix operation.",2); + end + else + if(ta == "vector4" or ta == "number") then + return a/b; + else + local t = vectr.mat4(a); + for i=1,4,1 do + for j=1,4,1 do + t[i][j] = t[i][j]/b; + end + end + return t; + end + end +end + +mat4_mt.__eq = function(a,b) + for i=1,4,1 do + for j=1,4,1 do + if(a[i][j] ~= b[i][j]) then + return false; + end + end + end + return true; +end +mat4_mt.__tostring = function(obj) return "(("..tostring(obj[1][1])..", "..tostring(obj[1][2])..", "..tostring(obj[1][3])..", "..tostring(obj[1][4]).."), (".. + tostring(obj[2][1])..", "..tostring(obj[2][2])..", "..tostring(obj[2][3])..", "..tostring(obj[2][4]).."), (".. + tostring(obj[3][1])..", "..tostring(obj[3][2])..", "..tostring(obj[3][3])..", "..tostring(obj[3][4]).."), (".. + tostring(obj[4][1])..", "..tostring(obj[4][2])..", "..tostring(obj[4][3])..", "..tostring(obj[4][4]).."))"; end +mat4_mt.__metatable = mthide; +mat4_mt.__len = function(a) return 3; end + +--CONSTRUCTOR +function vectr.mat4(row1,row2,row3, row4) + if(row1._type ~= nil and row1._type == "mat4") then + row4 = row1[4] + row3 = row1[3]; + row2 = row1[2]; + row1 = row1[1]; + elseif(row1._type ~= nil and row1._type ~= "mat4") then + error("Invalid matrix definition - invalid arguments.",2) + elseif(#row1 ~= 4 or row2 == nil or #row2 ~= 4 or row3 == nil or #row3 ~= 4 or row4 == nil or #row4 ~= 4) then + error("Invalid matrix definition - wrong number of matrix elements.",2) + end + local m = {row1,row2,row3,row4} + m.tomat2 = function(a) + return vectr.mat2({a[1][1],a[1][2]},{a[2][1],a[2][2]}); + end + + m.tomat3 = function(a) + return vectr.mat3({a[1][1],a[1][2],a[1][3]},{a[2][1],a[2][2],a[2][3]},{a[3][1],a[3][2],a[3][3]}); + end + + setmetatable(m,mat4_mt) + return m; +end + +end + +end + +function vectr.lerp(a,b,t) + return b*t + a*(1-t); +end + +local function viter(state,n) + if(string.sub(state._type,1,6) == "vector") then + if(n == 0) then + n = "x" + elseif(n == "x") then + n = "y"; + elseif(n == "y") then + n = "z" + elseif(n == "z") then + n = "w" + elseif(n == "w") then + n = nil; + end + if(state[n] ~= nil) then + return n,state[n]; + end + elseif(string.sub(state._type,1,3) == "mat") then + if(n == 0) then + n = {1,1}; + elseif(n[2] < #state) then + n[2] = n[2] + 1; + elseif(n[1] < #state) then + n[1] = n[1] + 1; + n[2] = 1; + else + n = nil; + end + if(n ~= nil) then + return n,state[n[1]][n[2]]; + end + end +end + +function vectr.pairs(a) + return viter,a,0; +end + +local g_mt = {}; +function g_mt.__index(obj,key) + if(key == "zero2") then + return vectr.v2(0,0); + elseif(key == "up2") then + return vectr.v2(0,1); + elseif(key == "right2") then + return vectr.v2(1,0); + elseif(key == "zero3") then + return vectr.v3(0,0,0); + elseif(key == "forward3") then + return vectr.v3(0,0,1); + elseif(key == "up3") then + return vectr.v3(0,1,0); + elseif(key == "right3") then + return vectr.v3(1,0,0); + elseif(key == "zero4") then + return vectr.v4(0,0,0,0); + elseif(key == "w4") then + return vectr.v4(0,0,0,1); + elseif(key == "forward4") then + return vectr.v4(0,0,1,0); + elseif(key == "up4") then + return vectr.v4(0,1,0,0); + elseif(key == "right4") then + return vectr.v4(1,0,0,0); + elseif(key == "empty2") then + return vectr.mat2({0,0},{0,0}); + elseif(key == "id2") then + return vectr.mat2({1,0},{0,1}); + elseif(key == "empty3") then + return vectr.mat3({0,0,0},{0,0,0},{0,0,0}); + elseif(key == "id3") then + return vectr.mat3({1,0,0},{0,1,0},{0,0,1}); + elseif(key == "empty4") then + return vectr.mat4({0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}); + elseif(key == "id4") then + return vectr.mat4({1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}); + elseif(key == "_ver") then + return version; + end +end + +function g_mt.__newindex(obj,key,val) + error("Cannot access a read-only object.",2) +end + +setmetatable(vectr,g_mt); + +return vectr; \ No newline at end of file