This is my current method for implementing it, which is just straight copying the comfy chair code. Is there a more efficient method for this?
Shuttle Chair armrests
- Mark9013100
- Joined: Sat Dec 27, 2014 6:06 pm
- Byond Username: Mark9013100
Shuttle Chair armrests
I've been attempting to add a new chair variant with armrests, the first method I attempted was making it a child of the comfy chairs, but that just resulted in the armrest sprite being the comfy chair instead of the one specifically made for it.
This is my current method for implementing it, which is just straight copying the comfy chair code. Is there a more efficient method for this?
This is my current method for implementing it, which is just straight copying the comfy chair code. Is there a more efficient method for this?
Spoiler:
- yorii
- Github User
- Joined: Fri Jan 05, 2018 1:13 am
- Byond Username: Yorpan
- Github Username: yorii
Re: Shuttle Chair armrests
I'm not very well-versed with objects, but I think you can do exactly the thing you did here but replace with
and then scrap any code that is literally identical like the post_unbuckle_mob() function.
For example as so:
Someone who isn't a pretend coder can feel free to correct me if I'm wrong.
Code: Select all
/obj/structure/chair/shuttle
Code: Select all
/obj/structure/chair/comfy/shuttle
For example as so:
Code: Select all
/obj/structure/chair/comfy/shuttle
name = "comfy shuttle chair"
desc = "It looks comfy."
icon_state = "shuttlechair"
/obj/structure/chair/comfy/shuttle/Initialize()
armrest = mutable_appearance('icons/obj/chairs.dmi', "shuttlechair_armrest")
armrest.layer = ABOVE_MOB_LAYER
return ..()
- Mark9013100
- Joined: Sat Dec 27, 2014 6:06 pm
- Byond Username: Mark9013100
- DemonFiren
- Joined: Sat Dec 13, 2014 9:15 pm
- Byond Username: DemonFiren
Re: Shuttle Chair armrests
I read that as "shuttle chair armaments" and I'm disappointed the Captain doesn't get dual gatling lasers on his chair.
-
- Code Maintainer
- Joined: Fri Apr 18, 2014 4:42 pm
- Byond Username: Anturke
Re: Shuttle Chair armrests
You'll need to wrap the armrest creation in a function then override it or make it use a variable. Otherwise calling the parent proc with ..() will replace the image you just created.
- Mark9013100
- Joined: Sat Dec 27, 2014 6:06 pm
- Byond Username: Mark9013100
Re: Shuttle Chair armrests
I'm not very code literate, is there an example of this anywhere in the code?
- yorii
- Github User
- Joined: Fri Jan 05, 2018 1:13 am
- Byond Username: Yorpan
- Github Username: yorii
Re: Shuttle Chair armrests
so the armrest var that gets used in the parent proc uses the parents var instead of the childs defined armrest var?AnturK wrote:You'll need to wrap the armrest creation in a function then override it or make it use a variable. Otherwise calling the parent proc with ..() will replace the image you just created.
-
- Code Maintainer
- Joined: Fri Apr 18, 2014 4:42 pm
- Byond Username: Anturke
Re: Shuttle Chair armrests
Code: Select all
/obj/structure/chair/shuttle
var/armrest_state = "default_armrest"
/obj/structure/chair/shuttle/Initalize()
...
armrest = mutable_appearance('chairs.dmi',armrest_state)
...
/obj/structure/chair/shuttle/whatever
armrest_state = "whatever_armrest"
- Mark9013100
- Joined: Sat Dec 27, 2014 6:06 pm
- Byond Username: Mark9013100
- Mark9013100
- Joined: Sat Dec 27, 2014 6:06 pm
- Byond Username: Mark9013100
Re: Shuttle Chair armrests
AnturK wrote:Something like this is the easiest solution.Code: Select all
/obj/structure/chair/shuttle var/armrest_state = "default_armrest" /obj/structure/chair/shuttle/Initalize() ... armrest = mutable_appearance('chairs.dmi',armrest_state) ... /obj/structure/chair/shuttle/whatever armrest_state = "whatever_armrest"
Tried it, but this line is giving me errors:
Code: Select all
armrest = mutable_appearance('icons/obj/chairs.dmi',armrest_state)
Here's the full thing I have:
Code: Select all
/obj/structure/chair/shuttle
name = "shuttle chair"
icon_state = "shuttlechair"
var/armrest_state = "shuttlechair_armrest"
item_chair = null
/obj/structure/chair/shuttle/Initialize()
...
armrest = mutable_appearance('icons/obj/chairs.dmi',armrest_state)
...
/obj/structure/chair/shuttle/armrest
armrest_state = "shuttlechair_armrest"
Who is online
Users browsing this forum: No registered users