| extendsControl |
| |
| varmessages= ["Hello curious one!\nIt seems that is your first time creating a planetary system,\n\n let me guide you through this adventure...", |
| "Every planetary system needs a star,\na unique and luminous sphere held by its own gravity.\n\nWhat is the name of your star?", |
| "Good, that’s a stellar name!\nYour star has mass, it refers to the amount of atoms in it, more mass, more atoms, less mass, less atoms.\n\nWhat is the mass of [Star-Name]?", |
| "Good, it’s all coming together!\nIs your star a warm or a cold place? Temperature is a body's ability to impart energy as heat to another body.\n\nWhat is the temperature of [Star-Name]?", |
| "Great, what a special climate!\nNow, is your star bright or dark? Luminosity is the measure of light of your star.\n\nWhat is the luminosity of [Star-Name]?", |
| "Amazing, light for the universe!\nFor the finishing touches… is your star small or big? Radius is distance from the center to the edge of your star.\n\nWhat is the radius of [Star-Name]?", |
| "Perfect!\n\nAll your data has been taken, space monkeys are working!\n\n[Star-Name] is now generating..."] |
| |
| varDELAY=1 |
| varREAD_TIME=2 |
| vart=0 |
| varindex=0 |
| varmode="" |
| vardata_stars |
| varGENERAL_DATA |
| |
| onreadyvarNAME_STAR_DB= $slider/name_star |
| onreadyvarVALUE= $slider/value |
| onreadyvarMIN= $slider/HBoxContainer/min_value |
| onreadyvarMAX= $slider/HBoxContainer/max_value |
| onreadyvardisplayText= $text/DisplayText |
| onreadyvarinput= $text_input/input |
| onreadyvarslider= $slider/slider |
| onreadyvarenter= $enter |
| |
| exportvarready=false |
| |
| exportvarstar_data= { |
| "name": "Alpha Centauri", |
| "mass": "2400 Sun masses", |
| "temperature": "1200 degrees", |
| "luminosity": "3..", |
| "radius": "120000", |
| "type": "Dwarf" |
| } |
| |
| func_ready(): |
| mode="in" |
| VALUE.visible=false |
| MIN.visible=false |
| MAX.visible=false |
| input.visible=false |
| slider.visible=false |
| |
| $slider.visible=false |
| enter.visible=false |
| |
| $HTTPRequest.request("http://144.202.115.196/nasaspaceapp/data_type_stars.json") |
| $HTTPRequest2.request("http://144.202.115.196/nasaspaceapp/data_stars.json") |
| set_text() |
| |
| func_process(delta): |
| fadein(delta) |
| ifInput.is_action_just_pressed("ui_accept"): |
| print("enter") |
| is_action_enter() |
| |
| ifmode=="read": |
| ifindex!=0: |
| return |
| t+=delta |
| ift>READ_TIME: |
| t=0 |
| mode="out" |
| index+=1 |
| set_color(1) |
| |
| funcis_action_enter(): |
| ifindex==1: |
| vars=input.text |
| iflen(s) !=0: |
| star_data["name"] =s |
| index+=1 |
| set_text() |
| mode="in" |
| t=0 |
| $hit.play() |
| elifindex==2: |
| varval=slider.value |
| star_data["mass"] =str(val) |
| index+=1 |
| star_data["type"] =get_star(int(star_data["mass"])) |
| mode="in" |
| t=0 |
| #create temperature |
| print("masa : "+String(val)) |
| vard=get_data_general(val) |
| print(d) |
| slider.min_value=d.temperature[0] |
| slider.max_value=d.temperature[1] ifd.temperature[1] !=nullelsed.temperature[0] *2 |
| slider.value=d.temperature[0] + ((d.temperature[1] -d.temperature[0]) /2) ifd.temperature[1] !=nullelsed.temperature[0] + (((d.temperature[0] *2) -d.temperature[0]) /2) |
| MIN.text=String(slider.min_value) +" Kv" |
| MAX.text=String(slider.max_value) +" Kv" |
| val=0 |
| set_text() |
| $hit.play() |
| elifindex==3: |
| # se deben crear nuevos valores minimos y maximos basandonos en los |
| # datos de la tabla general |
| varval=slider.value |
| star_data["temperature"] =str(val) |
| index+=1 |
| |
| #create temperature |
| vard=get_data_general(int(star_data["mass"])) |
| print(d) |
| slider.min_value=d.luminosity[0] |
| slider.max_value=d.luminosity[1] ifd.luminosity[1] !=nullelsed.luminosity[0] *2 |
| MIN.text=String(slider.min_value) +" Lo" |
| MAX.text=String(slider.max_value) +" Lo" |
| slider.value=d.luminosity[0] + ((d.luminosity[1] -d.luminosity[0]) /2) ifd.luminosity[1] !=nullelsed.luminosity[0] + (((d.luminosity[0] *2) -d.luminosity[0]) /2) |
| |
| set_text() |
| t=0 |
| mode="in" |
| $hit.play() |
| elifindex==4: |
| varval=slider.value |
| star_data["luminosity"] =str(val) |
| index+=1 |
| #create temperature |
| vard=get_data_general(int(star_data["mass"])) |
| print(d) |
| slider.min_value=d.radius[0] |
| slider.max_value=d.radius[1] ifd.radius[1] !=nullelsed.radius[0] *2 |
| MIN.text=String(slider.min_value) +" Rs" |
| MAX.text=String(slider.max_value) +" Rs" |
| slider.value=d.radius[0] + ((d.radius[1] -d.radius[0]) /2) ifd.radius[1] !=nullelsed.radius[0] + (((d.radius[0] *2) -d.radius[0]) /2) |
| |
| set_text() |
| mode="in" |
| t=0 |
| $hit.play() |
| elifindex==5: |
| varval=slider.value |
| star_data["radius"] =str(val) |
| index+=1 |
| $slider/HBoxContainer.visible=false |
| VALUE.visible=false |
| set_text() |
| mode="in" |
| t=0 |
| $hit.play() |
| elifindex==6: |
| $hit.play() |
| ready=true |
| funcfadein(delta): |
| ifmode=="in": |
| set_color(t/DELAY) |
| t+=delta |
| ift>DELAY: |
| t=0 |
| mode="read" |
| ifmode=="out": |
| set_color(1- (t/DELAY)) |
| t+=delta |
| ift>DELAY: |
| t=0 |
| mode="in" |
| set_text() |
| |
| funcset_text(): |
| index=clamp(index, 0, len(messages) -1) |
| print(index) |
| ifindex==0orindex==1: |
| displayText.text=messages[index] |
| ifindex==2: |
| NAME_STAR_DB.text=star_data["name"]+" is "+get_star(slider.max_value/2) |
| ifindex==1: |
| input.visible=true |
| ifindex>1: |
| displayText.text=messages[index].replace("[Star-Name]", star_data["name"]) |
| input.visible=false |
| ifindex>2: |
| NAME_STAR_DB.visible=false |
| |
| ifindex>0: |
| enter.visible=true |
| else: |
| enter.visible=false |
| ifindex>1andindex<6: |
| slider.visible=true |
| VALUE.visible=true |
| MIN.visible=true |
| MAX.visible=true |
| $slider.visible=true |
| $slider/HBoxContainer.visible=true |
| else: |
| slider.visible=false |
| |
| funcset_color(alpha): |
| varcolor=displayText.get_color("font_color") |
| alpha=clamp(alpha, 0, 1) |
| color.a=alpha |
| displayText.add_color_override("font_color", color) |
| |
| funcget_data_general(value): |
| fordatainGENERAL_DATA: |
| if (data.min<=valueanddata.max>=value): |
| returndata.data |
| return {} |
| |
| funcget_star(value): |
| fordataindata_stars: |
| if(data.masa[0] <=valueanddata.masa[1] >=value): |
| returndata.name |
| return"no name" |
| |
| func_on_HTTPRequest_request_completed(result, response_code, headers, body): |
| varjson=JSON.parse(body.get_string_from_utf8()) |
| data_stars=json.result |
| |
| slider.min_value=data_stars[len(data_stars)-1].masa[0] |
| slider.max_value=data_stars[0].masa[1] |
| MIN.text=String(slider.min_value) +" Ms" |
| MAX.text=String(slider.max_value) +" Ms" |
| slider.value=slider.max_value/2 |
| |
| VALUE.text=String(slider.max_value/2) |
| |
| func_on_HTTPRequest2_request_completed(result, response_code, headers, body): |
| varjson=JSON.parse(body.get_string_from_utf8()) |
| GENERAL_DATA=json.result |
| |
| func_on_slider_value_changed(value): |
| NAME_STAR_DB.text=star_data["name"]+" is "+get_star(value) |
| VALUE.text=String(value) |
| |
| funcdelete(): |
| queue_free() |