Laharl tries coding : Container Transfer Content

How, what and why to code in BYOND.
Post Reply
User avatar
Laharl Monthy
Joined: Tue Apr 29, 2014 10:19 am
Byond Username: Laharl Montgommery

Laharl tries coding : Container Transfer Content

Post by Laharl Monthy » #95932

Hey, remember who caused nightmares in Malf after he coded in the Anchoring Bolts for the AI? No? Wait, what do you mean, no-one remembers the anchoring bolts? Goddamn it all.

Anyway, I'm going to try my hand at coding in Byond again, and this time for a apparently "harmless" Quality of Life feature : transfering the contents of one container to the other.

The basic idea is this :

Click and Drag your Storage item (Bag/Satchel/RPED) to dump the its contents into :
  • Another Container
    A Disposal Bin
    A Not-Walled Turf
I hope the clown won't start using backpacks filled with bananas to dump them all on the ground

Apparently the place to do this is the MouseOver() proc in storage.dm, at least I think.

TO DO:

In MouserOver(over_object)

Check for adjacence
Istype pour 3 cases :
  • Container : Special ContentsToContainer(over_object, mob/user)
    Bin : No need for extra checks, ContentsTo(over_object, mob/user)
    Default (It case of dropping over another item not made for that) : get_turf(over_object), check if turf isn't walled, ContentsTo(turf, mob/user)



New Proc : ContentsTo(over_object, mob/user)
For (item in contents), transfer items to over_object

(There shouldn't be needs for any checks, turfs and bins can hold unlimited amounts of any items)

New Proc : ContentsToContainer(over_object, mob/user)
For (item in contents)
  • Check if Container isn't full
    Check if that weight item weight class can go in container
    Check if container can hold that part (case of satchel and RPED)
    transfer item to over_object



I hope I didn't forget any edge cases.Sounds simple enough, right?
Prepare for unforeseen consequences
EDIT : And yes, that way you actually can check a bag content without triggering that pesky mousetrap.
EDIT2 : Humanity and drone Check is already done in MouseOver, so there's no problem there either.
Last edited by Laharl Monthy on Mon Jun 15, 2015 5:46 pm, edited 3 times in total.
User avatar
Not-Dorsidarf
Joined: Fri Apr 18, 2014 4:14 pm
Byond Username: Dorsidwarf
Location: We're all going on an, admin holiday

Re: Laharl tries coding : Container Transfer Content

Post by Not-Dorsidarf » #95960

Dumping the bag should set off mousetraps and mousetrap assemblies, just not on the user, on the desitnation turf
Image
Image
kieth4 wrote: infrequently shitting yourself is fine imo
There is a lot of very bizarre nonsense being talked on this forum. I shall now remain silent and logoff until my points are vindicated.
Player who complainted over being killed for looting cap office wrote: Sun Jul 30, 2023 1:33 am Hey there, I'm Virescent, the super evil person who made the stupid appeal and didn't think it through enough. Just came here to say: screech, retards. Screech and writhe like the worms you are. Your pathetic little cries will keep echoing around for a while before quietting down. There is one great outcome from this: I rised up the blood pressure of some of you shitheads and lowered your lifespan. I'm honestly tempted to do this more often just to see you screech and writhe more, but that wouldn't be cool of me. So come on haters, show me some more of your high blood pressure please. 🖕🖕🖕
User avatar
Laharl Monthy
Joined: Tue Apr 29, 2014 10:19 am
Byond Username: Laharl Montgommery

Re: Laharl tries coding : Container Transfer Content

Post by Laharl Monthy » #95980

Good news. I discovered the existence of a can_be_inserted proc in storage that does all the checks I needed for me for storage items. Huzzah!

The bad news? I think I'm adding redudant procs with ContentsToContainer and ContentstTo. Need to look into this further.

EDIT : Seems like remove_from_storage handles putting one item from one contents to another contents...On a case per case basis. I just need to loop that for each item. Migt not even need extra procs.

EDIT2 : Time to watch my PR get absolutly murdered

EDIT3 : It doesn't work, I'll figure it out later.

EDIT4 : It works now.

EDIT 5 : Doing a OOP overhaul of the whole code.
Post Reply

Who is online

Users browsing this forum: dendydoom