Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


string error

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
titomdma
Newbie cheater
Reputation: 0

Joined: 14 Jul 2024
Posts: 12

PostPosted: Mon Jul 29, 2024 7:10 am    Post subject: string error Reply with quote

Hi

I receive an error with this script

Code:
local inputAddress = 0x1AB9032A044 -- Dirección 1 (inputAddress)
local inputAddress2 = (inputAddress + 0x890)  -- Dirección 2 (inputAddress)
local inputAddress3 = (inputAddress + 0x1120) -- Dirección 3 (inputAddress)
local inputAddress4 = (inputAddress + 0x19B0) -- Dirección 4 (inputAddress)
local inputAddress5 = (inputAddress + 0x28C) -- Dirección 4 (inputAddress)
local inputAddress6 = (inputAddress + 0xB1C) -- Dirección 4 (inputAddress)
local inputAddress7 = (inputAddress + 0x13AC) -- Dirección 4 (inputAddress)
local inputAddress8 = (inputAddress + 0x1C3C) -- Dirección 4 (inputAddress)
local upAddress = (inputAddress - 0x44C) -- Dirección UP (upAddress)
local downAddress = (inputAddress - 0x448) -- Dirección DOWN (downAddress)
local xValue1_2 = 0.0222 -- Valor para calcular el porcentaje de aumento para value1 y value2 (Xvalue1_2)
local xValue3_4 = 0.0222 -- Valor para calcular el porcentaje de aumento para value3 y value4 (Xvalue3_4)
local yValue1_2 = 0.1  -- Valor para calcular el porcentaje de disminución para value1 y value2 (Yvalue1_2)
local yValue3_4 = 0.1  -- Valor para calcular el porcentaje de disminución para value3 y value4 (Yvalue3_4)
local xValueside = 0.01 -- Valor para calcular el porcentaje de aumento para value1 y value2 (Xvalue1_2)
local xValueside2 = 0.01 -- Valor para calcular el porcentaje de aumento para value3 y value4 (Xvalue3_4)
-- Intervalo en milisegundos (10 ms = aproximadamente 100 veces por segundo)
local interval = 1

-- Función personalizada para leer el valor float en una dirección
local function customReadFloat(address)
  return readFloat(address)
end

-- Función personalizada para escribir un valor float en una dirección
local function customWriteFloat(address, value)
  writeFloat(address, value)
end

-- Función personalizada para modificar los valores según los porcentajes
local function customModifyValues()
  -- Lee los valores actuales
  local value1 = customReadFloat(inputAddress)
  local value2 = customReadFloat(inputAddress2)
  local value3 = customReadFloat(inputAddress3)
  local value4 = customReadFloat(inputAddress4)
  local value5 = customReadFloat(inputAddress5)
  local value6 = customReadFloat(inputAddress6)
  local value7 = customReadFloat(inputAddress7)
  local value8 = customReadFloat(inputAddress8)

  -- Verifica si los valores están dentro del rango [1, 190]
  if value1 < 1 or value1 > 190 then return end
  if value2 < 1 or value2 > 190 then return end
  if value3 < 1 or value3 > 190 then return end
  if value4 < 1 or value4 > 190 then return end
  if value5 < -20 or value5 > 20 then return end
  if value6 < -20 or value6 > 20 then return end
  if value7 < -20 or value7 > 20 then return end
  if value8 < -20 or value8 > 20 then return end

  -- Calcula los nuevos valores
  if customReadFloat(upAddress) > 0 then
    value1 = value1 * (1 + xValue1_2 / 100)
    value2 = value2 * (1 + xValue1_2 / 100)
    value3 = value3 * (1 + xValue3_4 / 100)
    value4 = value4 * (1 + xValue3_4 / 100)
    value5 = value5 * (1 - xValueside / 100)
    value6 = value6 * (1 - xValueside / 100)
    value7 = value7 * (1 - xValueside2 / 100)
    value8 = value8 * (1 - xValueside2 / 100)
  elseif customReadFloat(downAddress) > 0 then
    value1 = value1 * (1 - yValue1_2 / 100)
    value2 = value2 * (1 - yValue1_2 / 100)
    value3 = value3 * (1 - yValue3_4 / 100)
    value4 = value4 * (1 - yValue3_4 / 100)
    value5 = value5 * (1 - xValueside / 100)
    value6 = value6 * (1 - xValueside / 100)
    value7 = value7 * (1 - xValueside2 / 100)
    value8 = value8 * (1 - xValueside2 / 100)
  end

  -- Escribe los nuevos valores en las direcciones correspondientes
  customWriteFloat(inputAddress, value1)
  customWriteFloat(inputAddress2, value2)
  customWriteFloat(inputAddress3, value3)
  customWriteFloat(inputAddress4, value4)
  customWriteFloat(inputAddress5, value5)
  customWriteFloat(inputAddress6, value6)
  customWriteFloat(inputAddress7, value7)
  customWriteFloat(inputAddress8, value8)
end

-- Temporizador para ejecutar la función `customModifyValues` a intervalos regulares
local customTimer = createTimer(nil, true)
customTimer.Interval = interval
customTimer.OnTimer = function(timer)
  customModifyValues()
end
customTimer.Enabled = true


Error:[string "local inputAddress = 0x1AB9032A044 -- Direcci..."]:49: attempt to compare nil with number

previous version code


Code:
local inputAddress = 0x1AB9032A044 -- Dirección 1 (inputAddress)
local inputAddress2 = (inputAddress + 0x890)  -- Dirección 2 (inputAddress)
local inputAddress3 = (inputAddress + 0x1120) -- Dirección 3 (inputAddress)
local inputAddress4 = (inputAddress + 0x19B0) -- Dirección 4 (inputAddress)
local upAddress = (inputAddress - 0x44C) -- Dirección UP (upAddress)
local downAddress = (inputAddress - 0x448) -- Dirección DOWN (downAddress)
local xValue1_2 = 0.0222 -- Valor para calcular el porcentaje de aumento para value1 y value2 (Xvalue1_2)
local xValue3_4 = 0.0111 -- Valor para calcular el porcentaje de aumento para value3 y value4 (Xvalue3_4)
local yValue1_2 = 0.1  -- Valor para calcular el porcentaje de disminución para value1 y value2 (Yvalue1_2)
local yValue3_4 = 0.1  -- Valor para calcular el porcentaje de disminución para value3 y value4 (Yvalue3_4)

-- Intervalo en milisegundos (10 ms = aproximadamente 100 veces por segundo)
local interval = 1

-- Función personalizada para leer el valor float en una dirección
local function customReadFloat(address)
  return readFloat(address)
end

-- Función personalizada para escribir un valor float en una dirección
local function customWriteFloat(address, value)
  writeFloat(address, value)
end

-- Función personalizada para modificar los valores según los porcentajes
local function customModifyValues()
  -- Lee los valores actuales
  local value1 = customReadFloat(inputAddress)
  local value2 = customReadFloat(inputAddress2)
  local value3 = customReadFloat(inputAddress3)
  local value4 = customReadFloat(inputAddress4)

  -- Verifica si los valores están dentro del rango [1, 190]
  if value1 < 1 or value1 > 190 then return end
  if value2 < 1 or value2 > 190 then return end
  if value3 < 1 or value3 > 190 then return end
  if value4 < 1 or value4 > 190 then return end

  -- Calcula los nuevos valores
  if customReadFloat(upAddress) > 0 then
    value1 = value1 * (1 + xValue1_2 / 100)
    value2 = value2 * (1 + xValue1_2 / 100)
    value3 = value3 * (1 + xValue3_4 / 100)
    value4 = value4 * (1 + xValue3_4 / 100)
  elseif customReadFloat(downAddress) > 0 then
    value1 = value1 * (1 - yValue1_2 / 100)
    value2 = value2 * (1 - yValue1_2 / 100)
    value3 = value3 * (1 - yValue3_4 / 100)
    value4 = value4 * (1 - yValue3_4 / 100)
  end

  -- Escribe los nuevos valores en las direcciones correspondientes
  customWriteFloat(inputAddress, value1)
  customWriteFloat(inputAddress2, value2)
  customWriteFloat(inputAddress3, value3)
  customWriteFloat(inputAddress4, value4)
end

-- Temporizador para ejecutar la función `customModifyValues` a intervalos regulares
local customTimer = createTimer(nil, true)
customTimer.Interval = interval
customTimer.OnTimer = function(timer)
  customModifyValues()
end
customTimer.Enabled = true


works fine without errors

thanks in advance
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25807
Location: The netherlands

PostPosted: Mon Jul 29, 2024 9:23 am    Post subject: Reply with quote

inputaddress 7 is unreadable or not a float
_________________
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
View user's profile Send private message MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1530

PostPosted: Mon Jul 29, 2024 9:42 am    Post subject: Reply with quote

Code:
  if value1 < 1 or value1 > 190 then return end
  if value2 < 1 or value2 > 190 then return end
  if value3 < 1 or value3 > 190 then return end
  if value4 < 1 or value4 > 190 then return end


If any of the above lines of code execute and trigger "return", the following calculations will not occur!

"return" stops the code on the line it is on and reads the next command ( "end" ) and stops.

If you want to perform the following calculations, perform another check instead of "return".

Code:
  -- Calcula los nuevos valores
  if customReadFloat(upAddress) > 0 then
    value1 = value1 * (1 + xValue1_2 / 100)
    value2 = value2 * (1 + xValue1_2 / 100)
    value3 = value3 * (1 + xValue3_4 / 100)
    value4 = value4 * (1 + xValue3_4 / 100)
  elseif customReadFloat(downAddress) > 0 then
    value1 = value1 * (1 - yValue1_2 / 100)
    value2 = value2 * (1 - yValue1_2 / 100)
    value3 = value3 * (1 - yValue3_4 / 100)
    value4 = value4 * (1 - yValue3_4 / 100)
  end

  -- Escribe los nuevos valores en las direcciones correspondientes
  customWriteFloat(inputAddress, value1)
  customWriteFloat(inputAddress2, value2)
  customWriteFloat(inputAddress3, value3)
  customWriteFloat(inputAddress4, value4)
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
titomdma
Newbie cheater
Reputation: 0

Joined: 14 Jul 2024
Posts: 12

PostPosted: Tue Jul 30, 2024 8:08 am    Post subject: Reply with quote

Thanks both
Fixed code much better now

Thank so much
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites