show current money and image map shop (edit)

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
saskuto
Regular
Posts: 64
Joined: Fri Jan 15, 2010 2:56 pm
Contact:

show current money and image map shop (edit)

#1 Post by saskuto »

Hiya again ^^;

Ok i have 1 query
1) does anyone now how you can show the current amount of money on the inventory screen at particular co-ords?

At the moment I have at the start:

Code: Select all

label start:
    
    python:
        my_inventory = Inventory()
        crystal = Item("Energy Crystal", 3)
        herbs = Item("Healing Herb", 4)
        gem = Item("Magic Gem", 5)
        food = Item("Food", 11)

    "Oh, look! I found ten coins!"

    $ my_inventory.earn(10)

    $ current_money = my_inventory.money

    "Now I have %(current_money)d coins."
and I have my inventory label:

Code: Select all

label inventory:
    $ show_button=False
    $ ui.vbox(xalign=.5)
    if treasure1:
        $ ui.imagebutton("treasure1.jpg", "treasure1_hover.jpg",clicked=ui.callsinnewcontext('see_treasure1'))
    else:    
        $ ui.imagebutton("inventory.jpg", "inventory.jpg")
    $ ui.textbutton('Return to game', clicked=ui.jumps('return_to_game'))
    $ ui.close()
    $ ui.interact()
just not sure how to get the current money to show up when the inventory is called ^^;

Any help would be much appreciated :)
Last edited by saskuto on Tue Mar 23, 2010 8:42 am, edited 1 time in total.

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: show current money and image map shop

#2 Post by Showsni »

Looks like you're missing a bunch of commas in your image map code; put one after every hotspot.

As for the money, there are several ways to do it...

Something like, adding

$ current_money = my_inventory.money
$ ui.text(current_money)

somewhere between the ui.vbox and the ui.close should work, I think... Or, add a new vbox with whatever coordinates you want to put it in. Or you could have it as a textbutton that does something when you click it, or as an image depending on how much money you have...

saskuto
Regular
Posts: 64
Joined: Fri Jan 15, 2010 2:56 pm
Contact:

Re: show current money and image map shop

#3 Post by saskuto »

Showsni wrote:Looks like you're missing a bunch of commas in your image map code; put one after every hotspot.

As for the money, there are several ways to do it...

Something like, adding

$ current_money = my_inventory.money
$ ui.text(current_money)

somewhere between the ui.vbox and the ui.close should work, I think... Or, add a new vbox with whatever coordinates you want to put it in. Or you could have it as a textbutton that does something when you click it, or as an image depending on how much money you have...
Thanks alot my shop is now working!

Only problem is with the inventory and show money, i have put

Code: Select all

label inventory:
    $ show_button=False
    $ ui.vbox(xalign=.5)
    if treasure1:
        $ ui.imagebutton("treasure1.jpg", "treasure1_hover.jpg",clicked=ui.callsinnewcontext('see_treasure1'))
    else:    
        $ ui.imagebutton("inventory.jpg", "inventory.jpg")
    $ current_money = my_inventory.money    
    $ ui.text((current_money))    
    $ ui.textbutton('Return to game', clicked=ui.jumps('return_to_game'))
    $ ui.close()
    $ ui.interact()
and now i keep getting:

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

TypeError: 'int' object is not iterable

While running game code:
 - script at line 65 of O:\Program Files\Ren'py\renpy-6.10.2\Blue Rain/game/script.rpy
 - script at line 181 of O:\Program Files\Ren'py\renpy-6.10.2\Blue Rain/game/script.rpy
 - python at line 181 of O:\Program Files\Ren'py\renpy-6.10.2\Blue Rain/game/script.rpy.

-- Full Traceback ------------------------------------------------------------

  File "renpy-6.10.2/renpy/bootstrap.py", line 260, in bootstrap
  File "renpy-6.10.2/renpy/main.py", line 310, in main
  File "renpy-6.10.2/renpy/main.py", line 93, in run
  File "renpy-6.10.2/renpy/execution.py", line 234, in run
  File "renpy-6.10.2/renpy/ast.py", line 341, in execute
  File "renpy-6.10.2/renpy/exports.py", line 539, in say
  File "renpy-6.10.2/renpy/character.py", line 565, in __call__
  File "renpy-6.10.2/renpy/character.py", line 524, in do_display
  File "renpy-6.10.2/renpy/character.py", line 338, in display_say
  File "O:\Program Files\Ren'py\renpy-6.10.2\renpy\ui.py", line 70, in interact
  File "O:\Program Files\Ren'py\renpy-6.10.2\renpy\display\core.py", line 1578, in interact
  File "O:\Program Files\Ren'py\renpy-6.10.2\renpy\display\core.py", line 2072, in interact_core
  File "renpy-6.10.2/renpy/display/layout.py", line 647, in event
  File "renpy-6.10.2/renpy/display/layout.py", line 647, in event
  File "renpy-6.10.2/renpy/display/layout.py", line 647, in event
  File "renpy-6.10.2/renpy/display/behavior.py", line 460, in event
  File "renpy-6.10.2/renpy/curry.py", line 38, in __call__
  File "renpy-6.10.2/renpy/game.py", line 292, in call_in_new_context
  File "renpy-6.10.2/renpy/execution.py", line 234, in run
  File "renpy-6.10.2/renpy/ast.py", line 558, in execute
  File "O:\Program Files\Ren'py\renpy-6.10.2\renpy\python.py", line 937, in py_exec_bytecode
  File "O:\Program Files\Ren'py\renpy-6.10.2\Blue Rain/game/script.rpy", line 181, in <module>
  File "O:\Program Files\Ren'py\renpy-6.10.2\renpy\ui.py", line 194, in text
  File "renpy-6.10.2/renpy/display/text.py", line 689, in __init__
  File "renpy-6.10.2/renpy/display/text.py", line 729, in update
  File "renpy-6.10.2/renpy/display/text.py", line 348, in input_tokenizer
TypeError: 'int' object is not iterable

While running game code:
 - script at line 65 of O:\Program Files\Ren'py\renpy-6.10.2\Blue Rain/game/script.rpy
 - script at line 181 of O:\Program Files\Ren'py\renpy-6.10.2\Blue Rain/game/script.rpy
 - python at line 181 of O:\Program Files\Ren'py\renpy-6.10.2\Blue Rain/game/script.rpy.

Ren'Py Version: Ren'Py 6.10.2e

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: show current money and image map shop

#4 Post by chronoluminaire »

Rather than

Code: Select all

$ ui.text((current_money))
try

Code: Select all

$ ui.text('%d' % current_money)
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

saskuto
Regular
Posts: 64
Joined: Fri Jan 15, 2010 2:56 pm
Contact:

Re: show current money and image map shop

#5 Post by saskuto »

chronoluminaire wrote:Rather than

Code: Select all

$ ui.text((current_money))
try

Code: Select all

$ ui.text('%d' % current_money)
Thankyou! Is there anyway I can set the co-ords of its placement too?

chronoluminaire
Eileen-Class Veteran
Posts: 1153
Joined: Mon Jul 07, 2003 4:57 pm
Completed: Elven Relations, Cloud Fairy, When I Rule The World
Tumblr: alextfish
Skype: alextfish
Location: Cambridge, UK
Contact:

Re: show current money and image map shop (edit)

#6 Post by chronoluminaire »

Sure. You can apply Position Properties to the ui.vbox() call to move the whole column around, or to the ui.text() call to just move the display of the amount of money. Try, for example:

Code: Select all

$ ui.text('%d' % current_money, xalign=1.0) # this makes it right-justified
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!

saskuto
Regular
Posts: 64
Joined: Fri Jan 15, 2010 2:56 pm
Contact:

Re: show current money and image map shop (edit)

#7 Post by saskuto »

chronoluminaire wrote:Sure. You can apply Position Properties to the ui.vbox() call to move the whole column around, or to the ui.text() call to just move the display of the amount of money. Try, for example:

Code: Select all

$ ui.text('%d' % current_money, xalign=1.0) # this makes it right-justified
Ah I see it works but it wont go over the top of my inventory it sits under it...

User avatar
Alex
Lemma-Class Veteran
Posts: 3098
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: show current money and image map shop (edit)

#8 Post by Alex »

You make one vbox for all your inventory stuff. Try different boxes for money and others.

Code: Select all

...
vbox() # for the whole inventory, it makes everything inside appears from top to bottom

vbox() # for money
<some code for money>
ui.close() # for first box
vbox() # for imagebuttons
<some code>
ui.close() # for second vbox

ui.close() # for the whole box
ui.interact()

Post Reply

Who is online

Users browsing this forum: Google [Bot]