From 580c5baeb3af125371de53fb35592d92a97a7d17 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 16 Mar 2022 22:55:16 -0700 Subject: [PATCH] Add custom box model example --- .../custom_box/custom_box_surface.rgba16.png | Bin 0 -> 538 bytes .../actors/custom_box/geo.inc.c | 15 +++ .../actors/custom_box/model.inc.c | 97 ++++++++++++++++++ .../actors/custom_box_geo.bin | Bin 0 -> 1991 bytes docs/lua/examples/custom-box-model/main.lua | 24 +++++ docs/lua/lua.md | 3 +- 6 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 docs/lua/examples/custom-box-model/actors/custom_box/custom_box_surface.rgba16.png create mode 100644 docs/lua/examples/custom-box-model/actors/custom_box/geo.inc.c create mode 100644 docs/lua/examples/custom-box-model/actors/custom_box/model.inc.c create mode 100644 docs/lua/examples/custom-box-model/actors/custom_box_geo.bin create mode 100644 docs/lua/examples/custom-box-model/main.lua diff --git a/docs/lua/examples/custom-box-model/actors/custom_box/custom_box_surface.rgba16.png b/docs/lua/examples/custom-box-model/actors/custom_box/custom_box_surface.rgba16.png new file mode 100644 index 0000000000000000000000000000000000000000..6c14136b02ec754aed90f3bf79fb7718cff9aa15 GIT binary patch literal 538 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=hEVFy>`CI|pPYCo?c;Oe~#f?ak~c z(rQ1sUWTs!kC#df zeR(t1*-Cc1{w&{f|H6`2r4e6$)!(1L*miEAZ$_4=oN?}Q9UDcNSk2pA<}KA{=1dg3 zCw@)Va>0kzOTndeA#>J#UY(>aIG<_$tCgws1+Um=TP|0yQIXMlqW$c90ZagoGdbN0`}Wu$@U; zada`C1TUl5oX&uzQ!^j4Du=ChTby9R;^vG_9B^j160o@FasQTe=Nj4%tYCI?W?*

@|AFBCO^C3- zS0K&K#K3SJBno7|0E-I-ERLtq!mDzgAGU)S5pa>Rxu^9 zXqSyQ8Zq6$N{k%F!U2s0r{8uYe>kD47&$e8yV51_V^+fyG_sT22Rz^p6My{+i`d!#*?90+C zB0BA4u$sB^*^bXi4C6d5Rmg{7X2kcN=K@ZuXx4QzC;slXvD% zU<7a$ctjR6FmMZjFyp1Wb$@_@L7py-ArbD$DG3Qb_>VBN&0sr|w&LhwJ_%k%u{oUq zO{Zo)W>pSb?Y20&`W_A6UWc=FGtGUWmp1E9W&;py>>r zu6{1-oD!NC<&jbhIBDi&re~BCgOjJBqlJOJy*&d6gHj&|YiMYI^fNGHXe>)D0wy^~ zx^}cQ;0G$215B|X{D7H(p^<^%KZui>h(!qhV`fcOyg zAoD={Isak$A$*Wpn0-JC;rcCtGQ?? z4HOV8Obl#Xz~YRDi;Yc4fR8~$h>uN5LX1I1N{kgGFSdaQvw#r11JY8g~6pYFgyIQsr(0|{sT*E1(4SJAOd%QxfmHhO}Yp2818^|u>cvwz##A! zqz+4|4v}Vf2BkkUFfswF0Y(DG8bkbt(_R-7i$UN%Rz9RMDLpkGl*SYozA&-?X)y*a uhAj*q7(i@31||l#P(No-Ndw}G0uvbCUGOu)ep3JMqorCk87FMG8B literal 0 HcmV?d00001 diff --git a/docs/lua/examples/custom-box-model/main.lua b/docs/lua/examples/custom-box-model/main.lua new file mode 100644 index 00000000..050436c1 --- /dev/null +++ b/docs/lua/examples/custom-box-model/main.lua @@ -0,0 +1,24 @@ +-- name: Custom Box Model +-- description: Press DPAD+down to spawn a box + +E_MODEL_CUSTOM_BOX = smlua_model_util_get_id("custom_box_geo") + +function mario_update_local(m) + if (m.controller.buttonPressed & D_JPAD) ~= 0 then + print('spawning box: ', id_bhvBreakableBox, E_MODEL_CUSTOM_BOX) + -- spawn breakable box + spawn_sync_object( + id_bhvBreakableBoxSmall, + E_MODEL_CUSTOM_BOX, + m.pos.x, m.pos.y, m.pos.z, + nil) + end +end + +function mario_update(m) + if m.playerIndex == 0 then + mario_update_local(m) + end +end + +hook_event(HOOK_MARIO_UPDATE, mario_update) diff --git a/docs/lua/lua.md b/docs/lua/lua.md index b2f2b8b0..de8b8bf7 100644 --- a/docs/lua/lua.md +++ b/docs/lua/lua.md @@ -15,7 +15,7 @@ Lua scripts you make can be placed either the `mods` folder in the base director - When developing Lua mods, run the game from a console. Lua errors and logs will appear there. - You can use the `print()` command when debugging. Your logs will show up in the console. - [Setting up Visual Studio Code](vs-code-setup.md) will give you autocomplete and other nice things. - +- You can create a folder within the mods folder containing multiple lua scripts as long as one script is called `main.lua`. Dynos actors can be placed inside this mod folder under `/actors/`.
## Sections @@ -54,3 +54,4 @@ All of this is a holdover from when there were only two players. It was a reason - [Replace Goomba Behavior](examples/behavior-replace-goomba.lua) - [Add to Goomba Behavior](examples/behavior-add-to-goomba.lua) - [Behavior with Surface Collisions](examples/behavior-surface-collisions.lua) +- [Custom Box Model](examples/custom-box-model)