1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
# Embedding main.lua into Executable
When you're ready to ship your game, you can embed all Lua files and asset files directly into the executable.
## Development vs Release Workflow
### 🔧 Development Build (Fast Iteration)
During development, use external files for quick iteration:
**Setup:**
```
GameFolder/
├── ReiLua.exe
├── main.lua
├── player.lua
└── assets/
├── player.png
└── music.wav
```
**Build:**
```bash
cd build
cmake ..
cmake --build .
```
**Benefits:**
- ✅ Edit Lua files and re-run immediately
- ✅ Edit assets and reload
- ✅ Fast development cycle
- ✅ Debug with `--log` flag
### 📦 Release Build (Single Executable)
For distribution, embed everything into one file:
**Setup:**
```bash
cd build
# Copy Lua files to build directory
copy ..\main.lua .
copy ..\player.lua .
# Create assets folder and copy files
mkdir assets
copy ..\player.png assets\
copy ..\music.wav assets\
```
**Build:**
```bash
# Configure with embedding
cmake .. -DEMBED_MAIN=ON -DEMBED_ASSETS=ON
# Build release
cmake --build . --config Release
```
**Result:**
```
Distribution/
└── YourGame.exe (Everything embedded!)
```
**Benefits:**
- ✅ Single executable file
- ✅ No external dependencies
- ✅ Users can't modify game files
- ✅ Smaller download (no separate files)
## Quick Start
### Embedding Lua Files
1. **Copy your Lua files to the build directory**:
```bash
copy main.lua build\main.lua
copy player.lua build\player.lua
```
2. **Build with EMBED_MAIN option**:
```bash
cd build
cmake .. -DEMBED_MAIN=ON
cmake --build . --config Release
```
## Command Line Options
ReiLua supports several command-line options:
```bash
ReiLua [Options] [Directory to main.lua or main]
Options:
-h, --help Show help message
-v, --version Show ReiLua version
-i, --interpret Interpret mode [File name]
--log Show console window for logging (Windows only)
```
### Console/Logging
By default, ReiLua runs **without a console window** for a clean user experience. To enable console output for debugging:
```bash
# Run with console for debugging
ReiLua.exe --log
# You can also combine with other options
ReiLua.exe --log path/to/game
# Or with interpret mode
ReiLua.exe --log -i script.lua
```
This is useful during development to see:
- TraceLog output
- Print statements
- Lua errors
- Debug information
## Complete Release Workflow
Here's a complete step-by-step guide to prepare your game for release:
### Step 1: Organize Your Project
Ensure your project has this structure:
```
MyGame/
├── main.lua
├── player.lua
├── enemy.lua
├── player.png
├── enemy.png
├── music.wav
└── icon.ico (optional)
```
### Step 2: Customize Branding (Optional)
**Change executable icon:**
```bash
# Replace ReiLua's icon with yours
copy MyGame\icon.ico ReiLua\icon.ico
```
**Edit executable properties:**
Open `ReiLua\resources.rc` and modify:
```rc
VALUE "CompanyName", "Your Studio Name"
VALUE "FileDescription", "Your Game Description"
VALUE "ProductName", "Your Game Name"
VALUE "LegalCopyright", "Copyright (C) Your Name, 2025"
```
**Change executable name:**
Edit `ReiLua\CMakeLists.txt`:
```cmake
project( YourGameName ) # Change from "ReiLua"
```
See [CUSTOMIZATION.md](CUSTOMIZATION.md) for full details.
### Important: Asset Paths
**Keep your paths consistent!** The embedding system now preserves the `assets/` prefix, so use the same paths in both development and release:
```lua
-- ✅ Correct - works in both dev and release
playerImage = RL.LoadTexture("assets/player.png")
backgroundImg = RL.LoadTexture("assets/background.png")
musicSound = RL.LoadSound("assets/music.wav")
```
Your Lua code doesn't need to change between development and release builds!
### Step 3: Prepare Build Directory
```bash
cd ReiLua\build
# Copy all Lua files
copy ..\MyGame\*.lua .
# Create assets folder
mkdir assets
# Copy all asset files (images, sounds, etc.)
copy ..\MyGame\*.png assets\
copy ..\MyGame\*.wav assets\
copy ..\MyGame\*.ogg assets\
# Or copy entire folders
xcopy /E /I ..\MyGame\images assets\images
xcopy /E /I ..\MyGame\sounds assets\sounds
```
### Step 4: Build Release
```bash
# Configure with embedding enabled
cmake .. -DEMBED_MAIN=ON -DEMBED_ASSETS=ON
# Build in release mode
cmake --build . --config Release
```
### Step 5: Test Release Build
```bash
# Test with console to verify everything loaded
YourGameName.exe --log
# Test production mode (no console)
YourGameName.exe
```
Check console output for:
- ✅ "ReiLua x.x.x" version info
- ✅ No file loading errors
- ✅ Game runs correctly
### Step 6: Package for Distribution
```bash
# Create distribution folder
mkdir ..\Distribution
copy YourGameName.exe ..\Distribution\
# Optional: Add README, LICENSE, etc.
copy ..\README.txt ..\Distribution\
```
Your game is now ready to distribute as a single executable!
### Workflow Summary
| Stage | Build Command | Files Needed | Result |
|-------|--------------|--------------|--------|
| **Development** | `cmake .. && cmake --build .` | Lua + assets external | Fast iteration |
| **Testing** | `cmake .. -DEMBED_MAIN=ON && cmake --build .` | Lua in build/ | Test embedding |
| **Release** | `cmake .. -DEMBED_MAIN=ON -DEMBED_ASSETS=ON && cmake --build . --config Release` | Lua + assets in build/ | Single .exe |
### Troubleshooting
**Problem: "No .lua files found in build directory"**
```bash
# Solution: Copy Lua files to build directory
copy ..\*.lua .
```
**Problem: "No files found in assets folder"**
```bash
# Solution: Create assets folder and copy files
mkdir assets
copy ..\*.png assets\
```
**Problem: Game crashes on startup**
```bash
# Solution: Run with --log to see error messages
YourGameName.exe --log
```
**Problem: Assets not loading**
- Verify assets are in `build/assets/` before building
- Check asset filenames match in your Lua code
- Use `--log` to see loading errors
### Notes
- `.lua` files in the **build directory root** are embedded when using `EMBED_MAIN=ON`
- Asset files in **build/assets/** folder (and subfolders) are embedded when using `EMBED_ASSETS=ON`
- `main.lua` must exist and is always the entry point
- Asset embedding works with subdirectories: `assets/images/player.png` → Load with `LoadImage("player.png")`
- Both Lua and asset embedding can be used independently or together
- The system falls back to file system if embedded file is not found
- No code changes needed - all raylib functions work automatically with embedded assets
## Customizing Your Executable
Want to add your own icon and version info to the executable? See [CUSTOMIZATION.md](CUSTOMIZATION.md) for details on:
- Adding a custom icon
- Setting exe properties (company name, version, description)
- Renaming the executable
|