The Shadow Tiger Development Team Index du Forum
S’enregistrerRechercherFAQMembresGroupesConnexion
Programme Shop

 
Répondre au sujet    The Shadow Tiger Development Team Index du Forum » Projets » [Minecraft] Diablo Sujet précédent
Sujet suivant
Programme Shop
Auteur Message
x iWaRShAdE
Modérateur

Hors ligne

Inscrit le: 10 Déc 2012
Messages: 26

Message Programme Shop Répondre en citant
> tableTopInterface
term.clear()
mon=peripheral.wrap("top")
local name="Tingle's Grocery"
local lines=5
local shopBot=7
local keepRunning = true
rednet.open("right")
itemNames={0,0,0,"Steak","Pork","Bread",0,0,0}
function clear()
  mon.clear()
  mon.setCursorPos(1,1)
end
--[[function say(message)
  print(name .. " says: "..message)
  mon.scroll(1)
  mon.setCursorPos(1,lines)
  mon.write(name ..": "..message)
end
function message(text)
  print(message)
  mon.scroll(1)
  mon.setCursorPos(1,lines)
  mon.write(message)
end
function shopKeeper()
  if redstone.getInput("bottom") == false then
    clear()
    message("... (there is no one here)")
  else
    rednet.send(shopBot,"credit")
    send = nil
    while send == nil do
      send,credit,dist=rednet.receive()
      print("Got "..send.." "..credit)
    end
    credit = tonumber(credit)
    mon.setCursorPos(1,5)
    mon.clearLine()
    mon.write("Credit: "..credit)
  end
end
]]--
function getUpdates()
  while keepRunning do
    send,mess,dist=rednet.receive()
    if send == shopBot then
      --[[print("Got "..mess) ]]--
      selling,itemSelected,credit,shopCash,shopItems,price=string.match(mess,"Selling:(%d+) ItemSelected:(%d+) Credit:(%d+) Cash:(%d+) NumItems:(%d+) Price:([0-9\.]+)")
      if shopItems ~= nil then


        selling=tonumber(selling)
        itemSelected=tonumber(itemSelected)
        credit=tonumber(credit)
        shopCash=tonumber(shopCash)
        shopItems=tonumber(shopItems)
        price=tonumber(price)


        clear()
        mon.setCursorPos(1,1)
        mon.write("Welcome to "..name)
        mon.setCursorPos(1,2)
        if selling==1 then
          mon.write("You are selling")
        else
          mon.write("You are buying:"..itemNames[itemSelected])
        end


        mon.setCursorPos(1,3)
        mon.write("Shop Cash: "..shopCash.."c")
        mon.setCursorPos(23,3)
        mon.write("Items: "..shopItems)


        mon.setCursorPos(1,4)
        mon.write("Your Credit: "..credit.."c")
        mon.setCursorPos(23,4)
        mon.write("Price: "..price)
      end
    end
  end
end


function printList()
  for ind,value in ipairs(itemNames) do
    if value ~= 0 then
      print(value)
    end
  end
end


function toggleSell()
  rednet.send(shopBot,"sell")
end


function buyItem(what)
  for ind,value in ipairs(itemNames) do
    if value == what then
      rednet.send(shopBot,"buy "..ind)
    end
  end
end
function getChoice()
  while keepRunning do
    print("How can I help you?")
    write(" (help for help) >")
    input = read()
    if input=="help" then
      print("'list' to list the items I sell")
      print("'sell' to start selling items to me")
      print("'buy (item)'' to start buying items")
    elseif input=="list" then
      printList()
    elseif input=="sell" then
      toggleSell()
    elseif input=="cheddar" then
      keepRunning = false
    elseif string.find(input,"buy") ~= nil then
      what = string.match(input,"buy (.+)")
      if what ~= nul then
        print("Buy :"..what)
        buyItem(what)
      end
    end
  end
end


parallel.waitForAll(getChoice,getUpdates)
--[[a
while true do
  shopKeeper() 
  os.sleep(1)
end   
]]--



> backroomTurtle
local debit=0
local credit=0
local shopBot=8
local slotValues = { 1,6,24,7,7,8,0,0,0 }
local slotCosts =  { 1,6,24,8,8,9,0,0,0 }
local wareSelected = 4
local selling=false
rednet.open("right")




function getCredit()
  credit=0
  for a=1,9 do
    if slotValues[a] == 0 then
      if turtle.getItemCount(a) > 0 then
        turtle.select(a)
        turtle.drop()
      end
    else      
      credit = credit + slotValues[a] * (turtle.getItemCount(a) - 1)
    end
  end
  return credit
end


function totalCredit()
  return getCredit() - debit
end


function buyIfWeCan()
  if wareSelected == 0 then return end
  local canBuy = totalCredit() / slotCosts[wareSelected]
  canBuy = math.floor(canBuy)
  if turtle.getItemCount(wareSelected) - 1 < canBuy then
    canBuy = turtle.getItemCount(wareSelected) - 1
  end
  --[[print(canBuy.." "..wareSelected.." "..debit.." "..credit)]]--
  if canBuy < 1 then return end
  turtle.select(wareSelected)
  turtle.drop(canBuy)
  debit = debit + canBuy * slotCosts[wareSelected] - (canBuy * slotValues[wareSelected] )
end


function sellIfWeCan()
  wareSelected=3
  buyIfWeCan()
  wareSelected=2
  buyIfWeCan()
  wareSelected=1
  buyIfWeCan()
end


function shopCash()
  local mon=0
  for a=1,3 do
    mon = mon + slotCosts[a] * (turtle.getItemCount(a)-1)
  end
  return mon
end


credit = getCredit()
debit = credit
local myCash=0


while true do
  send=nil
  local sell
  local inum
  while send ~= shopBot do
    getCredit()
    if selling then
      sellIfWeCan()
    else
      buyIfWeCan()
    end
    if selling then sell=1 else sell=0 end
    inum = turtle.getItemCount(wareSelected) - 1
    rednet.send(shopBot,"Selling:"..sell.." ItemSelected:"..wareSelected.." Credit:"..math.floor(totalCredit()).." Cash:"..shopCash().." NumItems:"..inum.." Price:"..slotCosts[wareSelected])
    send,mess,dist=rednet.receive(2)
  end
  print("got "..mess)
  if mess=="sell" then
    selling=true
  elseif string.find(mess,"buy") ~= nil then
    what = string.match(mess,"buy (.+)")
    selling=false
    wareSelected = tonumber(what)
  end
end












Celui qui marche


itemsOut=8
while true do 
  os.sleep(.2)
  money=0
  for a=2,9 do money=money+turtle.getItemCount(a) end
  turtle.drop(turtle.getItemCount(1))
  if money > itemsOut then
    redstone.setOutput("right",true) sleep(.2)
    redstone.setOutput("right",false) 
    itemsOut=itemsOut+1
end end


Jeu 3 Jan - 07:04 (2013)
Publicité






Message Publicité
PublicitéSupprimer les publicités ?

Jeu 3 Jan - 07:04 (2013)
x iWaRShAdE
Modérateur

Hors ligne

Inscrit le: 10 Déc 2012
Messages: 26

Message Programme Shop Répondre en citant
http://www.youtube.com/watch?v=zmGyDRpcEMk


Jeu 3 Jan - 07:41 (2013)
Tyggerr
Administrateur

Hors ligne

Inscrit le: 10 Déc 2012
Messages: 86

Message Programme Shop Répondre en citant
> backroomTurtle
local debit=0
local credit=0
local shopBot=6
local slotValues = { 1,9,81,729,7,7,8,0,0,0,0,0,0,0,0,0 }
local slotCosts =  { 1,9,81,729,8,8,9,0,0,0,0,0,0,0,0,0 }
local wareSelected = 5
local selling=false
rednet.open("right")




function getCredit()
  credit=0
  for a=1,16 do
    if slotValues[a] == 0 then
      if turtle.getItemCount(a) > 0 then
        turtle.select(a)
        turtle.drop()
      end
    else      
      credit = credit + slotValues[a] * (turtle.getItemCount(a) - 1)
    end
  end
  return credit
end


function totalCredit()
  return getCredit() - debit
end


function buyIfWeCan()
  if wareSelected == 0 then return end
  local canBuy = totalCredit() / slotCosts[wareSelected]
  canBuy = math.floor(canBuy)
  if turtle.getItemCount(wareSelected) - 1 < canBuy then
    canBuy = turtle.getItemCount(wareSelected) - 1
  end
  --[[print(canBuy.." "..wareSelected.." "..debit.." "..credit)]]--
  if canBuy < 1 then return end
  turtle.select(wareSelected)
  turtle.drop(canBuy)
  debit = debit + canBuy * slotCosts[wareSelected] - (canBuy * slotValues[wareSelected] )
end


function sellIfWeCan()
  wareSelected=4
  buyIfWeCan()

  wareSelected=3
  buyIfWeCan()
  wareSelected=2
  buyIfWeCan()
  wareSelected=1
  buyIfWeCan()
end


function shopCash()
  local mon=0
  for a=1,4 do
    mon = mon + slotCosts[a] * (turtle.getItemCount(a)-1)
  end
  return mon
end


credit = getCredit()
debit = credit
local myCash=0


while true do
  send=nil
  local sell
  local inum
  while send ~= shopBot do
    getCredit()
    if selling then
      sellIfWeCan()
    else
      buyIfWeCan()
    end
    if selling then sell=1 else sell=0 end
    inum = turtle.getItemCount(wareSelected) - 1
    rednet.send(shopBot,"Selling:"..sell.." ItemSelected:"..wareSelected.." Credit:"..math.floor(totalCredit()).." Cash:"..shopCash().." NumItems:"..inum.." Price:"..slotCosts[wareSelected])
    send,mess,dist=rednet.receive(2)
  end
  print("got "..mess)
  if mess=="sell" then
    selling=true
  elseif string.find(mess,"buy") ~= nil then
    what = string.match(mess,"buy (.+)")
    selling=false
    wareSelected = tonumber(what)
  end
end


Jeu 3 Jan - 08:02 (2013)
Tyggerr
Administrateur

Hors ligne

Inscrit le: 10 Déc 2012
Messages: 86

Message Programme Shop Répondre en citant
> tableTopInterface
term.clear()
mon=peripheral.wrap("top")
local name="Tingle's Grocery"
local lines=5
local shopBot=5
local keepRunning = true
rednet.open("right")
itemNames={0,0,0,0,"Steak","Pork","Bread",0,0,0,0,0,0,0,0,0}
function clear()
  mon.clear()
  mon.setCursorPos(1,1)
end
--[[function say(message)
  print(name .. " says: "..message)
  mon.scroll(1)
  mon.setCursorPos(1,lines)
  mon.write(name ..": "..message)
end
function message(text)
  print(message)
  mon.scroll(1)
  mon.setCursorPos(1,lines)
  mon.write(message)
end
function shopKeeper()
  if redstone.getInput("bottom") == false then
    clear()
    message("... (there is no one here)")
  else
    rednet.send(shopBot,"credit")
    send = nil
    while send == nil do
      send,credit,dist=rednet.receive()
      print("Got "..send.." "..credit)
    end
    credit = tonumber(credit)
    mon.setCursorPos(1,5)
    mon.clearLine()
    mon.write("Credit: "..credit)
  end
end
]]--
function getUpdates()
  while keepRunning do
    send,mess,dist=rednet.receive()
    if send == shopBot then
      --[[print("Got "..mess) ]]--
      selling,itemSelected,credit,shopCash,shopItems,price=string.match(mess,"Selling:(%d+) ItemSelected:(%d+) Credit:(%d+) Cash:(%d+) NumItems:(%d+) Price:([0-9\.]+)")
      if shopItems ~= nil then


        selling=tonumber(selling)
        itemSelected=tonumber(itemSelected)
        credit=tonumber(credit)
        shopCash=tonumber(shopCash)
        shopItems=tonumber(shopItems)
        price=tonumber(price)


        clear()
        mon.setCursorPos(1,1)
        mon.write("Welcome to "..name)
        mon.setCursorPos(1,2)
        if selling==1 then
          mon.write("You are selling")
        else
          mon.write("You are buying:"..itemNames[itemSelected])
        end


        mon.setCursorPos(1,3)
        mon.write("Shop Cash: "..shopCash.."c")
        mon.setCursorPos(23,3)
        mon.write("Items: "..shopItems)


        mon.setCursorPos(1,4)
        mon.write("Your Credit: "..credit.."c")
        mon.setCursorPos(23,4)
        mon.write("Price: "..price)
      end
    end
  end
end


function printList()
  for ind,value in ipairs(itemNames) do
    if value ~= 0 then
      print(value)
    end
  end
end


function toggleSell()
  rednet.send(shopBot,"sell")
end


function buyItem(what)
  for ind,value in ipairs(itemNames) do
    if value == what then
      rednet.send(shopBot,"buy "..ind)
    end
  end
end
function getChoice()
  while keepRunning do
    print("How can I help you?")
    write(" (help for help) >")
    input = read()
    if input=="help" then
      print("'list' to list the items I sell")
      print("'sell' to start selling items to me")
      print("'buy (item)'' to start buying items")
    elseif input=="list" then
      printList()
    elseif input=="sell" then
      toggleSell()
    elseif input=="cheddar" then
      keepRunning = false
    elseif string.find(input,"buy") ~= nil then
      what = string.match(input,"buy (.+)")
      if what ~= nil then
        print("Buy :"..what)
        buyItem(what)
      end
    end
  end
end


parallel.waitForAll(getChoice,getUpdates)
--[[a
while true do
  shopKeeper() 
  os.sleep(1)
end   
]]--


Jeu 3 Jan - 08:46 (2013)
x iWaRShAdE
Modérateur

Hors ligne

Inscrit le: 10 Déc 2012
Messages: 26

Message Programme Shop Répondre en citant
os.pullEvent = os.pullEventRaw                                                
term.clear()
term.setCursorPos(1,1)
write("Welcome! Please choose a class")
write("Amazone")
write("Guardian")
x = read()
if x == "Amazone" then
 write("1 Leather Helmet")
 write("1 Leather Chestplate")
 write("1 Leather Pant")
 write("1 Stone Spear")
 write("2 Iron Spear")


 sleep(7)
 end


elseif x == "Guardian" then
 write("1 Damascus Steel Helmet")
 write("1 Damascus Steel Chestplate")
 write("1 Damascus Steel Pant")
 write("1 Damascus Steel Boots")
 write("1 Gilded Wooden Shield")


 sleep(7)
 end


else
write("Invalid Class")
end


Dim 27 Jan - 09:42 (2013)
x iWaRShAdE
Modérateur

Hors ligne

Inscrit le: 10 Déc 2012
Messages: 26

Message Programme Shop Répondre en citant
os.pullEvent = os.pullEventRaw                                                
term.clear()
term.setCursorPos(1,1)
write("Welcome! Please choose a class\n")
write("Amazone\n")
write("Guardian\n")
write("Priest\n")
write("Hunter\n")
write("Blacksmith\n")
write("Scout\n")
write("Assassin\n")
write("Ranger\n")
write("Guard\n")
write("Merchant\n")
write("Enchanter\n")
write("Gladiator\n")
write("Barbarian\n")
write("Knight\n")
write("Warrior\n")
write("Ninja\n")
write("\n")
write("\n")


x = io.read()
choix = 0
if x == "Amazone" then
 write("1 Leather Helmet\n")
 write("1 Leather Chestplate\n")
 write("1 Leather Pant\n")
 write("1 Stone Spear\n")
 write("2 Iron Spears\n")
choix = 1
 sleep(2)


elseif x == "Guardian" then
 write("1 Damascus Steel Helmet\n")
 write("1 Damascus Steel Chestplate\n")
 write("1 Damascus Steel Pant\n")
 write("1 Damascus Steel Boots\n")
 write("1 Gilded Wooden Shield\n")
choix = 2
 sleep(2)


elseif x == "Priest" then
 write("1 Leather Helmet\n")
 write("1 Leather Chestplate\n")
 write("1 Milk\n")
 write("1 Stone Sword\n")
 write("4 Splash Health Potions\n")
 write("2 Splash Regen Potions\n")
choix = 4
 sleep(2)


elseif x == "Hunter" then
 write("1 Iron Bow\n")
 write("50 Arrows\n")
 write("1 Stone Knife\n")
 write("1 Reptile Helmet\n")
 write("1 Reptile Chestplate\n")
 write("1 Reptile Boots\n")
choix = 8
 sleep(2)


elseif x == "Blacksmith" then
 write("1 Stone Warhammer\n")
 write("1 Copper Helmet\n")
 write("1 Copper Chestplate\n")
 write("3 Copper Bars\n")
 write("2 Splash Potions Of Strength\n")
 write("5 Steaks\n")
choix = 16
 sleep(2)


elseif x == "Scout" then
 write("1 Fur Helmet\n")
 write("1 Leather Chestplate\n")
 write("1 Leather Pant\n")
 write("1 Leather Boots\n")
 write("2 Stone Swords\n")
 write("1 Map\n")
 write("5 Breads\n")
choix = 32
 sleep(2)


elseif x == "Assassin" then
 write("1 Fur Helmet\n")
 write("1 Fur Chestplate\n")
 write("1 Fur Pant\n")
 write("1 Fur Boots\n")
 write("1 Iron Knife\n")
 write("1 Invisibility Potion\n")
 write("5 Steaks\n")
choix = 64
 sleep(2)


elseif x == "Ranger" then
 write("1 Stone Crossbow\n")
 write("64 Stone Bolts\n")
 write("1 Leather Helmet\n")
 write("1 Leather Chestplate\n")
 write("1 Stone Knife\n")
choix = 128
 sleep(2)


elseif x == "Guard" then
 write("1 Stone Halberd\n")
 write("1 Stone Sword\n")
 write("1 Silver Helmet\n")
 write("1 Silver Chestplate\n")
 write("1 Silver Pant\n")
 write("1 Silver Boots\n")
 write("3 Steaks\n")
choix = 256
 sleep(2)


elseif x == "Merchant" then
 write("1 Map\n")
 write("1 Leather Chestplate\n")
 write("1 Stone Knife\n")
 write("1 Book\n")
 write("4 Cookies\n")
 write("1 Gold Bar\n")
 write("27 Coins\n")
choix = 512
 sleep(2)


elseif x == "Enchanter" then
 write("2 Books\n")
 write("1 Enchanted (Sharpness III) Stone Sword\n")
 write("1 Leather Helmet\n")
 write("1 Leather Chestplate\n")
 write("1 Leather Pant\n")
 write("1 Leather Boots\n")
 write("10 Potions Of Enchanting\n")
choix = 1024
 sleep(2)


elseif x == "Gladiator" then
 write("1 Giant Iron Sword\n")
 write("1 Chainmail Helmet\n")
 write("1 Chainmail Chestplate\n")
 write("1 Chainmail Pant\n")
 write("1 Chainmail Boots\n")
 write("5 Steaks\n")
choix = 2048
 sleep(2)


elseif x == "Warrior" then
 write("1 Bow\n")
 write("1 Iron Sword\n")
 write("1 Leather Helmet\n")
 write("1 Leather Chestplate\n")
 write("1 Leather Pant\n")
 write("25 Arrows \n")
choix = 4096
 sleep(2)


elseif x == "Knight" then
 write("1 Iron Flail\n")
 write("1 1 Iron Shield\n")
 write("1 Iron Helmet\n")
 write("1 Iron Chestplate\n")
choix = 8192
 sleep(2)


elseif x == "Barbarian" then
 write("1 Iron Battleaxe\n")
 write("1 Hide Helmet\n")
 write("1 Hide Chestplate\n")
 write("1 Hide Pant\n")
 write("1 Hide Boots\n")
 write("1 Potion Of Regeneration II\n")
 write("1 Potion Of Strength\n")
choix = 16384
 sleep(2)


elseif x == "Ninja" then
 write("1 Katana\n")
 write("1 Cave Scorpion Helmet\n")
 write("1 Cave Scorpion Chestplate\n")
 write("1 Cave Scorpion Pant\n")
 write("1 Cave Scorpion Boots\n")
choix = 32768
 sleep(2)






























else
write("Invalid Class,Case Sensitive\n")
end


if choix ~= 0 then
write ("Choose this class? (Yes/No)\n")
valid = io.read()
if valid == "Yes" then
redstone.setBundledOutput("back", choix)
write ("Class Selected\n")
redstone.setOutput("top", true)
sleep(1)
rs.setOutput("top", false)
rs.setBundledOutput("back", 0)
rs.setOutput("back", false)




end
end
write("Loading....please wait\n")
sleep(5)
shell.run("selectclass")





---------------------------------------------------------------------------------------------------------------------------------




local sPath = ".:/rom/programs"
if turtle then
sPath = sPath..":/rom/programs/turtle"
else
sPath = sPath..":/rom/programs/computer"
end
if http then
sPath = sPath..":/rom/programs/http"
end
if term.isColor() then
sPath = sPath..":/rom/programs/color"
end


shell.setPath( sPath )
help.setPath( "/rom/help" )


shell.setAlias( "ls", "list" )
shell.setAlias( "dir", "list" )
shell.setAlias( "cp", "copy" )
shell.setAlias( "mv", "move" )
shell.setAlias( "rm", "delete" )


if fs.exists( "/rom/autorun" ) and fs.isDir( "/rom/autorun" ) then
local tFiles = fs.list( "/rom/autorun" )
table.sort( tFiles )
for n, sFile in ipairs( tFiles ) do
if string.sub( sFile, 1, 1 ) ~= "." then
local sPath = "/rom/autorun/"..sFile
if not fs.isDir( sPath ) then
shell.run( sPath )
end
end
end
end


shell.run ( "selectclass" )


---------------------------------------------------------------------------------------------------------------------------------


local event, p1, p2, p3, p4, p5 = os.pullEventRaw( _sFilter )
 if event == "terminate" then
   print( "Terminated" )
   error()
 end
 return event, p1, p2, p3, p4, p5










Mar 29 Jan - 03:31 (2013)
Contenu Sponsorisé






Message Programme Shop

Aujourd’hui à 19:18 (2018)
Montrer les messages depuis:    
Répondre au sujet    The Shadow Tiger Development Team Index du Forum » Projets » [Minecraft] Diablo Toutes les heures sont au format GMT + 1 Heure
Page 1 sur 1

 
Sauter vers: 

Index | Panneau d’administration | creer un forum gratuit | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation
Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.Traduction par : phpBB-fr.com