Author Topic: Needing help with learning to script  (Read 4159 times)

0 Members and 1 Guest are viewing this topic.

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Needing help with learning to script
« on: December 13, 2015, 02:02:10 PM »
+1
I have been looking and looking trying to read as much as possible but I am still either dumb or blind. I saw that someone was willing to help people start learning to script with a small script where you pick a chest or crate in ur house and drag and item like a sword to the chest. would anyone be willing to spare sometime and let me try and get this to work and maybe help me along in my scripting career. I would really like to contribute something even if it is just some knowledge of what I learn on the way if I never become really good at it.

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #1 on: December 13, 2015, 02:15:10 PM »
+1
This is what I got so far
Code: [Select]
finditem WW ; the weapon type
if #FINDCNT > 0
{
            Exevent Drag #findID   ; finding the weapon and picking it up
            wait 10
            Exevent Dropc #CONTID PEDWYND    ; dropping it into the container of choice
            wait 10
halt
}


Online Crisis

  • Elite
  • *
  • *
  • Posts: 1902
  • Activity:
    6.6%
  • Reputation Power: 28
  • Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +186
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #2 on: December 13, 2015, 03:22:36 PM »
+1
This is quick and basic and I cannot check it but it should give you an idea to get you going

Code: [Select]
set %weapon WW
set %secure PEDWYND

finditem %weapon C_ , #backpackid
if #FINDCNT > 0
for #findindex 1 #findcnt
  {
    exevent drag #findid
    exevent drop %secure
  }
return

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #3 on: December 13, 2015, 04:11:08 PM »
+1
Ok cool just trying to learn and that is what he was offering kind of teaching I got it to work the way I did but ur way looks so much easier and nicer than mine

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #4 on: December 13, 2015, 05:04:10 PM »
+1
just tried yours out something weird is going on with it the weapon disappears until I log out an back in

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #5 on: December 13, 2015, 05:05:11 PM »
+1
and could u point to another easy script to try so I can see if I can figure it out. it would be much appreciated

Online Crisis

  • Elite
  • *
  • *
  • Posts: 1902
  • Activity:
    6.6%
  • Reputation Power: 28
  • Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +186
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #6 on: December 13, 2015, 06:35:50 PM »
+1

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #7 on: December 13, 2015, 06:40:45 PM »
+1
ok will do ill start on it tomorrow when I get off work and I will post and see if u can help me if you don't mind

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #8 on: December 14, 2015, 03:57:48 PM »
+1
ok so I started looking in there and the code I have to start with is this

Code: [Select]
finditem * C_ , #BACKPACKID
if #FINDCNT > 0
{
 display ok There are #FINDCNT items in your backpack!
}
if #FINDCNT < 1
{
 display ok No items were found in your backpack!
}
halt

it is telling me what how many items I have in my bag now from there I need to figure out what command will drag and drop which I have that already with exevent drag command and exevent dropc command but where do I put those and am I going to have to write a gosub and if so how do I do that is it like this
Code: [Select]
gosub remove items

sub remove it
     Exevent drag #findID
     wait 5s
     Exevent dropc #CONTID
     wait 5s

Offline MeWonUo

  • Hero Member
  • *
  • Posts: 905
  • Activity:
    0%
  • Reputation Power: 10
  • MeWonUo barely matters.MeWonUo barely matters.
  • Gender: Male
  • Respect: +84
  • Referrals: 0
    • View Profile
Re: Needing help with learning to script
« Reply #9 on: December 15, 2015, 11:48:08 AM »
+1
I would recommend a sub for your item movement. 

Through the teachings of many around here over the years I've found that breaking your scripts up into small pieces makes them more efficient and a lot easier to debug when you run into a little hangup. Not to mention you then have a sub library (Thx EN)  that you can reference on your next project.  No need to write something multiple times if you can do it just once.

You might play around with something along these lines:

Code: [Select]
repeat
 finditem LOL C_ , #BACKPACKID
  if #FINDCNT > 0
    gosub MoveIt
until #FINDCNT < 1
halt

sub MoveIt
 ;; Your drag and drop commands go in here.
return  ;; < Always remember to return out of your subs.

 Use F7 to step through your scripts one line at a time so you can see how it works.


Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #10 on: December 15, 2015, 05:38:54 PM »
+1
so this is what I got so far I get it to open my paperdoll then open my back pack and it will even attempt to take something out of my bag but then puts it right back in there so it never does the exevent dropc part. so do I have to manually set and #contid for it or is there a way to set it up with out that where it will find it. and or can I set up another event macro for that. and then it keeps trying to drag same item so does the have to be something else besides #findid #findstack
Code: [Select]
event macro 8 1
wait 5s
event macro 8 7
wait 5s

FINDITEM * C_ , #backpackID
if #FINDCNT > 0
    gosub MoveIt
until #FINDCNT < 1
halt

sub MoveIt
 exevent drag #findid #findstack
 wait 10
 exevent dropc #contid
 wait 10
repeat


now I could have a
set %secure XXXXX setup for my exevent dropc but do I need that
« Last Edit: December 15, 2015, 05:58:45 PM by cybercasper »

Online Crisis

  • Elite
  • *
  • *
  • Posts: 1902
  • Activity:
    6.6%
  • Reputation Power: 28
  • Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.Crisis is on the verge of being accepted.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +186
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #11 on: December 15, 2015, 06:13:48 PM »
+1
The #findStack system variable contains the number of stacked items in the object returned by findItem. You won't want to use it for a weapon, it is used for stacked items like ingots, ore, bandgaes, regs, etc.

set %secure XXXXXX tells the script which container to put the item in. In yours, you are not identifying what container to drop it in.

The EUO Wiki will really help you learn some of the different commands. http://wiki.easyuo.com/index.php?title=Documentation

I would also look at the tutorials on EUO http://www.easyuo.com/forum/viewforum.php?f=9  and here on SUO. http://www.scriptuo.com/index.php?board=17.0
« Last Edit: December 15, 2015, 06:16:15 PM by Crisis »

Offline MeWonUo

  • Hero Member
  • *
  • Posts: 905
  • Activity:
    0%
  • Reputation Power: 10
  • MeWonUo barely matters.MeWonUo barely matters.
  • Gender: Male
  • Respect: +84
  • Referrals: 0
    • View Profile
Re: Needing help with learning to script
« Reply #12 on: December 15, 2015, 06:46:18 PM »
+1
I think Crisis hit this one right on the head.  Check the EUO resources and I think you will get it figured out.

Setting your container somewhere in there is generally if not always a good idea for easy reference.

Sounds like you're trying to do a fairly simple, get something + move it here = make money kinda script.

The examples provided in the thread here should be more than enough to easily get it figured out.  I'm sure you can do it.

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #13 on: December 16, 2015, 03:20:31 PM »
+1
ok I got everything to finally work and what is the reason I use * after finditem I could find out why except for it is a semicolon. and would there be any other way to write it besides how I did. I know MeWonUo said always return out of sub but on this I put repeat should I have done something else.
Code: [Select]
set %chest CUABDSD ;This would be set to XXXXXXX so anyone could set there own container

event macro 8 1 ; take this out if u don't want to open paperdoll each time
wait 5s              ; could change wait to 20
event macro 8 7 ;opens backpack
wait 5s              ;change to wait 20

FINDITEM * C_ , #backpackID
if #FINDCNT > 0
    gosub MoveIt
until #FINDCNT < 1
 {
  display ok No items were found in your backpack!
 }
halt

sub MoveIt
 exevent drag #findID #findstack
 wait 10
 exevent dropc %chest
 wait 10
repeat
« Last Edit: December 16, 2015, 03:25:24 PM by cybercasper »

Offline cybercasperTopic starter

  • Full Member
  • ***
  • Posts: 218
  • Activity:
    0.2%
  • Reputation Power: 3
  • cybercasper has no influence.
  • Respect: +39
  • Referrals: 1
    • View Profile
Re: Needing help with learning to script
« Reply #14 on: December 16, 2015, 03:28:15 PM »
+1
and please can someone give me something else I can try so I can keep progressing maybe something that I could start like a step by step one so I can do one and then build on it

Tags: