SmashPuppet Posted September 29, 2016 Share Posted September 29, 2016 (edited) Edit: subject should be "if USER uses a Nick image"...Last night I was making a new players panel and needed to format it properly for medals/achievements if a player happened to be in a clan. I have clan icons shown as the last element for all intents and purposes for each player on the panel save for if a medal is achieved. I ran into an issue where if I happened to be using a nick image IE res_mods/mods/shared_resources/xvm/res/clanicons/NA/nick/SmashPuppet.png The text I had for Fighter or Top Gun etc, would overlap it as the {{clan}} macro ignores nick images. Of course this bugged me and I was ready to post a tentative request regarding this. I decided against it and tried my hand at using the newish {{py:macro}} system and managed to solve my own issue. Thought I would share here in case anyone might need it. Disclaimer: This happened to be my first attempt at using python. It is quite different from what I am used to and doesn't really behave the way my mind has been trained to work in some cases. The code is incredibly stupid simple yet took me an entire evening to get the syntax correct! Haha. If there is a better way of doing this, by all means please speak up. Perhaps I should have used the imghdr module instead? I don't know. I'm a green newby to python. =) But this works...Example to call it where the text should start at 370 pixels if a clan or nick image is present and at 350 pixels if not: "x": "{{clan?370|{{py:nickImage('res_mods/mods/shared_resources/xvm/res/clanicons/{{region}}/nick/{{name}}.png', '370', '350')}}}}", ...and the script (checkFile.py) ##################################################################### # SmashPuppet (NA) - there is no way to check for a nick image being # used by a player as one might expect by using {{clan}}. This will have to do for now. # {{py:nickImage('{{path-to-file}}', 'value1', 'value2')}} # Useful for formatting Players Panel. # Usage: Returns False then True in that order. # imports import BigWorld import os.path ##################################################################### @xvm.export('nickImage') def image_check(pathname, pos1, pos2): fpath = (pathname) a= pos1 b = pos2 if ( not os.path.exists(fpath)): return (b) return (a) Hope this helps that one person out of 500.000 that might need this. ;)Cheers! Edited September 29, 2016 by SmashPuppet @ Quote Link to comment Short link Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.