View previous topic :: View next topic |
Author |
Message |
Johnden Cheater Reputation: 0
Joined: 30 Jan 2018 Posts: 25
|
Posted: Wed Feb 07, 2018 3:55 am Post subject: Set value as text depending on the number |
|
|
I'm making a trainer and I have a value that randomizes between 1-26.
I need to make it so that the number changes to text
if value = 4 then then label displays "Top left shelf" for example.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Wed Feb 07, 2018 4:09 am Post subject: |
|
|
Code: |
texttable={}
texttable[3]="Something else"
texttable[4]="Top left shelf"
texttable[10000]="Some really high value"
value=4
if texttable[value] then
print("The value is "..texttable[value])
else
print("Unknown value:"..value)
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 |
|
|
Johnden Cheater Reputation: 0
Joined: 30 Jan 2018 Posts: 25
|
Posted: Wed Feb 07, 2018 4:37 am Post subject: |
|
|
Is it the same if I want to put the value in CELabel?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Wed Feb 07, 2018 4:49 am Post subject: |
|
|
yes, instead of print you just write the text to the label's Caption property
Code: |
MyForm.CELabel111234.Caption="The value is "..texttable[value]
|
_________________
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 |
|
|
Johnden Cheater Reputation: 0
Joined: 30 Jan 2018 Posts: 25
|
Posted: Thu Feb 08, 2018 12:09 pm Post subject: |
|
|
Another question, My Label doesn't seem to display the text ON
Code: |
function CETimer1Timer(sender)
local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "KeyCard RNG")
local value=memoryrecord_getValue(memrec)
if value==1 then control_setCaption(CETrainer_CELabel1, "ON")
else control_setCaption(CETrainer_CELabel1, "OFF")
end
end |
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Thu Feb 08, 2018 1:25 pm Post subject: |
|
|
try this code
Code: |
function CETimer1Timer(sender)
local memrec=getAddressList().getMemoryRecordByDescription("KeyCard RNG")
if (memrec==nil)
showMessage("The description was wrong")
end
if memrec.value==1 then
CETrainer.CELabel1.Caption="ON"
else
CETrainer.CELabel1.Caption="It is OFF"
end
end
|
And if your timer running? I am assuming the default code of your label is "OFF" so this script changes it to "It is OFF" to show the timer is active or not
_________________
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 |
|
|
Johnden Cheater Reputation: 0
Joined: 30 Jan 2018 Posts: 25
|
Posted: Thu Feb 08, 2018 1:54 pm Post subject: |
|
|
Didn't seem to work, it still stayed at OFF.
I want to use the timer similarly in this code
Code: |
function CETimer1Timer(sender)
local memrec=addresslist_getMemoryRecordByDescription(getAddressList(), "Adress 1")
local value=memoryrecord_getValue(memrec)
control_setCaption(CETrainer_CELabel1, value)
end
|
I need each value to be a different text.
As an example I tried 0 - OFF and 1 - ON
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Thu Feb 08, 2018 3:57 pm Post subject: |
|
|
look at your timer code or object. make sure you enable it
_________________
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 |
|
|
Johnden Cheater Reputation: 0
Joined: 30 Jan 2018 Posts: 25
|
Posted: Thu Feb 08, 2018 4:29 pm Post subject: |
|
|
Doesn't work for me even if the timer is enabled. When I change the value to 1 it still says OFF
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Thu Feb 08, 2018 5:26 pm Post subject: |
|
|
is your formname correct?
is the labelname correct ?
does your timer run ?
_________________
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 |
|
|
Johnden Cheater Reputation: 0
Joined: 30 Jan 2018 Posts: 25
|
Posted: Fri Feb 09, 2018 12:04 am Post subject: |
|
|
I've checked, timer is running, and the formname (CETrainer) and labelname (CELabel1) is correct.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Fri Feb 09, 2018 2:25 am Post subject: |
|
|
and your timer's onTimer function is CETimer1Timer ? Then why does your label say "OFF" instead of "It is OFF" ?
try this code for the timer:
Code: |
function CETimer1Timer(sender)
print("I am running")
CETrainer.CELabel1.Caption="MAYBE"
local memrec=getAddressList().getMemoryRecordByDescription("KeyCard RNG")
if (memrec==nil) then
print("The description was wrong")
end
if tonumber(memrec.value)==1 then
CETrainer.CELabel1.Caption="ON"
else
CETrainer.CELabel1.Caption="It is OFF"
end
end
|
and tell me what happens
_________________
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
Last edited by Dark Byte on Fri Feb 09, 2018 7:47 am; edited 1 time in total |
|
Back to top |
|
|
Johnden Cheater Reputation: 0
Joined: 30 Jan 2018 Posts: 25
|
Posted: Fri Feb 09, 2018 7:45 am Post subject: |
|
|
First thing that appeared was an Error
Quote: |
[string "function CETimer1Timer(sender)
..."]:7: 'then' expected near 'print'
|
After I added 'then'
lua engine repeatedly printed "I am running"
Also when I changed the value to 1 the label displayed "ON"
Any other value displayed "It is OFF"
So that worked.
Thank you
|
|
Back to top |
|
|
|