View previous topic :: View next topic |
Author |
Message |
Drivium Advanced Cheater
Reputation: 0
Joined: 16 Apr 2013 Posts: 97
|
Posted: Mon Apr 18, 2022 7:30 pm Post subject: if/then loop to check if value has increased or decreased |
|
|
I'm trying to make an if/then loop that monitors the players health and constantly checks if the value has increased or decreased from the previous value. If it decreases, I want to shrink my player by a certain amount. If it increases, grow my player. I can get it to work some of the time, but not consistently. Also, sometimes it does the opposite - grows when it should shrink. I think I'm getting confused on where to put the health variables. In case you're wondering why I used the for loop, it's so the player grows/shrinks smoothly. Any help would be greatly appreciated.
Code: | [ENABLE]
{$lua}
if syntaxcheck then return end
test = getAddress("[scale]+20C")
test1 = getAddress("[scale]+210")
test2 = getAddress("[scale]+214")
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
function fc_loop(thr_obj)
while fc_loop_running == true
do
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
if bHealth > aHealth then
xscale = readFloat"[scale]+20C"
yscale = readFloat"[scale]+210"
zscale = readFloat"[scale]+214"
for i = 0.1,0.5,0.0008
do
writeFloat(test,xscale+i)
writeFloat(test1,yscale+i)
writeFloat(test2,zscale+i)
--if i > 0.5 then break end
--sleep(10)
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
end
else
if bHealth < aHealth then
xscale = readFloat"[scale]+20C"
yscale = readFloat"[scale]+210"
zscale = readFloat"[scale]+214"
for i = 0.1,0.4,0.0008
do
writeFloat(test,xscale+i*-1)
writeFloat(test1,yscale+i*-1)
writeFloat(test2,zscale+i*-1)
--if i > 0.5 then break end
--sleep(10)
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
end
end
end
bHealth = readInteger"[phealth]"
end
end
fc_loop_running = true
fc_thread = createThread(fc_loop)
[DISABLE]
{$lua}
fc_loop_running = false
fc_thread = nil |
|
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1522
|
Posted: Tue Apr 19, 2022 1:03 am Post subject: |
|
|
Just for a different idea;
Code: | [ENABLE]
{$lua}
if syntaxcheck then return end
test = getAddress("[scale]+20C")
test1 = getAddress("[scale]+210")
test2 = getAddress("[scale]+214")
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
function fc_loop(thr_obj)
while fc_loop_running == true
do
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
if bHealth > aHealth then
xscale = readFloat"[scale]+20C"
yscale = readFloat"[scale]+210"
zscale = readFloat"[scale]+214"
i1 = 0.1
i2 = 0.5
i3 = 0.0008
writeFloat(test,xscale+i1)
writeFloat(test1,yscale+i2)
writeFloat(test2,zscale+i3)
--if i > 0.5 then break end
--sleep(10)
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
end
--else
if bHealth < aHealth then
xscale = readFloat"[scale]+20C"
yscale = readFloat"[scale]+210"
zscale = readFloat"[scale]+214"
i1 = 0.1
i2 = 0.4
i3 = 0.0008
writeFloat(test,xscale+i1*-1)
writeFloat(test1,yscale+i2*-1)
writeFloat(test2,zscale+i3*-1)
--if i > 0.5 then break end
--sleep(10)
aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
end
end
bHealth = readInteger"[phealth]"
end
fc_loop_running = true
fc_thread = createThread(fc_loop)
{$asm}
[DISABLE]
{$lua}
fc_loop_running = false
fc_thread = nil |
_________________
|
|
Back to top |
|
 |
Drivium Advanced Cheater
Reputation: 0
Joined: 16 Apr 2013 Posts: 97
|
Posted: Tue Apr 19, 2022 1:23 pm Post subject: |
|
|
Thanks! With this solution, looks as though the scales won't be scaled proportionally. xyz equates to height width depth of the character. My variable naming may have made that confusing. |
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1522
|
Posted: Tue Apr 19, 2022 2:47 pm Post subject: |
|
|
I just gave an example of "if" in the code.
Because there are too many undefined in the code
Code: | [scale] --undefined!
[phealth] --undefined! |
And it's like comparing the same query;
Code: | aHealth = readInteger"[phealth]"
bHealth = readInteger"[phealth]"
if bHealth > aHealth then |
I assumed they fixed them and just focused on the test code.
The code will not test in its current state.
Because you are comparing two same (equal) values. _________________
|
|
Back to top |
|
 |
Drivium Advanced Cheater
Reputation: 0
Joined: 16 Apr 2013 Posts: 97
|
Posted: Tue Apr 19, 2022 4:04 pm Post subject: |
|
|
I was thinking I needed to capture and store the value so the current value can compare against the previous value. I'm thinking my variables may be incorrect. Your method of breaking the if statement into 2 parts as opposed to a single if may help. |
|
Back to top |
|
 |
|