Placing and Removing Tank Decor

Placing and Removing Tank Decor

Rent's due.

I may need to work on it a bit tomorrow but today I hope to finish up the main functions of the tanks with decor placement as well as managing temp/humidity and lighting. [Future Me: So close.]

Today's music:

I'll have to come back to tanks now and then as I build the Slime Server, since they have to communicate a bit... but I will have finished the core of the Apartment Server, a big milestone to be sure.

I also bought another domain mostly because it was cheap and I could get 3 years for the price of 1. This will be the fallback domain and also provide a domain for this devlog. This site can now additionally be accessed via which is nice. I wish I could afford but hey, whatever, 30+ bucks a year is just not worth it to me.

Now that bills have been paid, servers remain up, lights remain on and roof remains over head. I can get to work and hopefully distract myself from the horrible feeling of watching the numbers in my bank account go from bad to worse like every month on the first.  

If I recall I left off having built the inventory for tank decor and still needed to create the base of the tank decor. What I think I will do is copy my furniture nodes (Placement node, Base node, etc.) and create a modified version of them.

Oh, I should probably do one thing in the models that I keep forgetting, I need to add a server-side script field to furniture. I will not need it for a while but it'll take me a minute and I'd like to do anything that might cause issues in how my tables are loaded in the apartment server now, while I am actually working on the apartment server than later on when I have other things on my mind.

That's better.

Alright, on to building the decor base on the Client.

Basic. Hastily drawn. It can be fixed later.

Wish I had more sleep. Cloudy mind today, maybe I just need more exercise? Would be a small price to pay to have a clearer mind. Anyway, lunch time.

Tested what I have up to now before starting making lunch, learned I have an interesting but where the tank inventory will hide itself when I click anywhere. I'll have to figure that out after lunch before I can go further.

Took the dog out, ate lunch and had a shower. Somehow it's 1 now. I guess this headache is slowing me down. Took some aspirin, hope that handles it. I slept on my shoulder weird and the pain got to my neck and now my head.

Now to fix this bug.

Looks like something is over the top of my UI, so when I click it registers me clicking THAT and hides the UI as it is supposed to do. But what the hell is over the top of the UI? Hmm...

Explain yourself, bug.

Nope. There's nothing above it in the remote and I can see the tool-tips when I hover.

I made the panel exclusive so it can't be closed by clicking elsewhere, this is how I got the idea I must be clicking something else somehow. Apparently not. Hmm...

But it's really behaving like that's the case. Maybe the mouse click is being registered at some kind of offset because it's in a viewport? I don't think that would be it.

I know it's not something over the top of the viewport or the light button wouldn't work either. I wouldn't even be able to open the inventory at all. Huh. Strange. It happens when I open the inventory.

I wonder if there is a way I can check in code what the hell the mouse is clicking?

Who consumed my click? - Godot Engine - Q&A
Tl;dr: is there a way to know which node consumed the mouse click event? Rational: In my game I’m ... the click event. Is there a way to trace it?

They really did think of a lot of things.


I see. Well, that's interesting. It's not registering any clicks after that. The object is not a control type... then what is it? I considered my collision setup might be the cause, it was technically loading after the UI... so I moved it to load before and that didn't change anything. This is some strange behavior. I'm sure it's something simple I am overlooking, though. Usually is.

Nothing is over the top of the TankInventory.
Button for the inventory item is setup right at least.

I thought for a second it could be Z axis sillybuggers but I don't think so. Again, it would have to be something IN the viewport given that I can already click buttons inside the viewport. I've inspected the things inside the viewport very hard with my eyeballs and nothing has shown itself.

Perhaps I will need to bring out the big hammer.

Another odd thing is there is no window dialog appearing on this. I wonder if there's a bug having a popup inside a viewport inside a popup? Hmm I will change the node type to a panel and just show/hide I guess? Maybe?

Yep. I'll have to refrain from using popups in viewports in popups in future.

Feels good to see it. Of course the perspective is busted but like I said; hastily drawn.

Now I need to write the code that actually sends the placement data to the server, as it turns out I didn't have many bugs in the code up til this point, just one where I meant to write decor_id and kinda started writing it and quit halfway through.

I did just have to copy the majority from something I know that already works but surprisingly none of my modifications to it had any problems. Nice.

Can't place outside the tank.

With that, back to the server.

func place_tank_decor_item(apt_id, tank_id, item_id, x, y, flipped):
	# Check item is available to be placed, then place it.
	var available_item = check_decor_available(apt_id, item_id)
	if not available_item:
		print("Decor item not available, can not place.")
		return false

	var placed_item_inv = database.execute("""
		UPDATE tank_decor_inventory_item
		SET in_use = '%s', x ='%s', y = '%s', flipped = '%s', tank_id = '%s'
		WHERE id = '%s';
	""" % [true, x, y, flipped, tank_id, available_item])
	return true

func check_decor_available(apt_id, item_id):
	var item_in_inventory_and_not_in_use = database.execute("""
		SELECT in_use FROM tank_decor_inventory_item WHERE house_id = '%s' AND item_id = '%s';
	"""% [apt_id, item_id])
	if item_in_inventory_and_not_in_use[1].data_row[0].size() > 0:
		return item_in_inventory_and_not_in_use[1].data_row[0][0] # Should be ID.
	return false

I rewrote the decor placement functions, should be more efficient. Seems I get more efficient each time I write one of these placement things, eh? Hopefully I didn't fuck it up.

Database says it's placed.

Now to load the dang decor when the tank is displayed. There were some bugs, though. I was returning item_id when I wanted id. IDs all start running together after a while. I should remember to take breaks...

So when the tank setup occurs we should request it's decor from the server, then the server will respond with whatever it finds in_use and with the correct tank_id, sending the Scene, X, Y and Flipped values for each placed item back to the client so the tank can place it's decor.

Decor server scripts are loading properly.

Now we have the data from the decor items, should be getting them from the server over on the client now... I think. Time to find out.

We're reaching the placement function.

Now to actually PLACE the decor in the tank and render it.

The hide is there. Hello hide.

So that's placing and loading taken care of (until I find a bug) on to removal... which SHOULD be easier than apartment furniture, all things considered.

All I should have to do is look up the decor item by it's id in the inventory DB and set it's in_use to false. I should also make sure it belongs to the apartment trying to remove it, of course. Then I just reload the decor inventory.

Alas, a bug. I am unable to find the mouse pointer in the tank it seems. I may need to use a texture button without a texture placed over the item... if I can look for a right-click... that is.

Sure, why not?
So empty... like me. :v

Now to make sure the tank inventory UI gets setup again, because right now it only gets setup on login and on placing an item.

And the inventory is updated.

Okay, with that I am done for today. Made it through the full day without pain in my arm, headache is still there but hey, looks like the arm is better.

Tomorrow I will have a half-day, or so it seems. I will be making sure the decor item's script stops safely and the item is removed from the children of the Tank as well, then I will wire up the light, humidity and temperature buttons to work on the server. Next week I will be starting on the Slime Server.