what is the opposite of "append"?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
what is the opposite of "append"?
Hello,
Does anyone know what the opposite of "append" is?
In my inventory here is how I add a gun with bullets:
$mp.inv.append("gun (%d/6)" % ammo)
Not sure how to remove it. Please help!
Does anyone know what the opposite of "append" is?
In my inventory here is how I add a gun with bullets:
$mp.inv.append("gun (%d/6)" % ammo)
Not sure how to remove it. Please help!
-
- Miko-Class Veteran
- Posts: 829
- Joined: Sun Feb 20, 2005 8:45 pm
- Projects: NaNoRenO 2016, Ren'Py tutorial series
- Location: USA
- Contact:
Re: what is the opposite of "append"?
based off of official documentation, the exact opposite of append is pop() (which, given no parameters, removes the last entry from the array, but if given a parameter, removes the specified item in the array. remember arrays count from 0 upwards - "1" is the SECOND item in an array)
Do note that you're going to have to keep track of what item is where in the array, and that's going to take a bit of trial and error in some cases.
Do note that you're going to have to keep track of what item is where in the array, and that's going to take a bit of trial and error in some cases.
~Kitsune Zeta
Re: what is the opposite of "append"?
Thanks! I am a bit clueless with this stuff, so I'm not sure how to approach this.
Can you provide an example of how I might implement this? Doesn't have to work, exactly... I just want to know what it generally would look like.
$mp.inv.pop("gun (%d/6)" % ammo)?
I read the documentation but I suck at comprehending it.
Can you provide an example of how I might implement this? Doesn't have to work, exactly... I just want to know what it generally would look like.
$mp.inv.pop("gun (%d/6)" % ammo)?
I read the documentation but I suck at comprehending it.
Re: what is the opposite of "append"?
Actually based on your response I tried $mp.inv.pop(0), which worked!
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Re: what is the opposite of "append"?
Aw, c'mon. My answer was totally right. Give me some points.
Re: what is the opposite of "append"?
Does remove really work? I couldn't get that going.
-
- Miko-Class Veteran
- Posts: 829
- Joined: Sun Feb 20, 2005 8:45 pm
- Projects: NaNoRenO 2016, Ren'Py tutorial series
- Location: USA
- Contact:
Re: what is the opposite of "append"?
yeah, it takes a bit of work to figure some things out.bozance wrote:Thanks! I am a bit clueless with this stuff, so I'm not sure how to approach this.
Can you provide an example of how I might implement this? Doesn't have to work, exactly... I just want to know what it generally would look like.
$mp.inv.pop("gun (%d/6)" % ammo)?
I read the documentation but I suck at comprehending it.
...be careful on that one - pop(0) removes the first item in the array, regardless of what it is.bozance wrote:Actually based on your response I tried $mp.inv.pop(0), which worked!
remove(x) removes the first occurrence of x in the array. if you have an array [5, 3, "beer", 5, 2, "beer", "women"] and use remove("beer") and remove(5), the resulting array (after both are done) will be [3, 5, 2, "beer", "women"]
Yeah, I missed remove when I was glancing through the page. my bad on that one.Aleema wrote:Aw, c'mon. My answer was totally right. Give me some points.
~Kitsune Zeta
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Re: what is the opposite of "append"?
It totally works, I use it myself. It might be fickle with your variable in there, though. Pop() is going to rely on the placement of your item in the list, and if you don't know the place, then Remove() works because it simply finds it for you.
Re: what is the opposite of "append"?
Excellent. I'm going to put the gun and ammo counter in a separate frame, apart from inventory. Remove works fine with just regular strings, so I'll stick with those for inventory items.
Thanks for all your help.
Thanks for all your help.
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot]