Posts
Afterpay having 'direct impact' on number of dogs Auckland Council shelters euthanise
I'm really not sure how to feel about this one. On one hand its great that less dogs are being put down. On the other hand people who got their dog impounded and couldnt afford $93 are taking an after pay loan to get it back. As someone who used to live in south auckland I feel like this is going to make the roaming dog problem way worse. If you're getting your dog impounded and after paying $93 then you are probably not equipped to be owning a dog.
https://www.rnz.co.nz/news/community/597583/afterpay-having-direct-impact-on-number-of-dogs-auckland-council-shelters-euthaniseOpen linkView original on lemmy.nzHelp suggest a data structure to hold objects so I can quickly look for the object by Keys
I want to preface this by saying that I think I got cooked by AI here.
I have a game where I am working on a job system. The job system has a job objects which I need to put into a data structure that can be searched via id, location, or work type. At first I was building with the mindset of "do whatever to solve this problem and make it work" but it became very hard to implement new features because I would break everything. So I started trying to think ahead and design ways of doing things that would handle all the different jobs and things.
At first I put all jobs into an array and iterated through. Then I learned about dictionaries and started using them for way to many things and so i updated my job queue to be a dictionary with the Key as ID > JobObj
Then I decided to plan out the job system before writing anything and "do it properly". I decided I needed to upgrade the data structure holding jobs because its a core part of the game and will be heavily interacted with. But I realized I only know array, dictionary and database, so I asked AI what data structure I should use and it suggested a nested dictionary.
Now im using multiple dictionaries but im really hating it. Its hard for me to work with and conceptually im not sure I can visualize how its even working.
How I am thinking about it is there is multiple layers of keys, 1st layer is work types, then once I find the work type it points to a dictionary of region IDs and that points to an array of jobs in the region.
Job def is work type like Planting Region id: the map is broken down into region IDs so i dont have to check every tile and can limit seaching
#python
var job_pool: Dictionary = {}
func register(designation: DesignationObj) -> void:
var job_def = designation.job
var region_id = designation.region_id
if not job_pool.has(job_def):
job_pool[job_def] = {}
if not job_pool[job_def].has(region_id):
job_pool[job_def][region_id] = []
job_pool[job_def][region_id].append(designation)
Here is how I am picturing it in my head.
var job_pool {
"plants": {
"1": {
"job1"
"job2"
}
"2": {
"job3"
}
}
"mining": {
"1": {
"job4"
"job5"
}
}
"hunting": {
"5":{
"job12"
}
}
}
But now I want to add ID look up into this im stuck and im thinking the entire structure does not work for what it needs to do.
How do people handle keyboard and mouse Input?
I am working on the input and it feels like its getting out of hand. I wanted to check in with people and see how people structure their input handling.
Currently I have 1 function _unhandled_unput(event) and inside there I have a ton of elif statements trying to handle every possible situation and event. Its manageable at the moment but I only have like 4 events so its going to get very out of hand if I continue.
I need to have 100s of these events based on whats selected and what mouse/keyboard buttons are being pressed and I need some way to resuse the actions.
::: spoiler spoiler
func _unhandled_input(event):
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_RIGHT:
clear_selection()
gui.queue_redraw()
get_viewport().set_input_as_handled()
return
if selected_item == "colonist": #broken
if event is InputEventKey:
if event.OS.get_keycode_string() == "r":
for colonist in selected_group:
colonist.set_state("DRAFT")
get_viewport().set_input_as_handled()
gui.queue_redraw()
#nothing selected dragbox to select things and single click to select things - does not work at the moment
elif selected_type == "" or selected_type == "basic":
if is_dragging and event is InputEventMouseMotion:
drag_end = camera.get_global_mouse_position()
cam_drag_end= get_viewport().get_mouse_position()
get_selection(drag_start, drag_end)
gui.queue_redraw()
get_viewport().set_input_as_handled()
return
elif event is InputEventMouseButton and not event.pressed:
is_dragging = false
gui.queue_redraw()
drag_start = null
drag_end = null
get_viewport().set_input_as_handled()
return
elif event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT:
selected_type = "basic"
is_dragging = true
drag_start = camera.get_global_mouse_position()
cam_drag_start = get_viewport().get_mouse_position()
gui.queue_redraw()
get_viewport().set_input_as_handled()
return
#command flow for dragging a selection box
elif selected_type == "command":
if selected_item == "structure_dict_growing":
if is_dragging and event is InputEventMouseMotion:
var grid_pos = tilemap.local_to_map(camera.get_global_mouse_position())
var local_pos = tilemap.map_to_local(grid_pos)
drag_end = local_pos + Vector2(32, 32)
cam_drag_end = get_viewport().get_mouse_position()
gui.queue_redraw()
get_viewport().set_input_as_handled()
return
elif event is InputEventMouseButton and not event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT:
is_dragging = false
gui.queue_redraw()
get_viewport().set_input_as_handled()
MessageBus.rpc_id(1, "request_zone_growing", selected_item ,drag_start, drag_end, multiplayer.get_unique_id())
drag_start = null
drag_end = null
return
elif event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT:
is_dragging = true
#to snap to grid
var grid_pos = tilemap.local_to_map(camera.get_global_mouse_position())
var local_pos = tilemap.map_to_local(grid_pos)
drag_start = local_pos - Vector2(32, 32)
cam_drag_start = get_viewport().get_mouse_position() #this is broken cbf fixing maybe one day after selection is working
gui.queue_redraw()
get_viewport().set_input_as_handled()
return
elif selected_type == "floor":
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT:
var global_mouse_pos = camera.get_global_mouse_position()
var grid_pos = tilemap.local_to_map(global_mouse_pos)
if selected_item == "":
return
MessageBus.rpc_id(1, "request_build_floor", selected_item, grid_pos, multiplayer.get_unique_id())
get_viewport().set_input_as_handled()
return
elif selected_type == "building":
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_LEFT:
var global_mouse_pos = camera.get_global_mouse_position()
var grid_pos = tilemap.local_to_map(global_mouse_pos)
if selected_item == "":
return
MessageBus.rpc_id(1, "request_build_structure", selected_item, grid_pos, multiplayer.get_unique_id())
get_viewport().set_input_as_handled()
return
:::
How can I get variables from a gd script? - Solved
Edit: ah i was reading an old doc because the reddit comment I saw was 6 years old. The property is get_property_list()
I have a script that is a global it contains a bunch of dictionaries that describe items. I need a way to get a list of the different types.
Searching for solutions I found https://docs.godotengine.org/en/3.2/classes/class_script.html#class-script-method-get-script-property-list
but I cant seem to get it working. Godot says "Function "get_script_property_list()" not found in base self"
Example of the what im trying to get a list of
var tile_dict_grass = {
"name": "grass",
"source": 1,
"atlas": Vector2i(1,0),
"move_speed": 0.80,
"path_cost": 2,
"fertility": 1,
"cleanliness": 1.5,
"flammability": 0.60,
"build_categories": "all",
"solid": false
}
var tile_dict_rich_soil = {
"name": "rich soil",
"source": 1,
"atlas": Vector2i(1,0),
"move_speed": 0.80,
"path_cost": 2,
"fertility": 1.4,
"cleanliness": -1.0,
"flammability": 0.0,
"build_categories": "all",
"solid": false
}
How im trying to get it.
func get_tile_dict():
var property_list = self.get_script_property_list()
var tile_list = []
for attr in dir(self):
if attr.startswith('tile_dict'):
value = getattr(self, attr)
tile_list.append(value)
return tile_list
How do I manage multiple sprites on a character efficiently?
I have a characterbody2d and I want to display the equipment being worn. So this equipment would need to be swapped around during game play.
I currently am using several sprites layered. How is best to handle this situation?
Paramount ads on the UFC cards suck so badly
Fucken hate getting hit by the same stupid ai generated sports betting ad every time there is a slight break. Bring back the corner mic and get commercials out of the fight.
How do I run two programs in the same Lutris instance?
I'm using lutris to run Guild Wars and I'd also like to run guild wars toolbox which needs to be run after guild wars has already started.
I tried running guild wars and toolbox as different lutris installs but toolbox cant see the guild wars process.
Does anyone know how this can be done?