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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import json
|
| 3 |
+
from groq import Groq
|
| 4 |
+
|
| 5 |
+
def load_config():
|
| 6 |
+
with open('config.json', 'r') as f:
|
| 7 |
+
return json.load(f)
|
| 8 |
+
|
| 9 |
+
def get_user_input(config):
|
| 10 |
+
st.title("Advanced Roblox Lua Script Generator")
|
| 11 |
+
|
| 12 |
+
def checkbox_with_default(label, value):
|
| 13 |
+
return st.checkbox(label, value=value)
|
| 14 |
+
|
| 15 |
+
def text_input_with_default(label, value):
|
| 16 |
+
return st.text_input(label, value)
|
| 17 |
+
|
| 18 |
+
def selectbox_with_default(label, options, value):
|
| 19 |
+
return st.selectbox(label, options, index=options.index(value))
|
| 20 |
+
|
| 21 |
+
default_params = config["default_parameters"]
|
| 22 |
+
|
| 23 |
+
# Game Object Properties
|
| 24 |
+
color_enabled = checkbox_with_default("Enable Color", True)
|
| 25 |
+
size_enabled = checkbox_with_default("Enable Size", True)
|
| 26 |
+
position_enabled = checkbox_with_default("Enable Position", True)
|
| 27 |
+
shape_enabled = checkbox_with_default("Enable Shape", True)
|
| 28 |
+
material_enabled = checkbox_with_default("Enable Material", True)
|
| 29 |
+
transparency_enabled = checkbox_with_default("Enable Transparency", True)
|
| 30 |
+
reflectance_enabled = checkbox_with_default("Enable Reflectance", True)
|
| 31 |
+
rotation_speed_enabled = checkbox_with_default("Enable Rotation Speed", True)
|
| 32 |
+
bounce_height_enabled = checkbox_with_default("Enable Bounce Height", True)
|
| 33 |
+
collision_enabled = checkbox_with_default("Enable Collision", True)
|
| 34 |
+
surface_enabled = checkbox_with_default("Enable Surface Type", True)
|
| 35 |
+
anchor_enabled = checkbox_with_default("Enable Anchor", True)
|
| 36 |
+
collision_group_enabled = checkbox_with_default("Enable Collision Group", True)
|
| 37 |
+
custom_physics_enabled = checkbox_with_default("Enable Custom Physics", True)
|
| 38 |
+
part_cframe_enabled = checkbox_with_default("Enable Part CFrame", True)
|
| 39 |
+
|
| 40 |
+
# Camera Properties
|
| 41 |
+
camera_enabled = checkbox_with_default("Enable Camera Configuration", True)
|
| 42 |
+
camera_interpolation_enabled = checkbox_with_default("Enable Camera Interpolation", True)
|
| 43 |
+
|
| 44 |
+
# Lighting Properties
|
| 45 |
+
lighting_enabled = checkbox_with_default("Enable Lighting Configuration", True)
|
| 46 |
+
fog_enabled = checkbox_with_default("Enable Environmental Fog", True)
|
| 47 |
+
shadow_enabled = checkbox_with_default("Enable Shadow Properties", True)
|
| 48 |
+
|
| 49 |
+
# Player Properties
|
| 50 |
+
player_settings_enabled = checkbox_with_default("Enable Player Settings", True)
|
| 51 |
+
respawn_time_enabled = checkbox_with_default("Enable Respawn Time", True)
|
| 52 |
+
|
| 53 |
+
# Sound Properties
|
| 54 |
+
sound_enabled = checkbox_with_default("Enable Sound", True)
|
| 55 |
+
sound_effects_enabled = checkbox_with_default("Enable Sound Effects", True)
|
| 56 |
+
environmental_sounds_enabled = checkbox_with_default("Enable Environmental Sounds", True)
|
| 57 |
+
|
| 58 |
+
# UI Properties
|
| 59 |
+
ui_enabled = checkbox_with_default("Enable UI Configuration", True)
|
| 60 |
+
|
| 61 |
+
# Decals
|
| 62 |
+
decals_enabled = checkbox_with_default("Enable Decals", True)
|
| 63 |
+
|
| 64 |
+
# Particle Effects
|
| 65 |
+
particles_enabled = checkbox_with_default("Enable Particle Effects", True)
|
| 66 |
+
|
| 67 |
+
# Advanced Game Object Properties Inputs
|
| 68 |
+
if color_enabled:
|
| 69 |
+
color = text_input_with_default("Enter Color (RGB, e.g., 255,0,0)", default_params["color"])
|
| 70 |
+
else:
|
| 71 |
+
color = None
|
| 72 |
+
|
| 73 |
+
if size_enabled:
|
| 74 |
+
size = text_input_with_default("Enter Size (X,Y,Z, e.g., 4,1,2)", default_params["size"])
|
| 75 |
+
else:
|
| 76 |
+
size = None
|
| 77 |
+
|
| 78 |
+
if position_enabled:
|
| 79 |
+
position = text_input_with_default("Enter Position (X,Y,Z, e.g., 0,10,0)", default_params["position"])
|
| 80 |
+
else:
|
| 81 |
+
position = None
|
| 82 |
+
|
| 83 |
+
if shape_enabled:
|
| 84 |
+
shape = selectbox_with_default("Select Shape", config["shapes"], default_params["shape"])
|
| 85 |
+
else:
|
| 86 |
+
shape = None
|
| 87 |
+
|
| 88 |
+
if material_enabled:
|
| 89 |
+
material = selectbox_with_default("Select Material", config["materials"], default_params["material"])
|
| 90 |
+
else:
|
| 91 |
+
material = None
|
| 92 |
+
|
| 93 |
+
if transparency_enabled:
|
| 94 |
+
transparency = text_input_with_default("Enter Transparency (0-1, e.g., 0.5)", default_params["transparency"])
|
| 95 |
+
else:
|
| 96 |
+
transparency = None
|
| 97 |
+
|
| 98 |
+
if reflectance_enabled:
|
| 99 |
+
reflectance = text_input_with_default("Enter Reflectance (0-1, e.g., 0.5)", default_params["reflectance"])
|
| 100 |
+
else:
|
| 101 |
+
reflectance = None
|
| 102 |
+
|
| 103 |
+
if rotation_speed_enabled:
|
| 104 |
+
rotation_speed = text_input_with_default("Enter Rotation Speed (e.g., 10)", default_params["rotation_speed"])
|
| 105 |
+
else:
|
| 106 |
+
rotation_speed = None
|
| 107 |
+
|
| 108 |
+
if bounce_height_enabled:
|
| 109 |
+
bounce_height = text_input_with_default("Enter Bounce Height (e.g., 10)", default_params["bounce_height"])
|
| 110 |
+
else:
|
| 111 |
+
bounce_height = None
|
| 112 |
+
|
| 113 |
+
if collision_enabled:
|
| 114 |
+
collision = selectbox_with_default("Enable Collision", config["collisions"], default_params["collision"])
|
| 115 |
+
else:
|
| 116 |
+
collision = None
|
| 117 |
+
|
| 118 |
+
if surface_enabled:
|
| 119 |
+
surface = selectbox_with_default("Select Surface Type", config["surfaces"], default_params["surface"])
|
| 120 |
+
else:
|
| 121 |
+
surface = None
|
| 122 |
+
|
| 123 |
+
if anchor_enabled:
|
| 124 |
+
anchor = selectbox_with_default("Enable Anchor", ["true", "false"], default_params["anchor"])
|
| 125 |
+
else:
|
| 126 |
+
anchor = None
|
| 127 |
+
|
| 128 |
+
if collision_group_enabled:
|
| 129 |
+
collision_group = selectbox_with_default("Select Collision Group", config["collision_groups"], default_params["collision_group"])
|
| 130 |
+
else:
|
| 131 |
+
collision_group = None
|
| 132 |
+
|
| 133 |
+
if custom_physics_enabled:
|
| 134 |
+
angular_velocity = text_input_with_default("Enter Angular Velocity (X,Y,Z, e.g., 0,0,0)", default_params["angular_velocity"])
|
| 135 |
+
linear_velocity = text_input_with_default("Enter Linear Velocity (X,Y,Z, e.g., 0,0,0)", default_params["linear_velocity"])
|
| 136 |
+
density = text_input_with_default("Enter Density", default_params["density"])
|
| 137 |
+
else:
|
| 138 |
+
angular_velocity = None
|
| 139 |
+
linear_velocity = None
|
| 140 |
+
density = None
|
| 141 |
+
|
| 142 |
+
if part_cframe_enabled:
|
| 143 |
+
part_cframe = text_input_with_default("Enter Part CFrame (e.g., CFrame.new(0, 50, -100))", default_params["part_cframe"])
|
| 144 |
+
else:
|
| 145 |
+
part_cframe = None
|
| 146 |
+
|
| 147 |
+
# Camera Properties Inputs
|
| 148 |
+
if camera_enabled:
|
| 149 |
+
camera_type = selectbox_with_default("Select Camera Type", config["camera_types"], default_params["camera_type"])
|
| 150 |
+
camera_position = text_input_with_default("Enter Camera Position (X,Y,Z, e.g., 0,50,-100)", default_params["camera_position"])
|
| 151 |
+
field_of_view = text_input_with_default("Enter Field of View", default_params["field_of_view"])
|
| 152 |
+
else:
|
| 153 |
+
camera_type = None
|
| 154 |
+
camera_position = None
|
| 155 |
+
field_of_view = None
|
| 156 |
+
|
| 157 |
+
if camera_interpolation_enabled:
|
| 158 |
+
camera_interpolation = checkbox_with_default("Enable Camera Interpolation", default_params["camera_interpolation"])
|
| 159 |
+
else:
|
| 160 |
+
camera_interpolation = None
|
| 161 |
+
|
| 162 |
+
# Lighting Properties Inputs
|
| 163 |
+
if lighting_enabled:
|
| 164 |
+
ambient_light = text_input_with_default("Enter Ambient Light (RGB, e.g., 128,128,128)", default_params["ambient_light"])
|
| 165 |
+
brightness = text_input_with_default("Enter Brightness", default_params["brightness"])
|
| 166 |
+
time_of_day = selectbox_with_default("Select Time of Day", config["times_of_day"], default_params["time_of_day"])
|
| 167 |
+
shadow_softness = text_input_with_default("Enter Shadow Softness (0-1, e.g., 0.5)", default_params["shadow_softness"])
|
| 168 |
+
shadow_color = text_input_with_default("Enter Shadow Color (RGB, e.g., 0,0,0)", default_params["shadow_color"])
|
| 169 |
+
else:
|
| 170 |
+
ambient_light = None
|
| 171 |
+
brightness = None
|
| 172 |
+
time_of_day = None
|
| 173 |
+
shadow_softness = None
|
| 174 |
+
shadow_color = None
|
| 175 |
+
|
| 176 |
+
if fog_enabled:
|
| 177 |
+
fog_start = text_input_with_default("Enter Fog Start Distance", default_params["fog_start"])
|
| 178 |
+
fog_end = text_input_with_default("Enter Fog End Distance", default_params["fog_end"])
|
| 179 |
+
fog_color = text_input_with_default("Enter Fog Color (RGB, e.g., 128,128,128)", default_params["fog_color"])
|
| 180 |
+
else:
|
| 181 |
+
fog_start = None
|
| 182 |
+
fog_end = None
|
| 183 |
+
fog_color = None
|
| 184 |
+
|
| 185 |
+
# Player Properties Inputs
|
| 186 |
+
if player_settings_enabled:
|
| 187 |
+
walk_speed = text_input_with_default("Enter Walk Speed", default_params["walk_speed"])
|
| 188 |
+
jump_power = text_input_with_default("Enter Jump Power", default_params["jump_power"])
|
| 189 |
+
health = text_input_with_default("Enter Health", default_params["health"])
|
| 190 |
+
else:
|
| 191 |
+
walk_speed = None
|
| 192 |
+
jump_power = None
|
| 193 |
+
health = None
|
| 194 |
+
|
| 195 |
+
if respawn_time_enabled:
|
| 196 |
+
respawn_time = text_input_with_default("Enter Respawn Time", default_params["respawn_time"])
|
| 197 |
+
else:
|
| 198 |
+
respawn_time = None
|
| 199 |
+
|
| 200 |
+
# Sound Properties Inputs
|
| 201 |
+
if sound_enabled:
|
| 202 |
+
background_music = text_input_with_default("Enter Background Music ID (e.g., rbxassetid://123456789)", default_params["background_music"])
|
| 203 |
+
sound_volume = text_input_with_default("Enter Sound Volume (e.g., 1)", default_params["sound_volume"])
|
| 204 |
+
else:
|
| 205 |
+
background_music = None
|
| 206 |
+
sound_volume = None
|
| 207 |
+
|
| 208 |
+
if sound_effects_enabled:
|
| 209 |
+
sound_effects = text_input_with_default("Enter Sound Effects ID (e.g., rbxassetid://987654321)", default_params["sound_effects"])
|
| 210 |
+
else:
|
| 211 |
+
sound_effects = None
|
| 212 |
+
|
| 213 |
+
if environmental_sounds_enabled:
|
| 214 |
+
environmental_sounds = text_input_with_default("Enter Environmental Sounds ID (e.g., rbxassetid://1122334455)", default_params["environmental_sounds"])
|
| 215 |
+
else:
|
| 216 |
+
environmental_sounds = None
|
| 217 |
+
|
| 218 |
+
# UI Properties Inputs
|
| 219 |
+
if ui_enabled:
|
| 220 |
+
ui_text = text_input_with_default("Enter UI Text", default_params["ui_text"])
|
| 221 |
+
ui_position = text_input_with_default("Enter UI Position (X,Y,Z, e.g., 0.5,-100,0.5,-25)", default_params["ui_position"])
|
| 222 |
+
ui_size = text_input_with_default("Enter UI Size (X,Y,Z, e.g., 0,200,0,50)", default_params["ui_size"])
|
| 223 |
+
ui_color = text_input_with_default("Enter UI Color (RGB, e.g., 255,255,255)", default_params["ui_color"])
|
| 224 |
+
ui_font = selectbox_with_default("Select UI Font", config["fonts"], default_params["ui_font"])
|
| 225 |
+
ui_text_size = text_input_with_default("Enter UI Text Size", default_params["ui_text_size"])
|
| 226 |
+
else:
|
| 227 |
+
ui_text = None
|
| 228 |
+
ui_position = None
|
| 229 |
+
ui_size = None
|
| 230 |
+
ui_color = None
|
| 231 |
+
ui_font = None
|
| 232 |
+
ui_text_size = None
|
| 233 |
+
|
| 234 |
+
# Decals Inputs
|
| 235 |
+
if decals_enabled:
|
| 236 |
+
texture_id = text_input_with_default("Enter Texture ID (e.g., rbxassetid://123456789)", default_params["texture_id"])
|
| 237 |
+
decal_position = selectbox_with_default("Select Decal Position", config["decal_positions"], default_params["decal_position"])
|
| 238 |
+
else:
|
| 239 |
+
texture_id = None
|
| 240 |
+
decal_position = None
|
| 241 |
+
|
| 242 |
+
# Particle Effects Inputs
|
| 243 |
+
if particles_enabled:
|
| 244 |
+
particle_texture = text_input_with_default("Enter Particle Texture ID (e.g., rbxassetid://123456789)", default_params["particle_texture"])
|
| 245 |
+
particle_lifetime = text_input_with_default("Enter Particle Lifetime (e.g., 1,2)", default_params["particle_lifetime"])
|
| 246 |
+
particle_rate = text_input_with_default("Enter Particle Rate (e.g., 100)", default_params["particle_rate"])
|
| 247 |
+
particle_speed = text_input_with_default("Enter Particle Speed (e.g., 10,20)", default_params["particle_speed"])
|
| 248 |
+
particle_size = text_input_with_default("Enter Particle Size (e.g., 1,2)", default_params["particle_size"])
|
| 249 |
+
particle_acceleration = text_input_with_default("Enter Particle Acceleration (X,Y,Z, e.g., 0,-10,0)", default_params["particle_acceleration"])
|
| 250 |
+
particle_rot_speed = text_input_with_default("Enter Particle Rotation Speed (e.g., 100,200)", default_params["particle_rot_speed"])
|
| 251 |
+
particle_color = text_input_with_default("Enter Particle Color (RGB, e.g., 255,255,255)", default_params["particle_color"])
|
| 252 |
+
else:
|
| 253 |
+
particle_texture = None
|
| 254 |
+
particle_lifetime = None
|
| 255 |
+
particle_rate = None
|
| 256 |
+
particle_speed = None
|
| 257 |
+
particle_size = None
|
| 258 |
+
particle_acceleration = None
|
| 259 |
+
particle_rot_speed = None
|
| 260 |
+
particle_color = None
|
| 261 |
+
|
| 262 |
+
custom_prompt_enabled = checkbox_with_default("Enable Custom Prompt", False)
|
| 263 |
+
|
| 264 |
+
if custom_prompt_enabled:
|
| 265 |
+
custom_prompt = st.text_area("Enter Custom Prompt")
|
| 266 |
+
else:
|
| 267 |
+
custom_prompt = None
|
| 268 |
+
|
| 269 |
+
return {
|
| 270 |
+
"color": color, "size": size, "position": position, "shape": shape, "material": material,
|
| 271 |
+
"transparency": transparency, "reflectance": reflectance, "rotation_speed": rotation_speed,
|
| 272 |
+
"bounce_height": bounce_height, "collision": collision, "surface": surface, "anchor": anchor,
|
| 273 |
+
"collision_group": collision_group, "angular_velocity": angular_velocity, "linear_velocity": linear_velocity,
|
| 274 |
+
"density": density, "part_cframe": part_cframe, "camera_type": camera_type, "camera_position": camera_position,
|
| 275 |
+
"field_of_view": field_of_view, "camera_interpolation": camera_interpolation, "ambient_light": ambient_light,
|
| 276 |
+
"brightness": brightness, "time_of_day": time_of_day, "shadow_softness": shadow_softness, "shadow_color": shadow_color,
|
| 277 |
+
"fog_start": fog_start, "fog_end": fog_end, "fog_color": fog_color, "walk_speed": walk_speed, "jump_power": jump_power,
|
| 278 |
+
"health": health, "respawn_time": respawn_time, "background_music": background_music, "sound_volume": sound_volume,
|
| 279 |
+
"sound_effects": sound_effects, "environmental_sounds": environmental_sounds, "ui_text": ui_text, "ui_position": ui_position,
|
| 280 |
+
"ui_size": ui_size, "ui_color": ui_color, "ui_font": ui_font, "ui_text_size": ui_text_size, "texture_id": texture_id,
|
| 281 |
+
"decal_position": decal_position, "particle_texture": particle_texture, "particle_lifetime": particle_lifetime,
|
| 282 |
+
"particle_rate": particle_rate, "particle_speed": particle_speed, "particle_size": particle_size,
|
| 283 |
+
"particle_acceleration": particle_acceleration, "particle_rot_speed": particle_rot_speed, "particle_color": particle_color,
|
| 284 |
+
"custom_prompt": custom_prompt
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
def generate_lua_script(params, api_key):
|
| 288 |
+
client = Groq(api_key=api_key)
|
| 289 |
+
|
| 290 |
+
if params["custom_prompt"]:
|
| 291 |
+
prompt = params["custom_prompt"]
|
| 292 |
+
else:
|
| 293 |
+
prompt = "Create a Lua script for Roblox that:\n"
|
| 294 |
+
if params["color"]:
|
| 295 |
+
prompt += f"1. Creates a {params['shape']} with the specified color {params['color']}.\n"
|
| 296 |
+
if params["size"]:
|
| 297 |
+
prompt += f"2. Specifies the size {params['size']}.\n"
|
| 298 |
+
if params["position"]:
|
| 299 |
+
prompt += f"3. Positions it at {params['position']}.\n"
|
| 300 |
+
if params["part_cframe"]:
|
| 301 |
+
prompt += f"4. Sets its CFrame to {params['part_cframe']}.\n"
|
| 302 |
+
if params["material"]:
|
| 303 |
+
prompt += f"5. Sets the material to {params['material']}.\n"
|
| 304 |
+
if params["transparency"]:
|
| 305 |
+
prompt += f"6. Sets the transparency to {params['transparency']}.\n"
|
| 306 |
+
if params["reflectance"]:
|
| 307 |
+
prompt += f"7. Sets the reflectance to {params['reflectance']}.\n"
|
| 308 |
+
if params["rotation_speed"]:
|
| 309 |
+
prompt += f"8. Rotates the {params['shape']} at a speed of {params['rotation_speed']}.\n"
|
| 310 |
+
if params["bounce_height"]:
|
| 311 |
+
prompt += f"9. Sets the bounce height to {params['bounce_height']}.\n"
|
| 312 |
+
if params["collision"]:
|
| 313 |
+
prompt += f"10. Sets collision to {params['collision']}.\n"
|
| 314 |
+
if params["surface"]:
|
| 315 |
+
prompt += f"11. Sets the surface type to {params['surface']}.\n"
|
| 316 |
+
if params["anchor"]:
|
| 317 |
+
prompt += f"12. Sets anchor to {params['anchor']}.\n"
|
| 318 |
+
if params["collision_group"]:
|
| 319 |
+
prompt += f"13. Sets the collision group to {params['collision_group']}.\n"
|
| 320 |
+
if params["angular_velocity"] and params["linear_velocity"]:
|
| 321 |
+
prompt += f"14. Sets the angular velocity to {params['angular_velocity']} and linear velocity to {params['linear_velocity']}.\n"
|
| 322 |
+
if params["density"]:
|
| 323 |
+
prompt += f"15. Sets the density to {params['density']}.\n"
|
| 324 |
+
if params["camera_type"]:
|
| 325 |
+
prompt += f"16. Sets the camera type to {params['camera_type']}.\n"
|
| 326 |
+
if params["camera_position"]:
|
| 327 |
+
prompt += f"17. Sets the camera position to {params['camera_position']}.\n"
|
| 328 |
+
if params["field_of_view"]:
|
| 329 |
+
prompt += f"18. Sets the field of view to {params['field_of_view']}.\n"
|
| 330 |
+
if params["camera_interpolation"]:
|
| 331 |
+
prompt += f"19. Enables camera interpolation.\n"
|
| 332 |
+
if params["ambient_light"]:
|
| 333 |
+
prompt += f"20. Sets the ambient light to {params['ambient_light']}.\n"
|
| 334 |
+
if params["brightness"]:
|
| 335 |
+
prompt += f"21. Sets the brightness to {params['brightness']}.\n"
|
| 336 |
+
if params["time_of_day"]:
|
| 337 |
+
prompt += f"22. Sets the time of day to {params['time_of_day']}.\n"
|
| 338 |
+
if params["shadow_softness"]:
|
| 339 |
+
prompt += f"23. Sets the shadow softness to {params['shadow_softness']}.\n"
|
| 340 |
+
if params["shadow_color"]:
|
| 341 |
+
prompt += f"24. Sets the shadow color to {params['shadow_color']}.\n"
|
| 342 |
+
if params["fog_start"] and params["fog_end"] and params["fog_color"]:
|
| 343 |
+
prompt += f"25. Sets fog with start distance {params['fog_start']}, end distance {params['fog_end']}, and color {params['fog_color']}.\n"
|
| 344 |
+
if params["walk_speed"]:
|
| 345 |
+
prompt += f"26. Sets the player's walk speed to {params['walk_speed']}.\n"
|
| 346 |
+
if params["jump_power"]:
|
| 347 |
+
prompt += f"27. Sets the player's jump power to {params['jump_power']}.\n"
|
| 348 |
+
if params["health"]:
|
| 349 |
+
prompt += f"28. Sets the player's health to {params['health']}.\n"
|
| 350 |
+
if params["respawn_time"]:
|
| 351 |
+
prompt += f"29. Sets the respawn time to {params['respawn_time']}.\n"
|
| 352 |
+
if params["background_music"]:
|
| 353 |
+
prompt += f"30. Adds background music with ID {params['background_music']} and sets volume to {params['sound_volume']}.\n"
|
| 354 |
+
if params["sound_effects"]:
|
| 355 |
+
prompt += f"31. Adds sound effects with ID {params['sound_effects']}.\n"
|
| 356 |
+
if params["environmental_sounds"]:
|
| 357 |
+
prompt += f"32. Adds environmental sounds with ID {params['environmental_sounds']}.\n"
|
| 358 |
+
if params["ui_text"]:
|
| 359 |
+
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"
|
| 360 |
+
if params["texture_id"] and params["decal_position"]:
|
| 361 |
+
prompt += f"34. Adds a decal with texture ID {params['texture_id']} at position {params['decal_position']}.\n"
|
| 362 |
+
if params["particle_texture"]:
|
| 363 |
+
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"
|
| 364 |
+
|
| 365 |
+
# Request the script generation from Groq
|
| 366 |
+
response = client.create_lua_script(prompt=prompt)
|
| 367 |
+
return response['script']
|
| 368 |
+
|
| 369 |
+
def main():
|
| 370 |
+
config = load_config()
|
| 371 |
+
user_input = get_user_input(config)
|
| 372 |
+
|
| 373 |
+
if st.button("Generate Script"):
|
| 374 |
+
api_key = config["api_key"]
|
| 375 |
+
lua_script = generate_lua_script(user_input, api_key)
|
| 376 |
+
st.code(lua_script, language='lua')
|
| 377 |
+
|
| 378 |
+
if __name__ == "__main__":
|
| 379 |
+
main()
|