How to remove stored variable?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
Black_Saber
Regular
Posts: 74
Joined: Wed Jul 14, 2010 4:56 am
Completed: cafe minigame
Projects: Beach Restaurant
Location: Indonesia
Contact:

How to remove stored variable?

#1 Post by Black_Saber »

Hi, I would like to ask a question :

I have a minigame where the protag brings 2 goods from one person to another, with a time limit.
At first, I don't have any problem, but when the 2nd times of the same minigame starts, the goods from the last minigame which haven't been delivered is still saved in the inventory, so my question is, how to remove that?

I'm not using python, I'm just using if and turn around script using renpy, basicallly, my codes is something like this :

Code: Select all

goods = ["table","chair","cup","glass","plate","fan"] around 5 or 7 object is inside
This variable will be used to describe which object that the client want to have by presented it on the game screen using :
$ achoice = renpy.random.choice(goods)
                if achoice == "table":
                    show table at Position(xpos=xx, ypos=yy)
                    $ goods.remove("table")

====

carry = [ ] limited to 2 object
This variable will be used to describe the object that protag carries, limited to 2 object and start with []

====

ordergoods = ["table","chair","cup","glass","plate","fan"]
This variable will be used when protag wants to take an object from the supplier, he will be asking for an object which the supplier will open a menu with the list of goods. Protag can choose from that menu, and will be removed after the protag takes one object.

====

The scenario start when the time already reach it's limit, but protag still carry either one or two object in his hands. This gives no problem when the minigame won't be called again, but the problem arise when the minigame start again. First, I use either 
$ carry.remove(ordergoods)
or
$ carry = [ ]
or by describing the object one by one
if carry("chair"):
  $ carry.remove("chair") and such

but they aren't working. When I use $ carry = [ ] and check the stored variable using Shift + D, the variable $ carry is indeed become empty ( showing [ ] ), but when I click the client, the object still there! I still can give the object from before, and resulted in traceback because there aren't any object to remove.
Can anyone enlighten me?
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)

User avatar
Shalambay Shift
Regular
Posts: 71
Joined: Fri Aug 03, 2012 5:52 am
Projects: ASL!, PotD, MftBS, Capture~
Organization: Valonia, Shalambay Shift
Location: Milky Way
Contact:

Re: How to remove stored variable?

#2 Post by Shalambay Shift »

I don't know if I can help because I'm not in a computer with Ren'Py in it, but try this:

Code: Select all

    $ client = None
Image
VALONIA ~Shadow Valley~ | Blog
Nyofuuu~ fuu~ fuuu....

Black_Saber
Regular
Posts: 74
Joined: Wed Jul 14, 2010 4:56 am
Completed: cafe minigame
Projects: Beach Restaurant
Location: Indonesia
Contact:

Re: How to remove stored variable?

#3 Post by Black_Saber »

I've tried putting

Code: Select all

$ carry = "none"
but it still didn't remove my previous stored object, yet it will makes me unable to get new object from the supplier when the next minigame occurs.

however, if I use

Code: Select all

$ carry = [ ]
on the next minigame, I can take objects from the supplier, but when I give it to client, there's 4 object available (assuming I still have 2 object from previous minigame).
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)

Black_Saber
Regular
Posts: 74
Joined: Wed Jul 14, 2010 4:56 am
Completed: cafe minigame
Projects: Beach Restaurant
Location: Indonesia
Contact:

Re: How to remove stored variable?

#4 Post by Black_Saber »

bumping

is the problem lies because I set when storing the variable?

Code: Select all

==syntax from the supplier==
menu:
 set carry
 "chair":
    $ ordergoods.remove("chair")
And I would like to know why when I use SHIFT+D, my $ carry variable have "u" in the front of the object stored? Ex : u"chair", u"table"
Is that why I can't completely removed it using $ carry = [ ] ?

If I use

Code: Select all

if $ carry("table"):
  $ carry.remove("table")
and such, it will give me error 

TypeError: 'RevertableList' object is not callable
while in the interaction with the customer, append and remove the object is working.
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot], piinkpuddiin, snotwurm