Author Topic: Question about %0  (Read 2991 times)

0 Members and 1 Guest are viewing this topic.

Offline UoLugnutzTopic starter

  • Full Member
  • ***
  • Posts: 123
  • Activity:
    0%
  • Reputation Power: 2
  • UoLugnutz has no influence.
  • Respect: +25
  • Referrals: 0
    • View Profile
Question about %0
« on: February 17, 2010, 07:11:36 AM »
0
I'm just in the middle of writing my first script and would like to add a few snippets. Why re event the wheel but I don't want to use them until I understand completely what I am using. An example is I want to make sure my backpack is open and if it is not open to open it to a set position. TM has this snippet that works perfect

Code: [Select]
gosub TM_CheckBackpack  200 200

sub TM_CheckBackpack
  namespace push
  namespace local CP
  set !cnt %0
  set !x %1
  set !y %2
  finditem * C_ , #BACKPACKID
  if #FINDKIND = -1
  {
    event macro 8 7 ; open backpackid
    gosub GumpAndSizeWait container_gump 230_204
    if !cnt > 0
    {
      contpos !x !y
      wait 10
    }
  }
  namespace pop
return

Its the
Code: [Select]
set !cnt %0 line. What is the value of %0? I used the search button but didn't find what I was looking for. Thanks in advance!


« Last Edit: February 17, 2010, 12:14:32 PM by UoLugnutz »

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Question about %0
« Reply #1 on: February 17, 2010, 07:26:56 AM »
0
It's how many arguments your sending to the sub...

gosub somesubroutine one two three four five

that would result a %0 of 5 because you sent 5 arguments to the sub.

gosub somesubroutine cerv really rox

that would result in %0 being 3 because of the 3 arguments sent.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Question about %0
« Reply #2 on: February 17, 2010, 07:27:12 AM »
0
%0 is the value of the number of criteria you send a sub. For example if you say:

Code: [Select]
gosub sub1 %Value %Value2 %Value3
you are sending three values thus %0 = 3

Hope that helps.

X

<edit> I see Cerv beat me to it LOL. Oh well, there's two examples for ya!
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Question about %0
« Reply #3 on: February 17, 2010, 07:29:27 AM »
0
He so sloooow... heh

Quote from: EasyUO Docs
gosub

The gosub command transfers the execution to a sub with the name given by the parameter.

gosub sub_name

Parameters can be added after the sub name. They will be transfered in the variables %1, %2, and so on. The variable %0 holds the number of parameters passed.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Question about %0
« Reply #4 on: February 17, 2010, 07:31:53 AM »
0
LOL, ahhh parameters was the word I was having a hard time thinking of so I said values. Feels like a Monday.

When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Question about %0
« Reply #5 on: February 17, 2010, 07:35:08 AM »
0
See I learned them as arguments.

Quote from: Dictionary
9.    Computers. a variable in a program, to which a value will be assigned when the program is run: often given in parentheses following a function name and used to calculate the function.

Quote from: Some script thingy
#  Within the script, we refer to the first argument as $1, the second argument as $2, and so on

XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline UoLugnutzTopic starter

  • Full Member
  • ***
  • Posts: 123
  • Activity:
    0%
  • Reputation Power: 2
  • UoLugnutz has no influence.
  • Respect: +25
  • Referrals: 0
    • View Profile
Re: Question about %0
« Reply #6 on: February 17, 2010, 08:22:51 AM »
0
Thanks for the quick response. I kinda thought that is what it was but was stumped by the
Code: [Select]
If !cnt > 0 line. Since !cnt is set to 2 it will always be greater then 0. When will it ever fail? If it can never fail why have it?
« Last Edit: February 17, 2010, 12:16:18 PM by UoLugnutz »

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Question about %0
« Reply #7 on: February 17, 2010, 08:32:12 AM »
0
Because one could call the sub with no arguments thus the backpack would still get opened but not moved to !x !y.

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline UoLugnutzTopic starter

  • Full Member
  • ***
  • Posts: 123
  • Activity:
    0%
  • Reputation Power: 2
  • UoLugnutz has no influence.
  • Respect: +25
  • Referrals: 0
    • View Profile
Re: Question about %0
« Reply #8 on: February 17, 2010, 08:46:07 AM »
0
Because one could call the sub with no arguments thus the backpack would still get opened but not moved to !x !y.

X

Fug me! That almost seems obvious. Need to stop thinking of the specific use of the sub I could use it for and more a general sense of what the sub can be used for. The whole "What if" thing.
Thanks again for all the help!

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: Question about %0
« Reply #9 on: February 18, 2010, 12:43:33 PM »
0
hmm, I didn't realize that you could pull the value of 0% either.  Nice way to control the performance of a sub that accepts varying numbers of arguments/parameters/values/whatevers.
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Tags: