October 15, 2019, 04:18 pm

Author Topic: [Release] Auto Gun Shop [V1]  (Read 2563 times)

Offline andreblue

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 783
  • I got my zombie plan. Now do you have yours?
    • View Profile
    • Random ness here
[Release] Auto Gun Shop [V1]
« on: May 12, 2012, 01:26 am »
My little Gunshop

Features:
-Allows you to set a price
-Only Shows what is in stock
-Low Low Low ops, 0 when no chats


How To Wire:

Wire the Wirelinks to a screen, Stock is for you, Customer is as the name states
Range1 goes with Fire1 and so on.
MoneyDeposit to LastDeposit of a money pot
Ignore Sound
CustomerEntity to a target finder to identify the customer




Code: [Select]
@name Auto Shop 10 Slot V1
@inputs Customer:wirelink Stock:wirelink MoneyDeposit CustomerFinder:entity
# Ship Links Below Rest Above
@inputs [Ranger1 Ranger2 Ranger3 Ranger4 Ranger5 Ranger6 Ranger7 Ranger8 Ranger9 Ranger10]:entity
@outputs Sound EmptyPot
# Fire Below Rest Above
@outputs Fire1 Fire2 Fire3 Fire4 Fire5 Fire6 Fire7 Fire8 Fire9 Fire10
@persist Advert:string PriceArray:array Slot
@trigger
function void shipScreen(){
    Customer[2041]=1
    Stock[2041]=1
    Line = 1
    if(Ranger1:isShipment()){
        String = Ranger1:shipmentName()+" X"+Ranger1:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger1:shipmentName()+" X"+Ranger1:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[1,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger2:isShipment()){
        String = Ranger2:shipmentName()+" X"+Ranger2:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger2:shipmentName()+" X"+Ranger2:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[2,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger3:isShipment()){
        String = Ranger3:shipmentName()+" X"+Ranger3:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger3:shipmentName()+" X"+Ranger3:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[3,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger4:isShipment()){
        String = Ranger4:shipmentName()+" X"+Ranger4:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger4:shipmentName()+" X"+Ranger4:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[4,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger5:isShipment()){
        String = Ranger5:shipmentName()+" X"+Ranger5:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger5:shipmentName()+" X"+Ranger5:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[5,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger6:isShipment()){
        String = Ranger6:shipmentName()+" X"+Ranger6:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger6:shipmentName()+" X"+Ranger6:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[6,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger7:isShipment()){
        String = Ranger7:shipmentName()+" X"+Ranger7:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger7:shipmentName()+" X"+Ranger7:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[7,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger8:isShipment()){
        String = Ranger8:shipmentName()+" X"+Ranger8:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger8:shipmentName()+" X"+Ranger8:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[8,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger9:isShipment()){
        String = Ranger9:shipmentName()+" X"+Ranger9:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger9:shipmentName()+" X"+Ranger9:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[9,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    if(Ranger10:isShipment()){
        String = Ranger10:shipmentName()+" X"+Ranger10:shipmentAmount()
        NumLen = String:length()
        Customer:writeString(Ranger10:shipmentName()+" X"+Ranger10:shipmentAmount(),0,Line)
        Customer:writeString("Each :"+PriceArray[10,number]:toString()+"$",NumLen+3,Line)
        Stock:writeString(String,0,Line)
        Line++
    }
    Stock:writeString("Customer: "+CustomerFinder:name(),0,Line)
}
 
if(first()){
    #Help Printing
    print("Do \"@help\" for this menu")#Help Menu Command
    print("Do \"@price <Slot Number> <Price>\" to set the price")#Price Command
    print("Do \"@slot <Slot Number>\" for the Slot's infomation")#Price/slot List Command
    print("Do \"@who\" for the current buyer")#Current Buyer
    print("Do \"@stock\" for your current stocks with prices")#Stock
    print("If you add a \" ?\" after your wanted command, it will display more on it")

}

#Price Checking
if(changed(MoneyDeposit)){
    for(I=1,10){
        if(MoneyDeposit == PriceArray[I,number]){
            Slot = I
            break
        }
    }
    shipScreen()
}   
#Fire Slots
if(changed(Slot)){
    if(Slot == 1){
        Fire1 = 1
        timer("Fires",1000)
    }elseif(Slot == 2){
        Fire2 = 1
        timer("Fires",1000)
    }elseif(Slot == 3){
        Fire3 = 1
        timer("Fires",1000)
    }elseif(Slot == 4){
        Fire4 = 1
        timer("Fires",1000)
    }elseif(Slot == 5){
        Fire5 = 1
        timer("Fires",1000)
    }elseif(Slot == 6){
        Fire6 = 1
        timer("Fires",1000)
    }elseif(Slot == 7){

        Fire7 = 1

        timer("Fires",1000)

    }elseif(Slot == 8){
        Fire8 = 1
        timer("Fires",1000)
    }elseif(Slot == 9){
        Fire9 = 1
        timer("Fires",1000)
    }elseif(Slot == 10){
        Fire10 = 1
        timer("Fires",1000)
    }

}
#Reset Stuff
if(clk("Fires")){
    Fire1 = 0
    Fire2 = 0
    Fire3 = 0
    Fire4 = 0
    Fire5 = 0
    Fire6 = 0
    Fire7 = 0
    Fire8 = 0
    Fire9 = 0
    Fire10 = 0
    EmptyPot = 1
    timer("Pot",500)
}
if(clk("Pot")){
    EmptyPot = 0
}
#Screen Stuff
if(changed(Ranger1)){
    shipScreen()
}
if(changed(Ranger2)){
    shipScreen()
}
if(changed(Ranger3)){
    shipScreen()
}
if(changed(Ranger4)){
    shipScreen()
}
if(changed(Ranger5)){
    shipScreen()
}
if(changed(Ranger6)){
    shipScreen()
}
if(changed(Ranger7)){
    shipScreen()
}
if(changed(Ranger8)){
    shipScreen()
}
if(changed(Ranger10)){
    shipScreen()
}
if(changed(Ranger10)){
    shipScreen()
}
#Chat Stuff
runOnChat(1)
LS = owner():lastSaid():explode(" ")
if(LS[1,string]=="@help" & chatClk(owner())){
    print("Do \"@help\" for this menu")#Help Menu Command
    print("Do \"@price <Slot Number> <Price>\" to set the price")#Price Command
    print("Do \"@slot <Slot Number>\" for the Slot's infomation")#Price/slot List Command
    print("Do \"@who\" for the current buyer")#Current Buyer
    print("Do \"@stock\" for your current stocks with prices")#Stock
    print("If you add a \" ?\" after your wanted command, it will display more on it")
    shipScreen()
}elseif(LS[1,string]=="@price" & chatClk(owner())){
    if(LS[2,string]=="?"){
        print("Put a 1-10 where the \"?\" was to set the price of said slot")
    }elseif(LS[2,string]=="1"){
        PriceArray[1,number] = LS[3,string]:toNumber()
        print("Slot 1: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="2"){
        PriceArray[2,number] = LS[3,string]:toNumber()
        print("Slot 2: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="3"){
        PriceArray[3,number] = LS[3,string]:toNumber()
        print("Slot 3: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="4"){
        PriceArray[4,number] = LS[3,string]:toNumber()
        print("Slot 4: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="5"){
        PriceArray[5,number] = LS[3,string]:toNumber()
        print("Slot 5: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="6"){
        PriceArray[6,number] = LS[3,string]:toNumber()
        print("Slot 6: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="7"){
        PriceArray[7,number] = LS[3,string]:toNumber()
        print("Slot 7: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="8"){
        PriceArray[8,number] = LS[3,string]:toNumber()
        print("Slot 8: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="9"){
        PriceArray[9,number] = LS[3,string]:toNumber()
        print("Slot 9: $"+LS[3,string]:toNumber())
    }elseif(LS[2,string]=="10"){
        PriceArray[10,number] = LS[3,string]:toNumber()
        print("Slot 10: $"+LS[3,string]:toNumber())
    }else{
        print("Put a 1-10 where the \"?\" was to set the price of said slot or leave it blank to see the current prices")
    }
    hideChat(1)
    shipScreen()
}elseif(LS[1,string]=="@slot" & chatClk(owner())){
    if(LS[2,string]=="?"){
        print("Put a 1-10 where the \"?\" was to set the price of said slot")
    }elseif(LS[2,string]=="1"){
        print("Slot 1: $"+PriceArray[1,number])
    }elseif(LS[2,string]=="2"){
        print("Slot 2: $"+PriceArray[2,number])
    }elseif(LS[2,string]=="3"){
        print("Slot 3: $"+PriceArray[3,number])
    }elseif(LS[2,string]=="4"){
        print("Slot 4: $"+PriceArray[4,number])
    }elseif(LS[2,string]=="5"){
        print("Slot 5: $"+PriceArray[5,number])
    }elseif(LS[2,string]=="6"){
        print("Slot 6: $"+PriceArray[6,number])
    }elseif(LS[2,string]=="7"){
        print("Slot 7: $"+PriceArray[7,number])
    }elseif(LS[2,string]=="8"){
        print("Slot 8: $"+PriceArray[8,number])
    }elseif(LS[2,string]=="9"){
        print("Slot 9: $"+PriceArray[9,number])
    }elseif(LS[2,string]=="10"){
        print("Slot 10: $"+PriceArray[10,number])
    }else{
    for(B=1,PriceArray:count()){
        print("Slot "+B+" : "+PriceArray[B,number]+"$")
    }
    }
    hideChat(1)
    shipScreen()
}elseif(LS[1,string]=="@who" & chatClk(owner())){
    if(LS[2,string]=="?"){
        print("Just type nothing after this command to see who is in your shop")
    }else{
    if(CustomerFinder:isPlayer()){
        print(CustomerFinder:name())
    }else{
        print("No Customer At The Moment")
    }
    }
    hideChat(1)
   
}elseif(LS[1,string]=="@stock" & chatClk(owner())){
        print(Ranger1:shipmentName()+" X "+Ranger1:shipmentAmount())
        print(Ranger2:shipmentName()+" X "+Ranger2:shipmentAmount())
        print(Ranger3:shipmentName()+" X "+Ranger3:shipmentAmount())
        print(Ranger4:shipmentName()+" X "+Ranger4:shipmentAmount())
        print(Ranger5:shipmentName()+" X "+Ranger5:shipmentAmount())
        print(Ranger6:shipmentName()+" X "+Ranger6:shipmentAmount())
        print(Ranger7:shipmentName()+" X "+Ranger7:shipmentAmount())
        print(Ranger8:shipmentName()+" X "+Ranger8:shipmentAmount())
        print(Ranger9:shipmentName()+" X "+Ranger9:shipmentAmount())
        print(Ranger10:shipmentName()+" X "+Ranger10:shipmentAmount())
        shipScreen()
        hideChat(1)
}
#[
By usign the e2, you agree that i(Andre Lallier) can take legal action
for you breaking the copy rights
CopyRight:
This document is Copyright (2012) (Andre Lallier) (andreblue)
and is the intellectual property of the author. It may be not be
reproduced under any circumstances except for personal,
private use as long as it remains in its unaltered, unedited form.
It may not be placed on any web site or otherwise distributed publicly
without advance written permission. Use of this code on any other
website or as a part of any public display is strictly prohibited,
and a violation of copyright.
Written Permission must be obtained at all times.
No one has my(Andre Lallier) permission to make profit(Real Legal Tender,items,services,Vitural Cash) off of this code.
You will have to pay a sum of 100$ and legal fees if caught doing so.
]#

Coming Soon:
-Better Price setting
-Better Printing of current stock, as to not include the empty slots
-Store Shipment Names in an array along with amounts

ChangeLog:
V1:
Release

http://andreblue.com/auto_shop_10_slot_v1.txt
« Last Edit: May 12, 2012, 01:38 am by andreblue »

Offline Mr.Commodore

  • ByB Fanatic
  • ****
  • Posts: 345
    • View Profile
Re: [Release] Auto Gun Shop [V1]
« Reply #1 on: May 12, 2012, 02:33 am »
Suggestion; structure your chat commands like this:

Code: [Select]
runOnChat(1)
if(chatClk(owner())){
LS = owner():lastSaid():explode(" ")
/* If statements */

It saves on op usage as it only checks to see if the owner chatted once and not multiple times.
That and it looks nicer.

Offline andreblue

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 783
  • I got my zombie plan. Now do you have yours?
    • View Profile
    • Random ness here
Re: [Release] Auto Gun Shop [V1]
« Reply #2 on: May 12, 2012, 03:00 am »
Suggestion; structure your chat commands like this:

Code: [Select]
runOnChat(1)
if(chatClk(owner())){
LS = owner():lastSaid():explode(" ")
/* If statements */

It saves on op usage as it only checks to see if the owner chatted once and not multiple times.
That and it looks nicer.
Ya its gonna be part of the array cleanup.

Offline Spoofzor

  • ByB Fanatic
  • ****
  • Posts: 902
  • What do you mean that's as loud as it can go!?!
    • View Profile
Re: [Release] Auto Gun Shop [V1]
« Reply #3 on: May 12, 2012, 07:33 am »
Also, you can put
Code: [Select]
runOnChat(1)

inside your
Code: [Select]
if(first()){
    ...
}
statement.

You only need to call it once, not every execution.