Jump to content
  • Sign Up
Sign in to follow this  
Nironior

LoadRGB giving same values on different pictures

Recommended Posts

Hey, I've been having a weird problem with LoadRGB. I'm making a script for Gems of war (a match-3 game) which keeps matching gems until one of my four spells is ready and then casts one of the spells. The script is able to detect when a spell is ready because a picture changes entirely when it is ready to cast, so i constantly check the values with LoadRGB and override the normal script when the picture changes. 

Here's the weird thing, It works perfectly for two of the four spells, namely the top two in the screen. But the last two spells, even though the pictures change completely, keep outputting the exact same color values on every pixel (i've tried it on more than hundred pixels, all yield the same values).

 

Here's a screenshot of the game to clarify my problem:
JMzIlVd.jpg

 

The second picture which is circled in green does yield different values when the picture changes.

The last one (which is circled red) does not output different values as you can see in my Notepad, even though those pictures are different.

Does anyone have an idea how this is possible?
My only theory is that for the last spell, LoadRGB somehow values the background instead of the picture itself.

But that would be strange for several reasons, most of all that it does not do that for the spell/picture which is circled in green.

Share this post


Link to post
Share on other sites

After some more testing I found out that I was lucky with getting values on the first two spells.

It seems that on each picture there is only a small range in which LoadRGB actually reads the values of the picture itself and not the background.

These are the values on ten adjacent pixels i got when testing the values on the second spell again:

29 and 114 and 255 op 228 362        29 and 114 and 255 op 228 362        Same
29 and 114 and 255 op 227 362        29 and 114 and 255 op 227 362        Same
29 and 114 and 255 op 226 362        29 and 114 and 255 op 226 362        Same
29 and 114 and 255 op 225 362        29 and 114 and 255 op 225 362        ,,
29 and 114 and 255 op 224 362        29 and 114 and 255 op 224 362        ,,
29 and 114 and 255 op 223 362        29 and 114 and 255 op 223 362        ,,
29 and 114 and 255 op 222 362        28 and 110 and 247 op 222 362        Different
29 and 114 and 255 op 221 362        25 and 97 and 215 op 221 362          Different
29 and 114 and 255 op 220 362        6 and 23 and 52 op 220 362              Different
29 and 114 and 255 op 219 362        4 and 8 and 28 op 219 362                Different
 
Do you guys think that my theory is correct?
("It seems that on each picture there is only a small range in which LoadRGB actually reads the values of the picture itself and not the background.")

Share this post


Link to post
Share on other sites

With no code I would only be guessing.

 

So one way I can think of is make objects, a bit slower in reading the colours, but more control over what it is looking for.

Share this post


Link to post
Share on other sites

Could try something like this.

I don't know what's in your code so can only put up an example that I use.

 

call getcolor 1024, 681 // Change to suit.

//XXXXXXXXXXXXXXXXXXXXXXXXXXXX  Get Colour  XXXXXXXXXXXXXXXXXXXXXXX
Procedure GetColor using X, Y
  LoadRGB $X, $Y
  Set Red   = {RGBRed}
  Set Green = {RGBGreen}
  Set Blue  = {RGBBlue}
  timestamp RGB Colour is Red-$red, Green-$green, Blue-$blue.
End
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

constants
  red        = 0
  green    = 0
  blue      = 0
End
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Procedure spin

 Is(color) 1024, 681

  do something

  else

  do something else

 end

End

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Share this post


Link to post
Share on other sites

Thanks for replying again!

That is exactly the code I'm using, except for the timestamp command. To get the RGB values I added this procedure:

Procedure ShowColor using A, B
  LoadRGB $A, $B
  SetConst Red   = {RGBRed}
  SetConst Green = {RGBGreen}
  SetConst Blue  = {RGBBlue}
  saypaste $Red and $Green and $Blue op $A $B
End

But it is still a mystery to me because I'm using the same script on two laptops, and on one laptop I can get the correct values for the last picture (meaning that the values change when that picture changes), but on my main laptop the values won't change in that area even if it is an entirely different picture within the game  :( 
So it's not so much as an error in the script i guess, but more of a weird setting or something that I'm not aware of

Share this post


Link to post
Share on other sites

All good. I use the getcolor to find the rgb then its not used again as I have what I need.

Then by calling spin at the x,y coords, if the correct color is there do something, if not do something else.

 

Not sure why laptops are different, my macros for my game work on any laptop as well as my home tower comp and 2 tower comps at the library where I work.

Could be the color difference between video cards on the different laptops. Just guessing.

 

Try

 

ObjVar 3

call spin

procedure spin

isobject at x, y

do something

end

 

object maker.zip

 

The object maker code is simple, add your name to line 5, 7.

Line 9 C:\objects\Av2.mac (replace C:\objects\ to where you want) Av2.mac (Rename Av2 to same as lines 5 and 7) Must have .mac on the end.

line 11 and 12 is the coords

line 14 and 15 is the size

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...