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 


[VB6] SetVariable - Multiple Variables

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Blader
I post too much
Reputation: 2

Joined: 19 Jan 2007
Posts: 2049

PostPosted: Mon Dec 10, 2007 5:29 pm    Post subject: [VB6] SetVariable - Multiple Variables Reply with quote

Is there an easier way to set array variables other than typing them out?
For example, I have a game and the variable is:
Code:
_root._game.towerArray.0.damage
_root._game.towerArray.1.damage
_root._game.towerArray.2.damage
_root._game.towerArray.3.damage
_root._game.towerArray.4.damage

The number after "towerArray." is the tower number, so pretend I want it to set it all the way to 100, is there a faster way then typing it all out?
I was thinking you could add a "+ 1" somewhere so it could keep increasing.

_________________
Back to top
View user's profile Send private message
Devilizer
Master Cheater
Reputation: 0

Joined: 22 Jun 2007
Posts: 451

PostPosted: Mon Dec 10, 2007 5:35 pm    Post subject: Reply with quote

Use a timer..?
Back to top
View user's profile Send private message
Blader
I post too much
Reputation: 2

Joined: 19 Jan 2007
Posts: 2049

PostPosted: Mon Dec 10, 2007 5:38 pm    Post subject: Reply with quote

Devilizer wrote:
Use a timer..?

Of course I know to use a timer, I need to know how you would do it though

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Dec 10, 2007 5:38 pm    Post subject: Reply with quote

You could do something like:

Code:
Private Function SetVariableArray(arrStart As Long, arrEnd As Long, arrValue As String)
    Dim x As Long
    For x = arrStart To arrEnd
        FlashObject.SetVariable "_root._game.towerArray." & x & ".damage", arrValue
    Next x
End Function


Or create a function with a parser to look for a given character to change with the number to make it work for basically any variable you sent to it to make it more "dynamic".

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Blader
I post too much
Reputation: 2

Joined: 19 Jan 2007
Posts: 2049

PostPosted: Mon Dec 10, 2007 5:39 pm    Post subject: Reply with quote

Wiccaan wrote:
You could do something like:

Code:
Private Function SetVariableArray(arrStart As Long, arrEnd As Long, arrValue As String)
    Dim x As Long
    For x = arrStart To arrEnd
        FlashObject.SetVariable "_root._game.towerArray." & x & ".damage", arrValue
    Next x
End Function


Or create a function with a parser to look for a given character to change with the number to make it work for basically any variable you sent to it to make it more "dynamic".


Ok I'll try it Razz

EDIT: It says argument not optional Confused
I don't really do modules, so I don't know if I'm doing something wrong

EDIT: Nvm, I fixed it, although it doesn't do anything

The code I'm using:
Code:
    Dim x As Long
    arrStart = 0
    arrEnd = 300
    For x = arrStart To arrEnd
        frmMain.flash1.SetVariable "_root._game.towerArray." & x & ".damage", txtDamage.Text
    Next x


EDIT AGAIN: Ok, lol, I forgot to put the quotes Rolling Eyes
Thanks for helping me, +rep Razz

_________________
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Mon Dec 10, 2007 6:49 pm    Post subject: Reply with quote

Use a variable instead of hardcoding the 0, 1, 2, 3, 4, etc.

In Delphi it would be like:
Code:

procedure xxxxxxxxx([i]parameters...[/i])
var
  i: Integer = 0
begin
  repeat
    begin
      _root._game.towerArray.i.damage
      // statements go here
     Inc(i);
    end;
  until
    i >= 100 // whatever max it is
end;
 


In VB, it would be different but you get the idea.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Dec 10, 2007 7:31 pm    Post subject: Reply with quote

Blader wrote:
Wiccaan wrote:
You could do something like:

Code:
Private Function SetVariableArray(arrStart As Long, arrEnd As Long, arrValue As String)
    Dim x As Long
    For x = arrStart To arrEnd
        FlashObject.SetVariable "_root._game.towerArray." & x & ".damage", arrValue
    Next x
End Function


Or create a function with a parser to look for a given character to change with the number to make it work for basically any variable you sent to it to make it more "dynamic".


Ok I'll try it Razz

EDIT: It says argument not optional Confused
I don't really do modules, so I don't know if I'm doing something wrong

EDIT: Nvm, I fixed it, although it doesn't do anything

The code I'm using:
Code:
    Dim x As Long
    arrStart = 0
    arrEnd = 300
    For x = arrStart To arrEnd
        frmMain.flash1.SetVariable "_root._game.towerArray." & x & ".damage", txtDamage.Text
    Next x


EDIT AGAIN: Ok, lol, I forgot to put the quotes Rolling Eyes
Thanks for helping me, +rep Razz


You got argument not optional because you forgot to pass one of the arguments when calling the function.

A proper call would be something like:

Code:
Call SetVariableArray( 0, 4, "100" )


Meaning the array starts at 0, ends at 4, and you want all the values to be 100.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Blader
I post too much
Reputation: 2

Joined: 19 Jan 2007
Posts: 2049

PostPosted: Mon Dec 10, 2007 7:33 pm    Post subject: Reply with quote

Yea, I forgot to set the strings Rolling Eyes
It's resolved now so no worries Razz

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming 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