Page 1 of 2
Tables and images
Posted: Thu Jan 12, 2017 9:54 am
by Ditto
Hi, so I was trying to programmatically change the image in a table .. and a quick search turned up this thread:
http://forums.rptools.net/viewtopic.php ... TableEntry
but didn't find anything there.
However, I noticed this:
setTableEntry
http://lmwcs.com/rptools/wiki/setTableEntry
Allows you to change/update the String "value" in the table .. however, it doesn't allow you to change/update the image id ?
Any reason for that?
Best I can figure, in order to update the image, I need to create a new row, and delete the old ... so:
Code: Select all
[h: img = tableImage ( "Misc", 7 )]
[h: deleteTableEntry( "Place",10)]
[h: addTableEntry ( "Place", 10, 10, "Place 10 Alt", img ) ]
However, when I do that, the image in the table comes out as a big red "X" .. O.o
How do I change/add an entry in a table along with the image for it ?
Re: Tables and images
Posted: Thu Jan 12, 2017 11:11 am
by wolph42
you could have better replied in jagged's thread, that way he gets a notification, now he doens't and most likely will it take longer to respond. AFAIK he's the only one who can answer your questions.
Re: Tables and images
Posted: Thu Jan 12, 2017 12:30 pm
by aliasmask
If the table image shows a red X, can you display the image either on a token or in chat?
I know table images have to load in to memory to be seen properly and that doesn't happen until you try to output one. So, not seeing the table image in the new table entry may just be a memory buffer thing.
Re: Tables and images
Posted: Thu Jan 12, 2017 1:03 pm
by Ditto
wolph42 wrote:you could have better replied in jagged's thread, that way he gets a notification, now he doens't and most likely will it take longer to respond. AFAIK he's the only one who can answer your questions.
Oh sorry, it was an old thread, and I'm used to necro-threading being frowned upon .. so I started a new thread
@alias:
Yes, the image displays fine everywhere else ...
it's just after I use the addTableEntry ..
hmm .. yeah, so the table itself doesn't show .. but if I just "trust it" and let her rip, seems to be fine ... very odd ..
[edit] sorry, I spoke too soon, it was still displaying the old image .. the new image won't show ...
[/edit]
So, that's the Delete row + create row.
Is there any way to update an image on a row? rather than dropping and re-creating ?
Re: Tables and images
Posted: Thu Jan 12, 2017 2:36 pm
by aliasmask
Hmm, maybe the image asset itself isn't saved with the addTableEntry, just the asset identifier. ie the name, but not the actual image (that would be a bug). The asset should be the same if you have it in one table and move to another. Caching should take care of the rest.
Re: Tables and images
Posted: Thu Jan 12, 2017 3:01 pm
by Ditto
aliasmask wrote:Hmm, maybe the image asset itself isn't saved with the addTableEntry, just the asset identifier. ie the name, but not the actual image (that would be a bug). The asset should be the same if you have it in one table and move to another. Caching should take care of the rest.
Tried a stripped down test: (following the code sample on wiki:
http://lmwcs.com/rptools/wiki/addTableEntry
v1.4.0.5
Create new table (manually).
named; "test"
create rows 1, 2, 3, 4.
Create a new token, named "elf".
Use default token image for an Elf.
Create lib:Utility token.
create macro "test"
(uncheck "Allow Players to Edit Macro"
add following logic to "test":
[r: switchToken ( "elf" )]
[r:addTableEntry("test",5,5,"alf", getTokenImage())]
Checked the table: Yep, big red "X".
Re: Tables and images
Posted: Thu Jan 12, 2017 11:25 pm
by aliasmask
alf the elf?
Re: Tables and images
Posted: Fri Jan 13, 2017 4:13 pm
by Ditto
aliasmask wrote:alf the elf?
hey, it's from the wiki .. *shrug* .. who am I to argue?
Re: Tables and images
Posted: Mon Jan 16, 2017 7:16 pm
by aliasmask
Fyi, I figured out the problem. Seems to be a bug. It adds "asset://" to the beginning, but when getting an image id, it already has that on the beginning so it doubles it. This is my fix.
Code: Select all
[deleteTableEntry("players",1)]
[addTableEntry("players",1,1,"",substring(getImage("DM"),8))]
I also tried setTableImage(tableName,image) which has the same problem.
Code: Select all
[setTableImage("players",substring(getImage("image:Unknown"),8))]
Re: Tables and images
Posted: Tue Jan 17, 2017 12:55 am
by Full Bleed
aliasmask wrote:Fyi, I figured out the problem. Seems to be a bug.
Nice catch... you should bug report it. I updated the original table macros thread on the issue (pointing back to here) and PM'd Jagged to make him aware of the issue... but you've isolated the issue and it sounds like there is pathway to fix that wouldn't require the function's creator to address.
Re: Tables and images
Posted: Fri Jan 20, 2017 12:03 pm
by Ditto
aliasmask wrote:Fyi, I figured out the problem. Seems to be a bug. It adds "asset://" to the beginning, but when getting an image id, it already has that on the beginning so it doubles it. This is my fix.
Code: Select all
[deleteTableEntry("players",1)]
[addTableEntry("players",1,1,"",substring(getImage("DM"),8))]
I also tried setTableImage(tableName,image) which has the same problem.
Code: Select all
[setTableImage("players",substring(getImage("image:Unknown"),8))]
Sweet! I'll try that ... thanks!
Re: Tables and images
Posted: Fri Jan 20, 2017 8:46 pm
by Ditto
aliasmask wrote:
I also tried setTableImage(tableName,image) which has the same problem.
Code: Select all
[setTableImage("players",substring(getImage("image:Unknown"),8))]
hey ..wait .. what ?
setTableImage isn't on the wiki page!!
Cheater!!
What's the full syntax of that sucker ?
Re: Tables and images
Posted: Fri Jan 20, 2017 10:25 pm
by aliasmask
I actually tried it not knowing it wasn't there. I use setTableImage(tableName,image).
Re: Tables and images
Posted: Fri Jan 20, 2017 11:09 pm
by JamzTheMan
FYI: since i have the code open, looks like the current list of functions are:
Code: Select all
"tbl", "table", "tblImage", "tableImage", "getTableNames", "getTableRoll", "setTableRoll", "clearTable", "addTableEntry", "deleteTableEntry", "createTable", "deleteTable", "getTableVisible", "setTableVisible", "getTableAccess", "setTableAccess", "getTableImage", "setTableImage", "copyTable", "setTableEntry")
(sorry, list is "as is" from code, not alphabetic)
FWIW, Looks like we have the following in the wiki:
Code: Select all
addTableEntry
clearTable
createTable
deleteTable
deleteTableEntry
getTableAccess
getTableNames
getTableRoll
getTableVisible
setTableAccess
setTableEntry
setTableRoll
setTableVisible
table
tableImage
tbl
tblImage
Re: Tables and images
Posted: Sat Jan 21, 2017 11:45 am
by Ditto
JamzTheMan wrote:FYI: since i have the code open, looks like the current list of functions are:
Code: Select all
"tbl", "table", "tblImage", "tableImage", "getTableNames", "getTableRoll", "setTableRoll", "clearTable", "addTableEntry", "deleteTableEntry", "createTable", "deleteTable", "getTableVisible", "setTableVisible", "getTableAccess", "setTableAccess", "getTableImage", "setTableImage", "copyTable", "setTableEntry")
(sorry, list is "as is" from code, not alphabetic)
FWIW, Looks like we have the following in the wiki:
Code: Select all
addTableEntry
clearTable
createTable
deleteTable
deleteTableEntry
getTableAccess
getTableNames
getTableRoll
getTableVisible
setTableAccess
setTableEntry
setTableRoll
setTableVisible
table
tableImage
tbl
tblImage
Cool, so I'm not going crazy
sweet.
however, seems that setTableImage doesn't touch images on the individual rows, it's just the 1 larger image for the full table ...