Page 1 of 1

Placing variable based values in a imagemap

Posted: Tue Feb 04, 2014 2:42 am
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 960 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!

Re: Placing variable based values in a imagemap

Posted: Tue Feb 04, 2014 8:19 am
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
    "?"

Re: Placing variable based values in a imagemap

Posted: Tue Feb 04, 2014 1:12 pm
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?

Re: Placing variable based values in a imagemap

Posted: Tue Feb 04, 2014 1:20 pm
by xela
When you were editing the code, did you try something like:

screen my_value:
text "[v]" rotate 45

?

Re: Placing variable based values in a imagemap

Posted: Tue Feb 04, 2014 1:52 pm
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)

Re: Placing variable based values in a imagemap

Posted: Tue Feb 04, 2014 2:25 pm
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)

Re: Placing variable based values in a imagemap

Posted: Tue Feb 04, 2014 3:45 pm
by Dragonstar89
Thanks for the help everyone, I managed to do what I was aiming for :)

Re: Placing variable based values in a imagemap

Posted: Mon Sep 03, 2018 8:50 am
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")