Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -261,10 +261,7 @@ def get_user_input(config):
|
|
| 261 |
|
| 262 |
custom_prompt_enabled = checkbox_with_default("Enable Custom Prompt", False, "custom_prompt_enabled")
|
| 263 |
|
| 264 |
-
|
| 265 |
-
custom_prompt = st.text_area("Enter Custom Prompt", key="custom_prompt")
|
| 266 |
-
else:
|
| 267 |
-
custom_prompt = None
|
| 268 |
|
| 269 |
return {
|
| 270 |
"color": color, "size": size, "position": position, "shape": shape, "material": material,
|
|
@@ -286,79 +283,8 @@ def get_user_input(config):
|
|
| 286 |
|
| 287 |
def generate_lua_script(params, api_key):
|
| 288 |
client = Groq(api_key=api_key)
|
| 289 |
-
prompt = params["custom_prompt"]
|
| 290 |
|
| 291 |
-
if params["color"]:
|
| 292 |
-
prompt += f"1. Creates a {params['shape']} with the specified color {params['color']}.\n"
|
| 293 |
-
if params["size"]:
|
| 294 |
-
prompt += f"2. Specifies the size {params['size']}.\n"
|
| 295 |
-
if params["position"]:
|
| 296 |
-
prompt += f"3. Positions it at {params['position']}.\n"
|
| 297 |
-
if params["part_cframe"]:
|
| 298 |
-
prompt += f"4. Sets its CFrame to {params['part_cframe']}.\n"
|
| 299 |
-
if params["material"]:
|
| 300 |
-
prompt += f"5. Sets the material to {params['material']}.\n"
|
| 301 |
-
if params["transparency"]:
|
| 302 |
-
prompt += f"6. Sets the transparency to {params['transparency']}.\n"
|
| 303 |
-
if params["reflectance"]:
|
| 304 |
-
prompt += f"7. Sets the reflectance to {params['reflectance']}.\n"
|
| 305 |
-
if params["rotation_speed"]:
|
| 306 |
-
prompt += f"8. Rotates the {params['shape']} at a speed of {params['rotation_speed']}.\n"
|
| 307 |
-
if params["bounce_height"]:
|
| 308 |
-
prompt += f"9. Sets the bounce height to {params['bounce_height']}.\n"
|
| 309 |
-
if params["collision"]:
|
| 310 |
-
prompt += f"10. Sets collision to {params['collision']}.\n"
|
| 311 |
-
if params["surface"]:
|
| 312 |
-
prompt += f"11. Sets the surface type to {params['surface']}.\n"
|
| 313 |
-
if params["anchor"]:
|
| 314 |
-
prompt += f"12. Sets anchor to {params['anchor']}.\n"
|
| 315 |
-
if params["collision_group"]:
|
| 316 |
-
prompt += f"13. Sets the collision group to {params['collision_group']}.\n"
|
| 317 |
-
if params["angular_velocity"] and params["linear_velocity"]:
|
| 318 |
-
prompt += f"14. Sets the angular velocity to {params['angular_velocity']} and linear velocity to {params['linear_velocity']}.\n"
|
| 319 |
-
if params["density"]:
|
| 320 |
-
prompt += f"15. Sets the density to {params['density']}.\n"
|
| 321 |
-
if params["camera_type"]:
|
| 322 |
-
prompt += f"16. Sets the camera type to {params['camera_type']}.\n"
|
| 323 |
-
if params["camera_position"]:
|
| 324 |
-
prompt += f"17. Sets the camera position to {params['camera_position']}.\n"
|
| 325 |
-
if params["field_of_view"]:
|
| 326 |
-
prompt += f"18. Sets the field of view to {params['field_of_view']}.\n"
|
| 327 |
-
if params["camera_interpolation"]:
|
| 328 |
-
prompt += f"19. Enables camera interpolation.\n"
|
| 329 |
-
if params["ambient_light"]:
|
| 330 |
-
prompt += f"20. Sets the ambient light to {params['ambient_light']}.\n"
|
| 331 |
-
if params["brightness"]:
|
| 332 |
-
prompt += f"21. Sets the brightness to {params['brightness']}.\n"
|
| 333 |
-
if params["time_of_day"]:
|
| 334 |
-
prompt += f"22. Sets the time of day to {params['time_of_day']}.\n"
|
| 335 |
-
if params["shadow_softness"]:
|
| 336 |
-
prompt += f"23. Sets the shadow softness to {params['shadow_softness']}.\n"
|
| 337 |
-
if params["shadow_color"]:
|
| 338 |
-
prompt += f"24. Sets the shadow color to {params['shadow_color']}.\n"
|
| 339 |
-
if params["fog_start"] and params["fog_end"] and params["fog_color"]:
|
| 340 |
-
prompt += f"25. Sets fog with start distance {params['fog_start']}, end distance {params['fog_end']}, and color {params['fog_color']}.\n"
|
| 341 |
-
if params["walk_speed"]:
|
| 342 |
-
prompt += f"26. Sets the player's walk speed to {params['walk_speed']}.\n"
|
| 343 |
-
if params["jump_power"]:
|
| 344 |
-
prompt += f"27. Sets the player's jump power to {params['jump_power']}.\n"
|
| 345 |
-
if params["health"]:
|
| 346 |
-
prompt += f"28. Sets the player's health to {params['health']}.\n"
|
| 347 |
-
if params["respawn_time"]:
|
| 348 |
-
prompt += f"29. Sets the respawn time to {params['respawn_time']}.\n"
|
| 349 |
-
if params["background_music"]:
|
| 350 |
-
prompt += f"30. Adds background music with ID {params['background_music']} and sets volume to {params['sound_volume']}.\n"
|
| 351 |
-
if params["sound_effects"]:
|
| 352 |
-
prompt += f"31. Adds sound effects with ID {params['sound_effects']}.\n"
|
| 353 |
-
if params["environmental_sounds"]:
|
| 354 |
-
prompt += f"32. Adds environmental sounds with ID {params['environmental_sounds']}.\n"
|
| 355 |
-
if params["ui_text"]:
|
| 356 |
-
prompt += f"33. Adds UI text '{params['ui_text']}' at position {params['ui_position']} with size {params['ui_size']} and color {params['ui_color']} using font {params['ui_font']} and text size {params['ui_text_size']}.\n"
|
| 357 |
-
if params["texture_id"] and params["decal_position"]:
|
| 358 |
-
prompt += f"34. Adds a decal with texture ID {params['texture_id']} at position {params['decal_position']}.\n"
|
| 359 |
-
if params["particle_texture"]:
|
| 360 |
-
prompt += f"35. Adds particle effects with texture ID {params['particle_texture']}, lifetime {params['particle_lifetime']}, rate {params['particle_rate']}, speed {params['particle_speed']}, size {params['particle_size']}, acceleration {params['particle_acceleration']}, rotation speed {params['particle_rot_speed']}, and color {params['particle_color']}.\n"
|
| 361 |
-
|
| 362 |
completion = client.chat.completions.create(
|
| 363 |
model="llama3-8b-8192",
|
| 364 |
messages=[
|
|
@@ -388,6 +314,7 @@ def main():
|
|
| 388 |
api_key = config["api_key"]
|
| 389 |
lua_script = generate_lua_script(user_input, api_key)
|
| 390 |
st.code(lua_script, language='lua')
|
|
|
|
| 391 |
|
| 392 |
if __name__ == "__main__":
|
| 393 |
main()
|
|
|
|
| 261 |
|
| 262 |
custom_prompt_enabled = checkbox_with_default("Enable Custom Prompt", False, "custom_prompt_enabled")
|
| 263 |
|
| 264 |
+
custom_prompt = st.text_area("Enter Custom Prompt", "Create a Lua script for Roblox:", key="custom_prompt")
|
|
|
|
|
|
|
|
|
|
| 265 |
|
| 266 |
return {
|
| 267 |
"color": color, "size": size, "position": position, "shape": shape, "material": material,
|
|
|
|
| 283 |
|
| 284 |
def generate_lua_script(params, api_key):
|
| 285 |
client = Groq(api_key=api_key)
|
| 286 |
+
prompt = params["custom_prompt"]
|
| 287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
completion = client.chat.completions.create(
|
| 289 |
model="llama3-8b-8192",
|
| 290 |
messages=[
|
|
|
|
| 314 |
api_key = config["api_key"]
|
| 315 |
lua_script = generate_lua_script(user_input, api_key)
|
| 316 |
st.code(lua_script, language='lua')
|
| 317 |
+
st.download_button(label="Copy to Clipboard", data=lua_script, file_name="lua_script.txt", mime="text/plain")
|
| 318 |
|
| 319 |
if __name__ == "__main__":
|
| 320 |
main()
|