Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 24 23:37
    dragoncoder047 commented #784
  • May 24 22:22
    jcubic commented #784
  • May 24 22:21
    jcubic commented #784
  • May 24 22:21
    jcubic commented #784
  • May 24 21:06
    S1700 commented #784
  • May 24 20:39
    S1700 commented #784
  • May 24 20:00
    jcubic commented #784
  • May 24 20:00
    jcubic labeled #784
  • May 24 20:00
    jcubic commented #784
  • May 24 19:50
    jcubic commented #782
  • May 24 19:48
    S1700 opened #784
  • May 24 16:44
    S1700 commented #782
  • May 24 16:44
    S1700 closed #782
  • May 24 15:23
    S1700 commented #782
  • May 24 07:59
    jcubic commented #782
  • May 24 07:59
    jcubic commented #782
  • May 23 21:44
    dragoncoder047 commented #782
  • May 23 21:43
    S1700 commented #782
  • May 23 21:37
    S1700 commented #782
  • May 23 21:37
    S1700 commented #782
Jakub T. Jankiewicz
@jcubic
IF you want to index from 0 and first item in array is your menu than code is even simpler:
<?php
  function logs($token, $choice = 0) {
    $this->valid_token($token);
    global $logs;
    if (isset($logs[$choice])) {
      $log = logs[$choice];
      return '[[ send "${$log}::logs::1000" ]]';
    } else {
      throw new Error('Invalid choice');
    }
  }
but you will need to remove the delay, sorry default choice shoult not have the number at the end otherwise the menu will disappear after 1 second
Jagg3127-alt
@jagg3127-alt
ok
Jakub T. Jankiewicz
@jcubic
sorry not remove index, remove the delay
Jagg3127-alt
@jagg3127-alt
ok
Jakub T. Jankiewicz
@jcubic
<?php
  function logs($token, $choice = 0) {
    $this->valid_token($token);
    global $logs;
    if (isset($logs[$choice])) {
      $log = $logs[$choice];
      if ($choice == 0) {
        return '[[ send "${$log}::logs" ]]';
      } else {
        return '[[ send "${$log}::logs::1000" ]]';
      }
    } else {
      throw new Error('Invalid choice');
    }
  }
this should work and you only need to fill the $logs array
Jagg3127-alt
@jagg3127-alt
ok i think i understand the code too which is great
Jakub T. Jankiewicz
@jcubic
sorry typo logs need to always have $ in front
Updated
Jagg3127-alt
@jagg3127-alt
ok
Jakub T. Jankiewicz
@jcubic
So far this is pretty adanced usage of the library, I have no idea but I assume not not many people even know that they can control the terminal from server.
I'm very pleased how this ended up, the code is quite short in both PHP and JS
Jagg3127-alt
@jagg3127-alt
so im improving evryone elses knowledge of your terminal plugin?
Jakub T. Jankiewicz
@jcubic
yes
Jagg3127-alt
@jagg3127-alt
yay im helpful
Jakub T. Jankiewicz
@jcubic
PS: I think that you have messed up the git repo, you have nested main directory, the project should all be in main directory
Maybe you use clone inside a repo and another in same repo and it create nested directories
Jagg3127-alt
@jagg3127-alt
yeah ik ill fix it in a second im still fixing a couple things with the code itself
Jakub T. Jankiewicz
@jcubic
Will you delete that repo after you've done? Will you publish end result online, for public view?
I would be able to link to it from the website as an example
Jagg3127-alt
@jagg3127-alt
ill publicly show it to help your code a little
Jakub T. Jankiewicz
@jcubic
If you don't want to show the git repo (like delete it when you've done, or change it to private) then I will need to replicate your code. The code was done all by me so I think that it's fair for me to use it as example. Of course will change the logic it will not be identical to yours.
Jagg3127-alt
@jagg3127-alt
i dont care what you do but im going to keep it public add a read me linking to your github, gitter, and main website
Jakub T. Jankiewicz
@jcubic
awesome thanks
Jagg3127-alt
@jagg3127-alt
no problem it was done mostly by you
Jakub T. Jankiewicz
@jcubic
And also If you want to make it a game where people will want to escape I will make it all online, make the manual somewhere online to people can find it and solve the puzzle. The end can be a way to allow users to save his username in leader board and say something like in Guest Books that was a thing long ago in early web.
Jagg3127-alt
@jagg3127-alt
ill plan ill doing that thanks for the advice i might even make it more of an rpg web game
Jakub T. Jankiewicz
@jcubic
Or at the end user can send a tweet that he solve the puzzle with a link to a puzzle
Jagg3127-alt
@jagg3127-alt
hmmm i have plans big ones too
Jakub T. Jankiewicz
@jcubic
If you're interested I was planed to implement game engine for creating text based advanture games:
https://github.com/jcubic/gaiman
but it's been a while since I was working on it. THe idea is to have simple langauge that compile to advanced usaing of jQuery Terminal
I also wanted to make it work on real terminal
Jagg3127-alt
@jagg3127-alt
ahhhhhhhhhhhhh thanks i could make it work, ill love to have a colab
if you want
Jakub T. Jankiewicz
@jcubic
But the problem with gaiman is that it's all in browser, it generate game that don't have a server (like your PHP code). The idea came from other person that I was helping I've create something like engine to create games but the input for the game was one big JSON file.
Sorry but I don't think it will be possible I will need to do all the work, because you don't know how to code
Jagg3127-alt
@jagg3127-alt
incorrect i know how to code javascript html css you just didnt have much info on your plugin
and now php thanks to you
Jakub T. Jankiewicz
@jcubic
The PHP code that give last have nothing to do with the library. It's just basic of programming in PHP you if you can write this on your own and need help, it mean that you don't know how to code
Jagg3127-alt
@jagg3127-alt
i know now ok i didnt know php
Jakub T. Jankiewicz
@jcubic
this is basic logic, I know that there was lot of advenced stuff of the library but there was like basic coding in PHP and JavaScript
Jagg3127-alt
@jagg3127-alt
ok maybe the book i used to learn was not effective at all
ill re learn javascript
Jakub T. Jankiewicz
@jcubic
You didn't even know how to copy paste code that I give you, you copied it into middle of the code in random place and it was totally broken
Jagg3127-alt
@jagg3127-alt
ok that was just me being stupid
Jakub T. Jankiewicz
@jcubic
Example is this code, that I had to write:
<?php

$logs = array(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Praesent id nisl at magna tristique ullamcorper sit amet quis dolor.
Nulla quis leo luctus, elementum massa vitae, ultrices diam.
Quisque eu quam ut elit imperdiet gravida.
Integer mollis condimentum libero, varius pretium justo ullamcorper in.",
"something else"
);

function foo() {
  global $logs;
  return "${logs[0]}";
}

echo foo();
echo "\n";
this just mega basics of PHP array of strings and string interpolation.
Jagg3127-alt
@jagg3127-alt
i didnt know php i shouldve learned im so sorry
Jakub T. Jankiewicz
@jcubic
Oh, sorry that's right, you didn't said that you know php