Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Control
- var query_handler
- var query_result
- func _ready():
- Steam.ugc_query_completed.connect(func(handle, result, results_returned, total_matching, cached): query_completed(handle, result, results_returned, total_matching, cached))
- query_handler = Steam.createQueryAllUGCRequest( Steam.UGC_QUERY_RANKED_BY_PUBLICATION_DATE,
- Steam.UGC_MATCHING_UGC_TYPE_ITEMS,
- 2304350,
- 2304350,
- 1
- )
- print("Query Handle ID: " + str(query_handler))
- Steam.setMatchAnyTag(query_handler, true)
- #Steam.setReturnOnlyIDs(query_handler, true)
- Steam.sendQueryUGCRequest(query_handler)
- #fetch_query_result(Steam.NUM_UGC_RESULTS_PER_PAGE)
- func query_completed(handle, result, results_returned, total_matching, cached):
- print("%s - %s - %s - %s - %s" % [handle, result, results_returned, total_matching, cached])
- if result == Steam.RESULT_OK:
- print("[UGC] Query was completed successfully")
- fetch_query_result(Steam.NUM_UGC_RESULTS_PER_PAGE)
- else:
- print("[UGC] Query failed to get published items. Error: " + str(result))
- func fetch_query_result(number_of_items : int):
- var result : Dictionary
- for i in number_of_items:
- result = Steam.getQueryUGCResult(query_handler, i)
- if not result.is_empty():
- #print("%d - %s" % [i, result])
- var x : WorkshopItem = load("res://ui/workshop_item.tscn").instantiate()
- x.id = result["file_id"]
- x.title = result["title"]
- x.description = result["description"]
- x.author = Steam.getFriendPersonaName(result["steam_id_owner"])
- x.upvotes = result["votes_up"]
- x.downvotes = result["votes_down"]
- x.preview_link = Steam.getQueryUGCPreviewURL(query_handler, i)
- x.data = result
- #x.preview = result["handle_preview-file"]
- %WorkshopItems.add_child(x)
- Steam.releaseQueryUGCRequest(query_handler)
- func _on_menu_button_pressed():
- Global.play_sfx(Global.ui_button_click_sfx)
- var x = load("res://main_menu.tscn").instantiate()
- get_tree().root.call_deferred("add_child", x)
- self.queue_free()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement