Jump to content
UBot Underground

addamroy

Fellow UBotter
  • Content Count

    386
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by addamroy

  1. The code is just OK (http://screencast.com/t/XGWjyFGuhp), so no need to change it before you test it....actually I would give you an advice...save the code while it's working, so you can fall back when it stops....

     

    However, use the exact code that I've used, but before starting it make sure that JavaScript or JQuery is loaded in browser...so just navigate to Google for example before you do that.

     

    Ahhh.  That worked, I ran all that code in a 'new browser window' and it freakin worked!  Thanks man!

     

    I'm thinkin I may not even need to navigate anywhere because javascript is always enabled in the uihtml panel, probably just not enabled until you compile the bot (I as testing the node in ubot, which is probably why I had to navigate to make the functions work)

     

    Thanks again I appreciate the help.

     

    Adam.

  2. I also tried adding that Javascript within the HEAD tags of the UIHTML panel, rather than in a run javascript function, then put the set commands in a define command.  I ran the define command and according to the debugger it still didn't want to set the R G and B values.

     

    This is the javascript as it's entered in the HEAD tags;  (I have to add javascript to the UIHTML via pre-set variables because the {} symbols break any variables used in the UI HTML panel.)

     

    set(#HexToRGBJavascript, "<script>
    function hexToR(h) \{return parseInt((cutHex(h)).substring(0,2),16)\}
    function hexToG(h) \{return parseInt((cutHex(h)).substring(2,4),16)\}
    function hexToB(h) \{return parseInt((cutHex(h)).substring(4,6),16)\}
    function cutHex(h) \{return (h.charAt(0)==\"#\") ? h.substring(1,7):h\}
    </script>", "Global")
     

     

    My test define is as follows:

     

    define Hex to RGB {
        set(#COLOR Hex, "ff8800", "Global")
        set(#COLOR R, $eval("hexToR(\"{#COLOR Hex}\");"), "Global")
        set(#COLOR G, $eval("hexToG(\"{#COLOR Hex}\");"), "Global")
        set(#COLOR B, $eval("hexToB(\"{#COLOR Hex}\");"), "Global")
    }
     

     

    What am I doing wrong?

  3. If you would at least try to do what I have told you, I'm sure you would already have a solution. There is actually no javascript knowledge needed  to implement this (since you only need to copy the script from one of those pages and you only need to know that a (JavaScript) function returns a value, which is true for all of the programming languages btw), so it's mostly UBot knowledge that's left.

     

    It looks like you don't have any desire to learn this, so I'll just post an example for you (although I think it would be better if you would get to these results on your own, since that way you would learn something and remember that for always):

    run javascript("function hexToR(h) \{return parseInt((cutHex(h)).substring(0,2),16)\}
    function hexToG(h) \{return parseInt((cutHex(h)).substring(2,4),16)\}
    function hexToB(h) \{return parseInt((cutHex(h)).substring(4,6),16)\}
    function cutHex(h) \{return (h.charAt(0)==\"#\") ? h.substring(1,7):h\}")
    ui text box("COLOER Hex:", #COLOER Hex)
    set(#COLOR R, $eval("hexToR(\"{#COLOER Hex}\");"), "Global")
    set(#COLOR G, $eval("hexToG(\"{#COLOER Hex}\");"), "Global")
    set(#COLOR B, $eval("hexToB(\"{#COLOER Hex}\");"), "Global")

    The JavaScript snippet used above can be found here: http://www.javascripter.net/faq/hextorgb.htm

     

    It's not at all that i don't want to learn, I've been trying to pick apart codes for almost 7 days now, to no avail.  And have been using Ubot since it's inception, and can do some failry advanced.  It is not my effort, it is my lack of knowledge of javascript.  And I hadn't noticed that you had already posted that code.

     

    I copied and pasted your code as so.

     

    ui text box("COLOER Hex:", #COLOER Hex)

     

    define hex to rgb {

        run javascript("function hexToR(h) \{return parseInt((cutHex(h)).substring(0,2),16)\}

    function hexToG(h) \{return parseInt((cutHex(h)).substring(2,4),16)\}

    function hexToB(h) \{return parseInt((cutHex(h)).substring(4,6),16)\}

    function cutHex(h) \{return (h.charAt(0)==\"#\") ? h.substring(1,7):h\}")

        set(#COLOR R, $eval("hexToR(\"{#COLOER Hex}\");"), "Global")

        set(#COLOR G, $eval("hexToG(\"{#COLOER Hex}\");"), "Global")

        set(#COLOR B, $eval("hexToB(\"{#COLOER Hex}\");"), "Global")

    }

     

     

    It doesn't set any of the RGB values for some reason when I run the define. :(

  4. I have found the botters on this forum are usually very helpful.

    I suggest that you post more technical details about the issues you are grappling with and see what happens.

    Most of the time when I see people here not making progress here it is when they don't post enough details.

    Give specific questions and get specific answers.

    Do you have a JavaScript you would like to convert into UBOT?

     

    Yea, I'm not the best explainer of my issues lol.

     

    My specific question is:  How to convert a variable whose value is a hex code, to the RGB form of that samehex value.

     

    Example, if #colorA has a value of #ff8800, the script would change that value would become 255,136,0.  Now #colorA would have a value of 255,136,0 instead of #ff8800

  5. I've been trying for like a week lol.

     

    I went through all the Google searches, but being someone who is not knowledgable in Javascript enough to pick apart the scripts and put them back together puts me at a blank.

     

    I mean none of those scripts set ubot variables, which would be the most important aspect and unfortunately I don't know how to get those javascript snippets to set Ubot variables (or retrieve the existing variables that need to be converted), especially since I have many separate input fields that need to be converted.

  6. I'm looking for a hopefully simple way to convert a variable's value from a HEX value, to it's RGB equivalent. 

     

    IE if user inputs #ff8800 in the input field, let's say #colorA. I want to automatically convert that to it's RGB value.  In this case, #colorA would automatically become 255,136,0  which is the RGB value for the above Hex.

     

    I know there are various equations out there but I haven't the slightest clue how to get them into uBot and make them work for this.

  7. If you want it to show up in UI HTML than you'll have to use JavaScript+HTML (as mentioned above for example). I think the plugin only provides a popup.

     

    That's how I'm doing it.  I have onclick javascript executing the define functions which run the color picker.

  8.  

    That's what I did.  It's a workaround for now.

     

    I wanted to avoid creating a define command for each field.  (I have to use defines, because I am NOT using a ui button to display the picker)  I was hoping to just attach the color picker dialogue to the TEXT INPUT fields themselves.  So instead, I have a 'select color' text link under each input field, which prompts the color picker dialogue, then sets the variable for the input field, which then populates the input field with the hex code for that color.

     

    However now that I discovered this bug that doesn't let you close or cancel the color picker dialogue without it setting the value to #000000  I have another headache obstacle to work around.

  9. How do I get the file management color picker dialogue into UIHTML buttons, rather than the standard UI buttons?

     

    @Traffikcop, yes I tried that, but I have many input fields that need a color choice, so using defines and set commands for each individual field I have is just not efficient at all.

  10. set(#testgetfiles, $get files("{$special folder("Application")}\\images", "No"), "Global")

     

    I said before you need to change that NO to a YES!!  http://www.ubotstudio.com/forum/index.php?/topic/16789-why-do-i-get-an-error-with-get-files/&do=findComment&comment=100666

     

    set(#testgetfiles, $get files("{$special folder("Application")}\\images", "Yes"), "Global") :)

     

    in the get files node there is a drop down

     

    under the file path...the second input field

     

    include path Yes/No

     

    that means to include the file path special folder("Application")}\\images

     

    TC

     

    PS

     

    make sure you have some files in there too :rolleyes:

     

    Setting that to "YES" does not include the extra file path, it includes the full file-path of the files in the folder.

     

    IE full path YES displays getfiles results as, C:\\path\to\files\image.jpg

     

    full path NO displays getfiles results as, image.jpg

     

    So again, that does not work.  And regardless, if I have it set to YES or NO, it does not work.

     

    Did you try that code yourself or just put it into Ubot and assumed that it works?

×
×
  • Create New...