Forum du serveur Computercraft FR
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le Deal du moment : -45%
PC Portable LG Gram 17″ Intel Evo Core i7 32 Go ...
Voir le deal
1099.99 €

os.pullEvent("monitor_touch")

3 participants

Aller en bas

os.pullEvent("monitor_touch") Empty os.pullEvent("monitor_touch")

Message par Tonitch8 Lun 15 Aoû - 17:09

Bonjour,
je ne fait pas partit du serveur computercraft.fr mais j'ai quand meme besoin de votre aide

j'utilise big reactors et j'éssait de créer un programme de gestion de mon réacteur...

probleme : voici mon code
Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")
 
m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)
 
while true do
  if os.pullEvent("monitor_touch") then
    m.write("yo")
  end
end

au if os.pullEvent("monitor_touch") then
je ne peut pas récupérer les coordonnées du monitor_touch...
si qqun peut m'aider sa serais vraiment cool Very Happy

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Kuruyia Lun 15 Aoû - 17:13

Essaye plutôt :
Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")
 
m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)
 
while true do
  -- Je mets les coordonées dans clickX et clickY
  event, monitorName, clickX, clickY = os.pullEvent("monitor_touch")
  m.write("yo")
end
Kuruyia
Kuruyia

Messages : 83
Date d'inscription : 10/04/2016
Age : 23
Localisation : Glitch City

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Lun 15 Aoû - 17:16

c'est ce que j'ai essayé juste avant...

mais le problème est que la suite du programmes ne s'execute pas car il att un pullEvent...

car il y'a d'autres fonctions qui doivent êtres mises dans le programme

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Kuruyia Lun 15 Aoû - 17:19

Fait des fonctions et utilise l'API parallel :
Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")
 
m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)

function clickHandler()
  while true do
    -- Je mets les coordonées dans clickX et clickY
    event, monitorName, clickX, clickY = os.pullEvent("monitor_touch")
    m.write("yo")
  end
end

function autreChose()
  while true do
      --Je fais autre chose en même temps
  end
end

parallel.waitForAny(clickHandler, autreChose)
Kuruyia
Kuruyia

Messages : 83
Date d'inscription : 10/04/2016
Age : 23
Localisation : Glitch City

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Lun 15 Aoû - 17:22

arc13 a écrit:Fait des fonctions et utilise l'API parallel :
Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")
 
m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)

function clickHandler()
   while true do
     -- Je mets les coordonées dans clickX et clickY
     event, monitorName, clickX, clickY = os.pullEvent("monitor_touch")
     m.write("yo")
   end
end

function autreChose()
   while true do
      --Je fais autre chose en même temps
   end
end

parallel.waitForAny(clickHandler, autreChose)

merci je n'ai jamais utiliser cette api...
je vais check le wiki tu connais un bon tutoriel
sinon merci Razz

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Kuruyia Lun 15 Aoû - 17:24

Tu peut aller voir la vidéo de cedmeu à ce sujet :

Kuruyia
Kuruyia

Messages : 83
Date d'inscription : 10/04/2016
Age : 23
Localisation : Glitch City

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Lun 15 Aoû - 18:45

merci beacoup j'ai refait mon code et... il y'a encore un problème voici le code:

Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")

m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)

function mo_touch()
  while true do
    event, side, xpos, ypos = os.pullEvent("monitor_touch")
    if xpos == 3 or xpos == 4 and ypos == 2 then
      r.setActive(true)
    elseif xpos == 45 or xpos == 46 and ypos == 2 then
      r.setActive(false)
    end
  end
end

function test_r()
  while true do
    if r.getActive() then
      m.setBackgroundColor(colors.green)
      m.setCursorPos(4,4)
      m.write("On")
    elseif r.getActive() == false then
      m.setBackgroundColor(colors.red)
      m.setCursorPos(4,4)
      m.write("off")
    end
  end
end

function hud()
  paintutils.drawImage(image, 1, 1)
end

while true do
parallel.waitForAny(hud(),test_r(),mo_touch())
os.sleep(0.5)
end

au run (monitor right mono) ce programme affiche le hud correctement mais apprer quelques secondes, celui ci m'affiche un message d'erreur...

http://puu.sh/qCida/64dca7b1c3.png

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Kuruyia Lun 15 Aoû - 18:49

Je pense que mettre un sleep réglerait le problème :

Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")

m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)

function mo_touch()
  while true do
    event, side, xpos, ypos = os.pullEvent("monitor_touch")
    if xpos == 3 or xpos == 4 and ypos == 2 then
      r.setActive(true)
    elseif xpos == 45 or xpos == 46 and ypos == 2 then
      r.setActive(false)
    end
  end
end

function test_r()
  while true do
    if r.getActive() then
      m.setBackgroundColor(colors.green)
      m.setCursorPos(4,4)
      m.write("On")
    elseif r.getActive() == false then
      m.setBackgroundColor(colors.red)
      m.setCursorPos(4,4)
      m.write("off")
    end

  -- Ici, pour que le programme souffle un peu
  os.sleep(0.1)
  end
end

function hud()
  paintutils.drawImage(image, 1, 1)
end

while true do
parallel.waitForAny(hud(),test_r(),mo_touch())
os.sleep(0.5)
end
Kuruyia
Kuruyia

Messages : 83
Date d'inscription : 10/04/2016
Age : 23
Localisation : Glitch City

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Lun 15 Aoû - 18:53

c'est cool sa ne crash plus mais maintenant je n'arrive pas a presser sur les boutons.. :'(

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Kuruyia Lun 15 Aoû - 18:57

Tu pourrais essayer ça, je pense que ça devrait marcher :

Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")

m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)

function mo_touch()
  while true do
    event, side, xpos, ypos = os.pullEvent("monitor_touch")
    if xpos == 3 or xpos == 4 and ypos == 2 then
      r.setActive(true)
    elseif xpos == 45 or xpos == 46 and ypos == 2 then
      r.setActive(false)
    end
  end
end

function test_r()
  while true do
    if r.getActive() then
      m.setBackgroundColor(colors.green)
      m.setCursorPos(4,4)
      m.write("On")
    elseif r.getActive() == false then
      m.setBackgroundColor(colors.red)
      m.setCursorPos(4,4)
      m.write("off")
    end

  os.sleep(0.1)
  end
end

function hud()
  paintutils.drawImage(image, 1, 1)
end

hud()

parallel.waitForAny(test_r, mo_touch)
Kuruyia
Kuruyia

Messages : 83
Date d'inscription : 10/04/2016
Age : 23
Localisation : Glitch City

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Lun 15 Aoû - 19:03

super cool mais il n'y a plus de m.clear() ce qui donne sa (dernier problème je crois Very Happy)
:
http://puu.sh/qCjbh/ae5706e764.png

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Kuruyia Lun 15 Aoû - 19:06

Ouais c'est normal, tant que tu écris pas sur un caractère il reste, dans ton cas un simple paintutils.drawPixel fera l'affaire :

Code:
m = peripheral.wrap("right")
r = peripheral.wrap("back")
image = paintutils.loadImage("hud")

m.setBackgroundColor(colors.black)
m.clear()
paintutils.drawImage(image,1,1)

function mo_touch()
  while true do
    event, side, xpos, ypos = os.pullEvent("monitor_touch")
    if xpos == 3 or xpos == 4 and ypos == 2 then
      r.setActive(true)
    elseif xpos == 45 or xpos == 46 and ypos == 2 then
      r.setActive(false)
    end
  end
end

function test_r()
  while true do
    if r.getActive() then
      m.setBackgroundColor(colors.green)
      m.setCursorPos(4,4)
      m.write("On")
      paintutils.drawPixel(6, 4, colors.black)
    elseif r.getActive() == false then
      m.setBackgroundColor(colors.red)
      m.setCursorPos(4,4)
      m.write("off")
    end

  os.sleep(0.1)
  end
end

function hud()
  paintutils.drawImage(image, 1, 1)
end

hud()

parallel.waitForAny(test_r, mo_touch)
Kuruyia
Kuruyia

Messages : 83
Date d'inscription : 10/04/2016
Age : 23
Localisation : Glitch City

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Lun 15 Aoû - 19:25

MERCIIIIIII Very Happy

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Kuruyia Lun 15 Aoû - 19:26

De rien
Kuruyia
Kuruyia

Messages : 83
Date d'inscription : 10/04/2016
Age : 23
Localisation : Glitch City

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par cedmeu Lun 15 Aoû - 23:02

Un petit partage du programme terminé serait sympa pour la communauté de ComputerCraft Smile

cedmeu
Admin

Messages : 493
Date d'inscription : 28/03/2016

https://computercraftfr.forumgaming.fr

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Mar 23 Aoû - 17:25

cedmeu a écrit:Un petit partage du programme terminé serait sympa pour la communauté de ComputerCraft Smile

oui effectivement je le poste dés que possible Very Happy

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Tonitch8 Mar 23 Aoû - 17:29

http://pastebin.com/cPzn7vS0

Tonitch8

Messages : 2
Date d'inscription : 30/03/2016

Revenir en haut Aller en bas

os.pullEvent("monitor_touch") Empty Re: os.pullEvent("monitor_touch")

Message par Contenu sponsorisé


Contenu sponsorisé


Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum