|
Post by zenkrye on Dec 1, 2017 16:17:15 GMT
I am tying to use tables to store all of my patterns, strings and regions then build a user dialog to let them select the troop they want to use. When I use the code below I get an error that the script cannot fine image "PSRL.SiegeT2.P" but this is the reference to the pattern.
-- Image Table PSRL = {
SiegeT2 ={
P = Pattern("SiegeT2.png"),
S = "SiegeT2.png",
R = Region(149, 713, 118, 73),
}, }
addTextView('Select Troop Type')
troops = {"Warrior", "Mage", "Cavalry", "Siege", "Chocobo Caravan"}
addSpinner("troopSelect", troops, troops[4])
addTextView('Level')
level = {"1", "2", "3"}
addSpinnerIndex("levelSelect", level, level[2])
troop = "PSRL."..troopSelect.."T"..levelSelect..".P"
while (not exists(troop)) do -- this part gets an error
but if I use this it works just fine
troop = PSRL.SiegeT2.P
while (not exists(troop)) do -- this works fine.
Any idea what I am doing wrong?
|
|
|
Post by Exilereven on Dec 1, 2017 16:36:18 GMT
--obj/table/loc/reg whatever you want OBJ = {} --use it singularly like this OBJ.P = whatever pattern stuff --you can also make into table, and call from inside table like this OBJ.P = { loc = (120,120), troops = { stuff goes here}, random_name = {random stufd}, } Then call it like this click(OBJ.P.loc) --it would click at (120,120) Hope this helps, I didn't have a lot of time .
|
|
|
Post by zenkrye on Dec 1, 2017 17:08:11 GMT
Thanks for the quick reply. I know how to reference the item in the object but I am am struggling with building a variable that will reference the pattern in the object. The first example is what I m trying to do. The second example works if I want to always use the same pattern.
troopSelect = "Siege" levelSelect = "2"
if (troopSelect == "Chocobo Caravan") then
troop = PSRL.SiegeT2.P --this line works else
troop = "PSRL."..troopSelect.."T"..levelSelect..".P" --this line fails. end
while (not exists(troop)) do
--do something end
|
|
|
Post by Exilereven on Dec 1, 2017 18:04:43 GMT
Try:
OBJ.image_for_pattern = { image = Pattern("image"):targetOffset (20,20), }
Then call like
If exists(OBJ.image_for_pattern.image) then Bla bla bla
Is that what your talking about? Then you can make separate objects with patterns and call them separately.
|
|
|
Post by zenkrye on Dec 1, 2017 19:11:43 GMT
I think that you are not understanding my question. I am able to make the Object work with just calling it directly but I am trying to create a variable the assign that object to the variable. I am trying to build up a dynamic item instead of having to use a giant if then else statement to assign my image file.
|
|
|
Post by Exilereven on Dec 1, 2017 20:11:41 GMT
You mean like: variable = OBJ-and the table of info it comes with. So you can call variable, and it already knows your underlining pattern? I think I just don't know enough yet to help all the way, sorry my friend. I'm sure one of the other devs on here will chime in . Pretty cool group of people on the forums.
|
|