gianfun Posted May 27, 2008 Posted May 27, 2008 Hi people! So, i'm doing this little "map maker" for a little game im going to try and make (lol) So, I've made labels, which will be the tile. The radio's will define what colour will be "chosen" to colour the label, then when a label is clicked, it would change colour. Heres the script: expandcollapse popup#include<guiconstants.au3> opt("guioneventmode",1) opt("guicloseonesc",1) global $map[10][10], $color guicreate("Map Maker", 400,400) GUISetOnEvent($gui_event_close, "bye") for $x = 1 to 9 for $y = 1 to 9 $map[$x][$y] = GUICtrlCreateLabel("", 16*$x + 35,16*$y + 35,15,15) GUICtrlSetOnEvent(-1,"color") GUictrlSetStyle($map[$x][$y],$ss_center) GUICtrlSetBkColor(-1, "0x000000") next next GUICtrlCreateLabel("", 240, 43, 15,15) GUICtrlSetBkColor(-1, 0x00ff00) $grasstool = GUICtrlCreateRadio("Grass",260,40) GUICtrlSetOnEvent($grasstool,"settool") GUICtrlCreateLabel("", 240, 63, 15,15) GUICtrlSetBkColor(-1, 0x804000) $roadtool = GUICtrlCreateRadio("Road",260,60) GUICtrlSetOnEvent($roadtool,"settool") GUICtrlCreateLabel("", 240, 83, 15,15) GUICtrlSetBkColor(-1, 0xe2e2e5) $Buildingtool = GUICtrlCreateRadio("Building",260,80) GUICtrlSetOnEvent($Buildingtool,"settool") GUICtrlCreateLabel("", 240, 103, 15,15) GUICtrlSetBkColor(-1, 0x00ffff) $portaltool = GUICtrlCreateRadio("Portal",260,100) GUICtrlSetOnEvent($portaltool,"settool") guisetstate() func settool() MsgBox(0,"hi",$color) if guictrlread($grasstool) = 1 then $color = 0x00ff00 if guictrlread($roadtool) = 1 then $color = 0x804000 if guictrlread($Buildingtool) = 1 then $color = 0xe2e2e5 if guictrlread($portaltool) = 1 then $color = 0x00ffff EndFunc func color() GUICtrlSetBkColor($map,$color) EndFunc func bye() Exit EndFunc while 1 WEnd I would like to know if there is a way for the func color to find out which label i clicked. Thanks in advance! My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote]
SadBunny Posted May 27, 2008 Posted May 27, 2008 (edited) For really cool functions for all kinds of image manipulation, check out prospeed, as for instance described here:http://www.autoitscript.com/forum/index.php?showtopic=71654It both can greyscale and compare for you, or so it seems. The grayscaling works fine, I used it, the compare I have never used but it seems to work too, and fast.Sorry, in some WEIRD way this posted this as reply to the wrong topic... Edited May 27, 2008 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
SadBunny Posted May 27, 2008 Posted May 27, 2008 Anyway, a possibly more useful answer: if you create labels and assign the result of the creation to a variable, you can just check which one was clicked by GuiGetMsg(). Is this about what you need? HotKeySet("{ESC}", "_quit") $gui = GUICreate("test", 600, 400) $l1 = GUICtrlCreateLabel("test1", 10, 10, 300, 50) $l2 = GUICtrlCreateLabel("test2", 10, 100, 300, 50) GUICtrlSetBkColor($l1, 0xFF0000) GUICtrlSetBkColor($l2, 0x00FF00) GUISetState() While 1 Sleep(10) $msg = GUIGetMsg() If $msg=$l1 Then MsgBox(0,0,"The red label was clicked") If $msg=$l2 Then MsgBox(0,0,"The green label was clicked") WEnd Func _quit() Exit EndFunc ;==>_quit Roses are FF0000, violets are 0000FF... All my base are belong to you.
gianfun Posted May 27, 2008 Author Posted May 27, 2008 nah, wont work. Its on the "guioneventmode" option. Guigetmsg() doesnt go and its arrays. I would like the function to see what array had been clicked... Is that even possible? My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote]
SadBunny Posted May 27, 2008 Posted May 27, 2008 Now I don't mean to nag, but how can you click an array? You want to click some graphical element, right? Possibly you could get the mouse position, and then determine what color is present on that pixel coordinate. Roses are FF0000, violets are 0000FF... All my base are belong to you.
rambo3889 Posted May 27, 2008 Posted May 27, 2008 @GUI_CtrlId. My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youre the best in town Fight!
SadBunny Posted May 27, 2008 Posted May 27, 2008 @GUI_CtrlId.Or that ofcourse! Just like always, I took 3 right turns instead of 1 left Roses are FF0000, violets are 0000FF... All my base are belong to you.
gianfun Posted May 28, 2008 Author Posted May 28, 2008 hum... I tried it several ways, but just couldn't make it work. Clicking the labels isn't even calling the function... So now my problem is why? arrays i guess... expandcollapse popup#include<guiconstants.au3> opt("guioneventmode",1) opt("guicloseonesc",1) global $map[10][10], $color = 0x00ffff guicreate("Map Maker", 400,400) GUISetOnEvent($gui_event_close, "bye") for $x = 1 to 9 for $y = 1 to 9 $map[$x][$y] = GUICtrlCreateLabel("", 16*$x + 35,16*$y + 35,15,15) GUICtrlSetOnEvent($map[$x][$y],"color") GUictrlSetStyle($map[$x][$y],$ss_center) GUICtrlSetBkColor(-1, 0xff0000) next next GUICtrlCreateLabel("", 240, 43, 15,15) GUICtrlSetBkColor(-1, 0x00ff00) $grasstool = GUICtrlCreateRadio("Grass",260,40) GUICtrlSetOnEvent($grasstool,"settool") GUICtrlCreateLabel("", 240, 63, 15,15) GUICtrlSetBkColor(-1, 0x804000) $roadtool = GUICtrlCreateRadio("Road",260,60) GUICtrlSetOnEvent($roadtool,"settool") GUICtrlCreateLabel("", 240, 83, 15,15) GUICtrlSetBkColor(-1, 0xe2e2e5) $Buildingtool = GUICtrlCreateRadio("Building",260,80) GUICtrlSetOnEvent($Buildingtool,"settool") GUICtrlCreateLabel("", 240, 103, 15,15) GUICtrlSetBkColor(-1, 0x00ffff) $portaltool = GUICtrlCreateRadio("Portal",260,100) GUICtrlSetOnEvent($portaltool,"settool") GUICtrlSetBkColor($map[1][1], 0x00ffff) guisetstate() func settool() MsgBox(0,"hi",$color) if guictrlread($grasstool) = 1 then $color = 0x00ff00 if guictrlread($roadtool) = 1 then $color = 0x804000 if guictrlread($Buildingtool) = 1 then $color = 0xe2e2e5 if guictrlread($portaltool) = 1 then $color = 0x00ffff EndFunc func color() MsgBox(0,"test","test2") GUICtrlSetBkColor(@GUI_CtrlId ,$color) EndFunc func bye() Exit EndFunc while 1 sleep(10) $msg = GUIGetMsg() if $msg = $map[1][1] then MsgBox(0,"test,","test1") WEnd My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote]
enaiman Posted May 29, 2008 Posted May 29, 2008 Try this: expandcollapse popup#include<GuiConstants.au3> opt("guioneventmode",1) opt("guicloseonesc",1) global $map[10][10], $color = 0x00ffff guicreate("Map Maker", 400,400) GUISetOnEvent($gui_event_close, "bye") for $x = 1 to 9 for $y = 1 to 9 $map[$x][$y] = GUICtrlCreateLabel("", 16*$x + 35,16*$y + 35,15,15) GUICtrlSetOnEvent($map[$x][$y],"color") ;GUictrlSetStyle($map[$x][$y],$ss_center) - Useless, it creates all your problems GUICtrlSetBkColor(-1, 0xff0000) next next GUICtrlCreateLabel("", 240, 43, 15,15) GUICtrlSetBkColor(-1, 0x00ff00) $grasstool = GUICtrlCreateRadio("Grass",260,40) GUICtrlSetOnEvent($grasstool,"settool") GUICtrlCreateLabel("", 240, 63, 15,15) GUICtrlSetBkColor(-1, 0x804000) $roadtool = GUICtrlCreateRadio("Road",260,60) GUICtrlSetOnEvent($roadtool,"settool") GUICtrlCreateLabel("", 240, 83, 15,15) GUICtrlSetBkColor(-1, 0xe2e2e5) $Buildingtool = GUICtrlCreateRadio("Building",260,80) GUICtrlSetOnEvent($Buildingtool,"settool") GUICtrlCreateLabel("", 240, 103, 15,15) GUICtrlSetBkColor(-1, 0x00ffff) $portaltool = GUICtrlCreateRadio("Portal",260,100) GUICtrlSetOnEvent($portaltool,"settool") GUICtrlSetBkColor($map[1][1], 0x00ffff) guisetstate() func settool() MsgBox(0,"hi",$color) if guictrlread($grasstool) = 1 then $color = 0x00ff00 if guictrlread($roadtool) = 1 then $color = 0x804000 if guictrlread($Buildingtool) = 1 then $color = 0xe2e2e5 if guictrlread($portaltool) = 1 then $color = 0x00ffff EndFunc func color() ;MsgBox(0,"test","test2") GUICtrlSetBkColor(@GUI_CtrlId ,$color) EndFunc func bye() Exit EndFunc while 1 sleep(10) ;got rid of your other lines of script - bad idea to mix modes WEnd That Style thing messed your script. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
gianfun Posted May 29, 2008 Author Posted May 29, 2008 Yay!! thanks!! it worked now!! and yeah, i know it is a bad idea to mix modes, it had been one of the attempts to make it work which i forgot to take out XD My own pocket emo http://www.mindistortion.net/pocketemo/?da...1-7-2-0-0-1-0-0LOL[quote name='beerman' post='399180' date='Sep 6 2007, 08:45 AM']I have learned, never think inside the box. The moment you have a bright idea, and stand up to quickly exclaiming, "Eureka, I have it!". You will knock yourself out, from bashing your head on the inside of the box as you stand... So in conclusion it is always safer to think outside the box. :)[/quote]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now