Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 23 17:30
    KiddoV commented #748
  • Jun 23 17:29
    KiddoV commented #748
  • Jun 23 16:37
    jcubic commented #748
  • Jun 23 14:59
    KiddoV commented #748
  • Jun 23 14:57
    KiddoV commented #748
  • Jun 23 14:56
    KiddoV commented #748
  • Jun 23 14:52
    KiddoV commented #748
  • Jun 23 14:51
    KiddoV commented #748
  • Jun 23 14:42
    KiddoV commented #748
  • Jun 23 14:38
    KiddoV commented #748
  • Jun 23 12:54
    jcubic labeled #798
  • Jun 22 19:37
    jcubic opened #798
  • Jun 22 19:37
    jcubic labeled #798
  • Jun 19 19:19
    jcubic commented #707
  • Jun 19 11:53
    jcubic commented #748
  • Jun 19 11:52
    jcubic commented #748
  • Jun 15 18:58
    jcubic edited #792
  • Jun 15 18:57
    jcubic commented #792
  • Jun 15 18:56
    jcubic commented #792
  • Jun 15 18:51
    jcubic commented #792
Jagg3127-alt
@jagg3127-alt
jcubic is there a way i could instead of typing a super long paragraph inside of the logs function could i store the text in a variable then send it out from there of course in php
Jakub T. Jankiewicz
@jcubic
What you mean send? using email?
Jagg3127-alt
@jagg3127-alt
no like using the send command to type it out
Jakub T. Jankiewicz
@jcubic
I don't follow, can you explan in steps?
There is already send that echo stuff. If you don't want the typing of long text you can check the length of the text if it's longer then 10 characters you can print it, or you can check if there are newlines if yes then echo, i no you can use animation.
I'm not sure if I've understood what you want to do
The user have to only type cred, logs and number
Jagg3127-alt
@jagg3127-alt
ok so storing the text in a variable say like $log1
then use that data to type log 1 on the screen cause i plan on having large paragraphs
Jakub T. Jankiewicz
@jcubic
If think You can send as long command as you want and if you want to include long paragraph you can use code like this:
give me sec I need to search the docs
Jagg3127-alt
@jagg3127-alt
ok
Jakub T. Jankiewicz
@jcubic
You can use code like this in PHP:
<?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";
You basically have array of mutline text, and you return string with interpolation using that array.
In your case when you have logs function you can do
<?php
  function logs($token, $choice = null) {
    $this->valid_token($token);
    global $logs;
    if ($choice == null) {
        return '[[ send "1. \\n2. \\n3. ::logs" ]]';
    } else {
      $choice--;
      if (isset($logs[$choice])) {
        $log = logs[$choice];
        return '[[ send "${$log}::logs::1000" ]]';
      } else {
        throw new Error('Invalid choice');
      }
    }
  }
Jakub T. Jankiewicz
@jcubic
or you can just index from 0 and use choice null as 0.
Jagg3127-alt
@jagg3127-alt
ahhhh ok i understand
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