View previous topic :: View next topic |
Author |
Message |
pears How do I cheat? Reputation: 0
Joined: 31 Oct 2015 Posts: 7
|
Posted: Mon Jan 16, 2017 12:32 pm Post subject: Change picture based on memory value |
|
|
Hi,
I am trying to write a trainer that allows me to change a picture based on an associated memory value. I have pointers to the value I am looking (1byte 0 or 1 value depending). I have the images loaded, the true image and the false image (false is hidden). I want to be able to swap between the two based on the value in memory.
I tried the following which gives errors.
Code: | function Item1TimerTimer(sender)
local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Item1")
local value=memoryrecord_getValue(memrec)
if value then
control_setPicture(CETrainer_Item1, CETrainer_Item1.Picture)
else
control_setPicture(CETrainer_Item1, CETrainer_Quest.Picture)
end
end |
Currently "Item1" always shows it's own picture (since it's loaded with it by default). Any help would be appreciated.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Mon Jan 16, 2017 1:03 pm Post subject: |
|
|
Instead of trying to swap pictures, maybe you should simply place the two in the same location on your form.
Then simply set each one's visibility depending on your value. Code: | if value == 1 then
CETrainer_Item1.Visible = true
CETrainer_Quest.Visible = false
else
CETrainer_Item1.Visible = false
CETrainer_Quest.Visible = true
end |
|
|
Back to top |
|
|
pears How do I cheat? Reputation: 0
Joined: 31 Oct 2015 Posts: 7
|
Posted: Mon Jan 16, 2017 1:07 pm Post subject: |
|
|
I thought about this, but it'll be 400+ of that for each item. Was attempting to do it with the least amount of work possible heh. If I have to, I'll end up doing something similar. I just don't really see how to access the properties of the image object. Tried to find it on the lua wiki page but wasn't clear.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Mon Jan 16, 2017 1:09 pm Post subject: |
|
|
the first issue I see is the "if value then" line , that will result in true if the value is 0 (it only returns false if value is nil, which isn't the same as 0)
second, if it worked, the original picture of Item1 would be gone. (the picture of item1 gets replaced by Quest.)
Third, setting a picture gives it the same object (images are smart and that they use assign internally, but still, I recommend assign instead)
e.g:
Code: |
function Item1TimerTimer(sender)
if SavedPicture==nil then --global var saving the original picture
SavedPicture=CreatePicture();
SavedPicture.assign(CETrainer.Item1.Picture)
end
local memrec=getAddressList().getMemoryRecordByDescription("Item1")
if memrec.Value~=0 then
CETrainer.Item1.Picture.Assign(SavedPicture)
else
CETrainer.Item1.Picture.Assign(CETrainer.Quest.Picture)
end
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
pears How do I cheat? Reputation: 0
Joined: 31 Oct 2015 Posts: 7
|
Posted: Mon Jan 16, 2017 3:22 pm Post subject: |
|
|
I see. Thanks Dark Byte. I just didn't really know where to start but this helps a bunch. Appreciate it!
|
|
Back to top |
|
|
|