Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd menus to kitchen unit and welding rig (Finally Ready!) #3395
Conversation
NaturesWitness
referenced this pull request
Oct 1, 2013
Closed
Add soldiering iron menu to welding rig - How? #3377
kevingranade
reviewed
Oct 2, 2013
| @@ -7297,6 +7297,35 @@ void game::pickup(int posx, int posy, int min) | |||
| veh->refill("water", amt); | |||
| } | |||
| } | |||
| if (query_yn(_("Use hotplate?"))) | |||
This comment has been minimized.
This comment has been minimized.
kevingranade
Oct 2, 2013
Member
tabs, no, evil.
Also there are enough prompts here that it should probably be a menu instead of a bunch of prompts.
kevingranade
reviewed
Oct 2, 2013
| @@ -7248,7 +7248,7 @@ void game::list_items() | |||
| } | |||
|
|
|||
| // Pick up items at (posx, posy). | |||
| void game::pickup(int posx, int posy, int min) | |||
| void game::pickup(int posx, int posy, int min, game *g, player *p, item *it, bool t) | |||
This comment has been minimized.
This comment has been minimized.
kevingranade
reviewed
Oct 2, 2013
| if (query_yn(_("Use hotplate?"))) | ||
| { | ||
| { | ||
| if(it->charges == 0) |
This comment has been minimized.
This comment has been minimized.
kevingranade
Oct 2, 2013
Member
Instead of replicating the hotplate code here, generate a fake hotplate, and call the iuse function on it. This involves draining charges from the vehicle's batteries and then refilling what's left afterwards. Take a look at vehicle::fire_turret_internal() for an example of doing this with a UPS.
NaturesWitness
added some commits
Oct 2, 2013
This comment has been minimized.
This comment has been minimized.
|
I probably shouldn't try to code late at night, I have no idea what I'm doing with this. I couldn't find any mention of the UPS in vehicle.cpp, and I'm not sure how to get a menu to try to use an item. I'll sleep on it, and maybe in the morning it'll all make sense. |
This comment has been minimized.
This comment has been minimized.
|
oh.... oops, that PR hasn't landed yet, my bad. PR #3361 |
This comment has been minimized.
This comment has been minimized.
|
Well I got some sleep and feel much better. Will try and work on this more later today, have to help the neighbor with some stuff so might not be till later tonight. Plus I'm currently addicted to watching a let's play series by Totalbiscuit and Jesse Cox playing a game called "Terraria" which mostly involves them randomly fumbling about and Jesse repeatedly falling to his death down holes (look it up, it's hysterical, also Terraria is a really cool game). |
This comment has been minimized.
This comment has been minimized.
|
I think I'm at least making progress, although there are still issues to work out (listed in pull description) |
This comment has been minimized.
This comment has been minimized.
|
Okay to fix these undefined reference bugs, I think I need to get game.cpp to look at vehicle.cpp to find the blocks for vehicle::refill and vehicle::drain. The problem is, I don't know how to do it. I tried adding #include vehicle.h to game .cpp but that didn't do anything. What am I missing here? |
This comment has been minimized.
This comment has been minimized.
|
the context. The code you're copying from is inside the vehicle class, so it can call drain() and refill() directly, since this code is not in the vehicle code, it needs to access it like veh->drain() and veh->refill(). Also something's weird about if(choice == 2)break; |
This comment has been minimized.
This comment has been minimized.
|
Only two errors left, in the home stretch! |
This comment has been minimized.
This comment has been minimized.
|
Well adding an NPC to hold the hotplate quieted one of the errors, but I'm not sure if it will actually work. Now the only thing left is to get it to apply the hotplate, which I'm having no luck with at all. Care to give me a hint Kevin? |
This comment has been minimized.
This comment has been minimized.
|
Rather than spawning a NPC to hold the fake hotplate, what you want to do is spawn a fake hotplate and pass it to iuse::hotplate(). See player::use() around line 7474 for how that's done. |
This comment has been minimized.
This comment has been minimized.
|
Okay thanks I'll try and get another commit up tonight. |
This comment has been minimized.
This comment has been minimized.
|
You shouldn't need to give it to the player, just make an item object, load it with some charges, and pass it and a reference to the player to the iuse method. Mucking with the inventory while we do this is the last thing you want to do. To use it in crafting (does that work?) it needs to be added to the "crafting inventory" that gets generated on the fly from items near the player. Cancelling the action is currently a problem, but I'm making some changes to iuse that should prevent that from being a problem. |
This comment has been minimized.
This comment has been minimized.
|
I'm starting to get the feeling this may simply be too complicated for me to do with my limited knowledge of coding. Any chance you or someone else could just wrap this up for me? I have a feeling someone like you or Glyph could finish this up in about ten minutes, and once it's done for the kitchen I can just look at the code and get the welding rig part done. Sorry to pass the buck like this, but at this rate this'll never get done. BTW the crafting part of this was already in before, I just wanted to add the functionality of the iuse menus so people could repair their armor, heat food, etc. with the battery power in their vehicle. |
This comment has been minimized.
This comment has been minimized.
|
Okay took a break from this for a few days and feel much better. Removed the adding the hotplate to inventory thing, so there should only be one bug left. I think I have the u.use command in right, I just can't figure out what the second function value should be. I have no idea how values for this function work, can anyone tell me what the second entry needs to be? |
This comment has been minimized.
This comment has been minimized.
atomicdryad
commented on 2edd276
Oct 11, 2013
|
This would be the inventory letter of the item...which means it needs to go into inventory -.- |
This comment has been minimized.
This comment has been minimized.
atomicdryad
replied
Oct 11, 2013
|
I'm gonna take a look at this and see if it's possible to work without inventory cheese. I'll PR your PR if I do |
This comment has been minimized.
This comment has been minimized.
|
Not sure why I can't pr, but check out atomicdryad@57a038c |
This comment has been minimized.
This comment has been minimized.
|
You. Are. AWESOME! It works! I'll get a new commit up in a sec, and then I'll see if I can use the code from this as a reference to get the welding rig fixed. Huge thanks to both of you for all the help with this, this would have gone nowhere without your help, aka doing all the parts I don't understand, which is about all of it. I really am trying to learn something when doing these, so I can be more helpful in adding stuff to this fun game. |
NaturesWitness
added some commits
Oct 11, 2013
This comment has been minimized.
This comment has been minimized.
|
Just realized these have one other problem; they bypass the check for if you're on board the vehicle when you try to examine it. I guess this is going to be harder than I thought, oh well I'll try and work on it today. |
This comment has been minimized.
This comment has been minimized.
|
Hm, well they didn't check before iirc? |
This comment has been minimized.
This comment has been minimized.
|
There's something wrong with the menus in this; the kitchen unit works, but the game seems to be missing the code for the welding rig. Anyone know what's wrong with this? |
This comment has been minimized.
This comment has been minimized.
|
Hooray, it's finished! Thank you Kevingranade for all the advice you gave me while I was fumbling in the dark with this, and a big thanks to atomicdryad for writing the code block that actually made the hotplate iuse command work. I've tested this and it works great, the only other thing I think I could add to this would be a fix for the RV kitchen and welding rig not checking if you're standing in the vehicle before giving you the vehicle examine screen, but that probably is better addressed in a new PR. |
This comment has been minimized.
This comment has been minimized.
|
Is it possible to add some tools to welding rig or kitchen unit ingame? I think attaching hand press (and other tools, even unpowered ones) to rig can make some crafting recipes much less boring. |
This comment has been minimized.
This comment has been minimized.
|
It is possible, kitchen unit actually provides a pot and pan when standing near it. Both the kitchen and rig can store items, so if you just put your tools in them you can use all of them when standing near it. One feature of Cata that isn't well documented is that while crafting, you can use any tool or component that is two squares or less away from your character, it can be on the ground, in a container, wherever. |
NaturesWitness commentedOct 1, 2013
In my quest to make the RV kitchen unit and welding rig have all the same features as their portable counterparts, I'm trying to add the use_hotplate and soldier_weld iuse menus to them. As I don't actually know how to code, it's a disaster, errors out the wazoo. I'm hoping if I try to put this together, people who actually know how to code will see it, laugh for a while at all the idiotic mistakes, and help me fix it.
EDIT - Thanks to the help (and endless patience of) Kevingranade and atomicdryad, this is complete and functional! Tested and works, I think this really adds to the usefulness of the RV kitchen and welding rig, and it also gets rid of the annoying string of yes/no prompts the RV kitchen gave you, and replaces it with a neat, tidy menu selection instead.