Shop Example Script

Learn more on how to use Sandbox, or submit your own tutorials or resources.
User avatar
johnno56
Member
Member
Posts: 157
Joined: June 12th, 2009, 4:06 am
Name: John
Location: Melbourne, Australia

Re: Shop Example Script

Postby johnno56 » June 18th, 2009, 1:11 am

GoBologna120,

Please correct me if I am wrong.

Maybe you could use the following to detect no money?

if ( < $money 1 ) guitext "Sorry. You have no money."

Just a guess...

J
May your journey be free of incident.

Live long and prosper.

User avatar
GoBologna120
Member
Member
Posts: 167
Joined: June 10th, 2009, 3:07 pm
Name: Tim
IRC Username: GoBologna
Location: Nowhere in particular.

Re: Shop Example Script

Postby GoBologna120 » June 18th, 2009, 6:56 pm

Well, the shopkeeper usually only tells you if you don't have enough money. I'd think you'd know if you were broke. :lol:
Image
Yay. ^_^

User avatar
slyver1988
Member
Member
Posts: 10
Joined: June 25th, 2009, 5:16 pm
Name: patrick
Contact:

Re: Shop Example Script

Postby slyver1988 » June 26th, 2009, 4:03 pm

hey help me i wanna try things out... but were i put this scrips?? :shock:
srry i dont use scripts much xD
i putted it in my .CFG but i only see the invitory :)
how i get shopkeeper and text ^^
---->folow my project at http://www.youtube.com/slyver1988 it will be great and i keep you up to date with all new adds<----

User avatar
GoBologna120
Member
Member
Posts: 167
Joined: June 10th, 2009, 3:07 pm
Name: Tim
IRC Username: GoBologna
Location: Nowhere in particular.

Re: Shop Example Script

Postby GoBologna120 » June 26th, 2009, 4:31 pm

The coins must be set to level_trigger_1 and the shopkeeper must be set to level_trigger_2. Also, the coin is trigger type 12 and the shopkeep is type 11.
Image
Yay. ^_^

Doctor
Member
Member
Posts: 1
Joined: July 19th, 2009, 2:03 am
Name: Brendan

Re: Shop Example Script

Postby Doctor » July 19th, 2009, 2:31 am

GoBologna120 wrote:It's good to know that I'm contributing something. :mrgreen:
The only thing I'm not sure of at the moment is how to have the shopkeeper tell you if you don't have enough money.

I don't know how to script that much if at all but. couldn't you just run a script that asks for the players inventory and if they have the currency thats used at that shop? Like my really bad example:
(check player inventory for "blah blah")
(if player has "blah blah" let them buy it)
("else" play message: I'm sorry but you don't have enough money for this item)
(end sub)

Mama's Boy
Member
Member
Posts: 25
Joined: June 22nd, 2009, 7:10 pm
Name: Jacob DeBoer

Re: Shop Example Script

Postby Mama's Boy » August 17th, 2009, 8:34 am

I've got something for you. I redid some things, so just put this back in your cfg. It's mostly your work anyway :)

Code: Select all

"on_start" = [

   money = 0

   pie = 0

   sword = 0

   treasure = 0

   ]



"level_trigger_1" = [ money = ( + $money 5 )

   echo "You got 5 moneys."

   ]



"level_trigger_2" = "showgui Shopkeeper"



newgui Shopkeeper [

   guitext "What're ya buyin, stranger?" chat

   guibar

   guilist [

      guibutton "Pie: 10 moneys" [

         if ( > $money 9 ) [

            money = ( - $money 10 )

            pie = ( + $pie 1 )

         ] [showgui NotEnough]

      ]

      guibar

      guibutton "Sword: 20 moneys" [

         if ( > $money 19 ) [

            money = ( - $money 20 )

            sword = ( + $sword 1 )

            ] [showgui NotEnough]

         ]

      guibar

      guibutton "Treasure: 40 moneys" [

         if ( > $money 39 ) [

            money = ( - $money 40 )

            treasure = ( + $treasure 1 )

            ] [showgui NotEnough]

         ]

   ]

]

newgui NotEnough [
   guitext "Sorry, you don't have enough moneys." chat
   guibar
   guilist [
      guibutton "I'll buy something else." "showgui Shopkeeper"
      guibar
      guibutton "Goodbye." "cleargui"
   ]
] "Shopkeeper"



newgui Inventory [

guibutton "Back" "cleargui 1"

guibar

guitext ( format "You have %1 moneys in your wallet." $money )

guitext ( format "You have %1 pies.  Yum." $pie )

guitext ( format "You have %1 swords.  Not that you can use them..." $sword )

guitext ( format "You have %1 treasures.  Lucky you!" $treasure )

]



newgui main [

   guilist [

      guilist [

         guibutton "Inventory" "showgui Inventory"

      ]

   ]

   guibar

   @main

]


It's just like the old one, but if you can't afford something, the shopkeeper will tell you, and you can either say goodbye or continue shopping.

OrbitalRider
Member
Member
Posts: 3
Joined: September 18th, 2009, 10:26 pm
Name: Shane

Re: Shop Example Script

Postby OrbitalRider » September 20th, 2009, 11:58 pm

Heres the code to make it where the shopkeeper tells you u dont have enough gold if you havent figured it out yet. only prob is you have to type out another "newgui" but atleast theres a copy and paste option :)!!!!

Code: Select all

if ( < $money 10 ) "showgui ShopKeeper"
       
 newgui ShopKeeper [
    guitext ( format "You only have %1 gold." $money )   
          guibar
           guibutton "ok" [
          cleargui -1 ]


Ofcourse you can change what you want him to say, i just made it where it reminds me how much i have. Also you could take out the "ok" button if you use the keyboard to to exit menus.

And if you didnt want to have a new menu pop up you could always use

Code: Select all

echo "You dont have enough gold"


so that it would just show up as little text in the corner of the screen. Either way, well there ya go pretty simple.

oh! don't forget to put however many "]" you need. itll tell you if theres one missing.

bradels
Member
Member
Posts: 4
Joined: November 9th, 2009, 9:43 pm
Name: brad hill

Re: Shop Example Script

Postby bradels » November 11th, 2009, 12:22 am

thank you this alone has thought me a lot :D

EDIT: sorry for double post would this work. as a addon to yours

Code: Select all

]

"level_trigger_3" = "showgui chest" [money=(=+$money 5)

]

newgui chest [

guitext " wow you obtained 20 coins for your jounerny"
guibar
guilist[
guibutton "leave unlocked in hopes some kind stanger will refill it (i mean howd it get in there in the first place"
]









i say this because i don't know how to assing level trigger
Last edited by Obsidian on November 11th, 2009, 1:09 am, edited 1 time in total.
Reason: merged double post -- in the future, please just edit your post

User avatar
Creatorrookie
Member
Member
Posts: 66
Joined: September 22nd, 2009, 8:35 pm
Name: John

Re: Shop Example Script

Postby Creatorrookie » January 3rd, 2010, 4:14 pm

Does the shop script work in the sandbox rpg and 2.4?
The rookie in sandbox... :)

User avatar
GR1M
Support Team
Support Team
Posts: 1305
Joined: August 22nd, 2009, 4:35 pm
Name: Luke
IRC Username: Gr1m
Location: Texas
Contact:

Re: Shop Example Script

Postby GR1M » January 3rd, 2010, 7:52 pm

Yes it does.
Image
Want a user bar like this one? PM Leo


Return to “Tutorials and Resources”

Who is online

Users browsing this forum: No registered users and 4 guests