Placing variable based values in a imagemap

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
User avatar
Dragonstar89
Regular
Posts: 163
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: Self
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Placing variable based values in a imagemap

#1 Post by Dragonstar89 »

I decided to add some sort of 'skills HUD' to the top left of the screen of my game, and it is basically an image with the words Strength: Charisma: and Study:.

I have it placed in the area I want it on the screen, the problem I'm facing is adding the values next to the right words. Basically, I want this HUD of sorts to show the player the character's stats without having to click through to some screen, etc.

I figured using an imagemap in a screen could do it, but I'm not very well informed on that section of Ren'py and would definitely appreciate any help what so ever. Attached is the image I'm using as the 'HUD':
ui_points_001.png
ui_points_001.png (22.62 KiB) Viewed 1858 times
In a sort of diagonal way, I want the values for the Strength, Charisma, and Study points to show next to their respective names. Would anyone know how to do this? I know that showing the values only requires things like %(strength_pts)d but the problem is getting that to display within that 'screen.'

Again, any help would be highly appreciate. Thanks!
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

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

Re: Placing variable based values in a imagemap

#2 Post by Alex »

Not tested, but try to do it the way similar to imagemap save slots made, something like

Code: Select all

screen my_value:
    text v rotate 45

screen my_stat_imgmap:
    idle "img.png"
    hover "img.png"

    hotspot (100, 10, 50, 50) action None:
        use my_value(v=strength_var)
    hotspot (100, 70, 50, 50) action None:
        use my_value(v=charisma_var)
    hotspot (100, 130, 50, 50) action None:
        use my_value(v=study_var)

label start:
    $ strength_var = 3
    $ charisma_var = 5
    $ study_var = 10

    show screen my_stat_imgmap
    "?"

User avatar
Dragonstar89
Regular
Posts: 163
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: Self
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: Placing variable based values in a imagemap

#3 Post by Dragonstar89 »

Alex wrote:Not tested, but try to do it the way similar to imagemap save slots made, something like

Code: Select all

screen my_value:
    text v rotate 45

screen my_stat_imgmap:
    idle "img.png"
    hover "img.png"

    hotspot (100, 10, 50, 50) action None:
        use my_value(v=strength_var)
    hotspot (100, 70, 50, 50) action None:
        use my_value(v=charisma_var)
    hotspot (100, 130, 50, 50) action None:
        use my_value(v=study_var)

label start:
    $ strength_var = 3
    $ charisma_var = 5
    $ study_var = 10

    show screen my_stat_imgmap
    "?"
I've tried using your code, but I haven't got to see what the thing actually looks like because now when I run it (after doing some editing to your code because it originally was having problems) I continuously get this error:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 588, in script
  File "game/screens.rpy", line 758, in python
  File "game/screens.rpy", line 749, in python
Exception: Cannot display 1 as text.

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

Full traceback:
  File "C:\Users\^^^^^\Desktop\renpy-6.15.4-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Users\^^^^^\Desktop\renpy-6.15.4-sdk\renpy\ast.py", line 1110, in execute
    renpy.exports.with_statement(trans, paired)
  File "C:\Users\^^^^^\Desktop\renpy-6.15.4-sdk\renpy\exports.py", line 946, in with_statement
    return renpy.game.interface.do_with(trans, paired, clear=clear)
  File "C:\Users\^^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 1531, in do_with
    clear=clear)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 1853, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 2092, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 250, in visit_all
    d.visit_all(callback)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 252, in visit_all
    callback(self)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\core.py", line 2092, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\screen.py", line 166, in per_interact
    self.update()
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\screen.py", line 266, in update
    self.screen.function(**self.scope)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\screenlang.py", line 1217, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/screens.rpy", line 758, in <module>
    use my_value(v=strength_pts)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\display\screen.py", line 595, in use_screen
    screen.function(**scope)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\screenlang.py", line 1217, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\python.py", line 1297, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/screens.rpy", line 749, in <module>
    text v xpos 1.0
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\ui.py", line 448, in __call__
    w = self.function(*args, **keyword)
  File "C:\Users\^^^^\Desktop\renpy-6.15.4-sdk\renpy\text\text.py", line 1107, in __init__
    raise Exception("Cannot display {0!r} as text.".format(i))
Exception: Cannot display 1 as text.

Windows-post2008Server-6.2.9200
Ren'Py 6.15.4.320
A Ren'Py Game 0.0

Any ideas as to why this is?
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Placing variable based values in a imagemap

#4 Post by xela »

When you were editing the code, did you try something like:

screen my_value:
text "[v]" rotate 45

?
Like what we're doing? Support us at:
Image

User avatar
Dragonstar89
Regular
Posts: 163
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: Self
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: Placing variable based values in a imagemap

#5 Post by Dragonstar89 »

xela wrote:When you were editing the code, did you try something like:

screen my_value:
text "[v]" rotate 45

?
I just did now, but the rotate thing is still seen as an unknown argument to the string, so I removed it for the time being and now this is my current error:

Code: Select all

  File "renpy/common/00defaults.rpy", line 45, in _imagemap_auto_function
    rv = auto_param % variant
TypeError: not all arguments converted during string formatting
This is the code so far for the screen overlay:

Code: Select all

screen my_value:
    text "[v]" xpos 1.0

screen ptshud_overlay:

    imagemap:
        auto "ui/ui_points_001.png"
        ground "ui/ui_points_001.png"

        hotspot (100, 10, 50, 50) action None:
            use my_value(v=strength_pts)
        hotspot (100, 70, 50, 50) action None:
            use my_value(v=charisma_pts)
        hotspot (100, 130, 50, 50) action None:
            use my_value(v=study_pts)
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Placing variable based values in a imagemap

#6 Post by xela »

Sorry, that's an image map thing and I know nothing about that :(

To get rotate working:

Code: Select all

transform rt:
    rotate 45
            
screen my_value:
    text "[v]" at rt

screen ptshud_overlay:
    vbox:
        spacing 20
        use my_value(v=a)
        use my_value(v=b)
        use my_value(v=c)
Like what we're doing? Support us at:
Image

User avatar
Dragonstar89
Regular
Posts: 163
Joined: Mon Aug 12, 2013 11:28 pm
Projects: TBA
Organization: Self
IRC Nick: dstar89
Deviantart: senpai-jake
Skype: dstar_891
Location: West Virginia, USA
Contact:

Re: Placing variable based values in a imagemap

#7 Post by Dragonstar89 »

Thanks for the help everyone, I managed to do what I was aiming for :)
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game 8)

User avatar
Minuteman
Regular
Posts: 40
Joined: Sat Feb 24, 2018 2:02 pm
Location: On duty
Contact:

Re: Placing variable based values in a imagemap

#8 Post by Minuteman »

This is still work?
I want to put a variables to imagemap

imagemap:
hotspot (0, 0, 0, 0) action Jump("school"), SetVariable("date, True")
of the people for the people

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Draida