-
August 22nd, 2011, 02:51 #1
- Join Date
- Jan 2008
- Posts
- 19
Using the <token> data as an icon
So, following my idea from here, I started developing such an extension. I got pretty far but hit a roadblock. I can get the <token> value from the npc which is speaking. This value is from type token which I found no documentation, but its value is something on the likes of: tokens/host/Portraits/port001.JPG
If I try to pass this value to the field icon of the message object, nothing appears on the chat, not even the GM logo. I believe it is because this is just a prototype for a token and not an actual one which can be used as an icon, right? Is there a way I can create such an icon to be used?
I just changed the chat_entry.lua file, which follows:
Code:-- -- Please see the license.html file included with this distribution for -- attribution and copyright information. -- function onInit() ChatManager.registerEntryControl(self); end function onDeliverMessage(msg, mode) if mode == "chat" then local bOptPCHT = OptionsManager.isOption("PCHT", "on"); if User.isHost() then gmid, isgm = GmIdentityManager.getCurrent(); msg.sender = gmid; if isgm then msg.font = "chatgmfont"; if bOptPCHT then msg.icon = "portrait_gm_token"; end else msg.font = "chatnpcfont"; if bOptPCHT then local token = findNPCPortrait(msg.sender); if token then msg.icon = token; else msg.icon = "portrait_gm_token"; end end end else if bOptPCHT then local sCurrentId = User.getCurrentIdentity(); if sCurrentId then msg.icon = "portrait_" .. sCurrentId .. "_chat"; end end end elseif mode == "emote" then if User.isHost() then local gmid, isgm = GmIdentityManager.getCurrent(); if not isgm then msg.sender = ""; msg.text = gmid .. " " .. msg.text; end end end return msg; end function findNPCPortrait(npcName) local rootNode = DB.findNode("npc"); if rootNode then local npcs = rootNode.getChildren(); if not npcs then return nil; end for npcKey, npc in pairs(npcs) do local name = npc.getChild("name"); if name then if name.getText() == npcName then local token = npc.getChild("token").getValue(); if token then return token; end end end end end return nil; end function onTab() ChatManager.doAutocomplete(); end
-
August 22nd, 2011, 08:05 #2Originally Posted by The Crusader of Metal
Originally Posted by The Crusader of Metal
Code:<icon name="exampleicon" file="graphics/icons/some_icon.png" />
Tokencontrols on the other hand use strings to define the path and filename of the image file containing the token graphic, whilst Portraits can be referenced in place of icons using something like the following:
Code:msg.icon = "portrait_" .. nodeofpccharsheet.getName() .. "_chat";
Last edited by Zeus; August 22nd, 2011 at 08:07.
FG Project Development
Next Project(s)*: Starfinder v1.2 Starship Combat
Current Project: Starfinder v1.1 - Character Starships
Completed Projects: Starfinder Ruleset v1.0, Starfinder Core Rulebook, Alien Archive, Paizo Pathfinder Official Theme, D&D 5E data updates
* All fluid by nature and therefore subject to change.
-
August 23rd, 2011, 03:32 #3
- Join Date
- Jan 2008
- Posts
- 19
Thanks for the answer DrZeuss, I found your explanations really really useful!
What I did after posting to get it working was that I used an user just to create characters with the same name of the npcs, so I could get the portrait using the exact same idea you showed there. But unfortunately that is a little bit confusing so I don't feel like releasing an extension like this one.
The name of the control is 'token' but it's type is a tokenfield (tokencontrol). See here more library information on the control and its methods. To get the string name of the token path and file name, use the method getPrototype().
The <icon> idea is pretty nice, I liked it! The only problem would be needing to add all of the portraits to the extension before hand.
I am thinking about following the pseudo-pc idea though, would feel like a workaround but at least I wouldn't need to redistribute the extension everytime I added new entries.
Or if some dev could explain if it is possible to generate portraits for NPCs ...
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks