NegativeNrG Posted November 29, 2005 Share Posted November 29, 2005 hey, im working on small piece of script. want i want to do is, i have a combobox, and a list of items "item1|etc" but how do i set the data on the items. Example ONLY.(not real) GUIcreate("this is not real",500,500) $combo = GUIctrlcreatecombo("",150,20,20,20) GUIctrlsetdata($combo,"item1|item2","item1") GUIsetstate(@SW_SHOW) while 1 ;stuff here: WEnd how do i set item1(in the combobox) to make it 200. so if the user clicks OK it will say something, then 200, depending on what the user picks, either item1 or 2. [size=20]My File Upload[/size]Register at my site and upload. Link to comment Share on other sites More sharing options...
Greenseed Posted November 29, 2005 Share Posted November 29, 2005 (edited) Look at this little file combo list box! the update is very simple! hope it help! the code is not originate by me! #include <GUIConstants.au3> $gui = GUICreate("File Dropdown",200,100) $combo = GUICtrlCreateCombo("Select a file...",40,40,120,20,$CBS_DROPDOWNLIST+$WS_VSCROLL) $dir = InputBox("Directory?","Enter a directory to search (no trailing backslash)") $ext = InputBox("Extension?","Enter a file extension to search for (without the dot)") $search = FileFindFirstFile($dir&"\*."&$ext) While 1 $i = FileFindNextFile($search) If @error <> 0 Then ExitLoop $b = StringSplit($i,".") If @error Then $a = $i Else $a = $b[$b[0]-1] endif GUICtrlSetData($combo,FileGetAttrib($i)&"-"&$a) WEnd FileClose($search) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd bye bye Edited November 29, 2005 by Greenseed GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. Link to comment Share on other sites More sharing options...
NegativeNrG Posted November 29, 2005 Author Share Posted November 29, 2005 Thanks but, i dont think thats what im looking for, ill make it clearer. i have a combobox. with sword|broadsword|potion and i want to set sword to $200 broadsword to $100 and potion to $50 then if the user chooses sword from the dropdown box, and clicks BUY it will check to see if the user has more or equal to $200, since Sword = $200. [size=20]My File Upload[/size]Register at my site and upload. Link to comment Share on other sites More sharing options...
Greenseed Posted November 29, 2005 Share Posted November 29, 2005 and now if i understand you correctely! this is the code i come with! i hope is help! #include <GUIConstants.au3> #Include <GuiCombo.au3> $gui = GUICreate("File Dropdown",200,100) $combo = GUICtrlCreateCombo("Select a file...",40,40,120,20,$CBS_DROPDOWNLIST+$WS_VSCROLL) $button = GUICtrlCreateButton("go",80,70,20,20) GUICtrlSetData($combo,"allo|salut|bonjours|aurevoir") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button _replacestringcombo("bonjours","bonjours-200$") EndSelect WEnd func _replacestringcombo($stringtoreplace,$newstring) local $_index $_index = _GUICtrlComboSelectString($combo,0,$stringtoreplace) _GUICtrlComboDeleteString($combo, 3) _GUICtrlComboInsertString($combo, 3 , $newstring) if not @error Then return 1 Else Return 0 EndIf endfunc and i hope i've understanding you correctely hehe bye bye GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. Link to comment Share on other sites More sharing options...
Greenseed Posted November 29, 2005 Share Posted November 29, 2005 are you making a game? GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. Link to comment Share on other sites More sharing options...
kpu Posted November 29, 2005 Share Posted November 29, 2005 This should get you started. Hope it helps! expandcollapse popup#include <GuiConstants.au3> GUICreate("MyGUI", 444, 83, (@DesktopWidth - 444) / 2, (@DesktopHeight - 83) / 2) Dim $player1Money $Combo_1 = GUICtrlCreateCombo("Choose Item", 20, 20, 290, 21) GUICtrlSetData(-1, "sword|broadsword|potion", "") $Button_2 = GUICtrlCreateButton("Check", 330, 20, 100, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $Button_2 _CheckData() Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func _CheckData() $uData = GUICtrlRead($Combo_1) If $uData = "Choose Item" Then MsgBox(16, "What the??", "Do you know what your doing? Pick an item before to pressing the button") ElseIf $uData = "sword" Then MsgBox(32, "Cost", "That will cost you $200") _Sword() ElseIf $uData = "broadsword" Then MsgBox(32, "Cost", "That will cost you $100") ;_Broadsword ElseIf $uData = "potion" Then MsgBox(32, "Cost", "That will cost you $50") ;_Potion() EndIf EndFunc ;==>_CheckData Func _PlayerMoney() ;whatever here $player1Money = "100" EndFunc ;==>_PlayerMoney Func _Sword() _PlayerMoney() If $player1Money < "200" Then MsgBox(16, "Money", "You have " & $player1Money & " It costs $200") ElseIf $player1Money >= "200" Then MsgBox(32, "Okay", "You have the money") EndIf EndFunc ;==>_Sword http://www.kpunderground.com Link to comment Share on other sites More sharing options...
Greenseed Posted November 29, 2005 Share Posted November 29, 2005 when i look at kpu example i see i was wrong hehe my english still need working! but now i understand! hehe! i sugest you defini all Item like this! Dim $Item[HowManyItemYouWan][6] $Item[0][0]="0001" ; Item ID , in first for faster search $Item[0][1]="Sword" ; Item Class can be Sword, Hammer, Axe, Longbow, ect... $Item[0][2]="1" ; level: 1 to maybe 99 $Item[0][3]="LegendarySword" ; Name Of the Item $Item[0][4]="200" ; Cost $Item[0][5]="15" ; Hitpoint and you do some thing same for the player Dim $Player[HowManyPlayerAreSaved][5] $Player[0][0]="Greenseed" ;PlayerName And Save Identification $Player[0][1]="dexxa" ; player password $Player[0][2]="1" ; player level $Player[0][3]="600" ; player gold $Player[0][4]="2345" ; Player experience $Player[0][5]="100" ; Player Health $Player[0][6]="30" ; HitPoint $Player[0][7]="12" ; DefencePoint $Player[0][8]=$Item[0][0] ; Player Weapon $Player[0][9]=$Item[3][0] ; Player Armor $Player[0][10] to $Player[0][Any] continue for the rest of item like potion or amulet! before displaying item you check if item are <= to the player level! and to enable buy you check if item cost or <= with the player cash! this is just a example idea! i think! the idea can be good for big and small game! it will be easier to keep track of object in game! all the variable position must stay same! you know in $Item[$x][4] it will always be the cost of the item! GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. Link to comment Share on other sites More sharing options...
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