Computercraft coding - Help please

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Ocker

New Member
Jul 29, 2019
441
0
0
Hi I have a simple (hopefully) question regarding computercraft.

I have set up a spawning room similar to the season 6 Direwolf20 void age room but I want to be able to handle the names of the mobs differently.

The basics are a chest containing safari nets is searched and the safari net data "captured" value is displayed on buttons on the screen, and it shows things like "thaumcraft.Pech" and longer names for other mobs which are hard to fit to a button and I also want to be able to select sheep by colour but the name comes up only as "sheep".

I thought there may be a way similar to the MS Excel right(x) command that returns the right hand requested characters to solve the first problem but cant find a solution to the second apart from creating a screen with set labeled buttons that get the mob from a designated slot.

Is there a command like right() or any other ideas would be appreciated

BTW I tried renaming the safari net with the mob in it - fail
and a name tag on the mob before capturing - fail
 

Ocker

New Member
Jul 29, 2019
441
0
0
I think your suggestion is a solution to both problems and may have been the simplest way, but I have just solved the wool problem by making a new table with buttons for each color that link to the correct slot and I am happy with that.
So the only problem now its long names for twilightforest. etc. I would really like to be able to add new safari nets and the computer will find them and create a button without having to add names to arrays each time. So something that will truncate the name is my hope.
Thanks for replying
 

Ocker

New Member
Jul 29, 2019
441
0
0
Thats Neils, As I said in the first post "I tried renaming the safari net with the mob in it - fail" but you have just made me rethink that, the data that I am taking from the safari net via my programming (DireWolf20's actually) is ".captured" and the mob that is captured is the same regardless of the "name" of the safari net - I am about to see if the safari net that I renamed shows the change under something else. Thanks

Thank you very much - changed to ".name" and this works :p
 
Last edited:
  • Like
Reactions: Niels Henriksen

Ocker

New Member
Jul 29, 2019
441
0
0
Hi Neils (if your still monitoring) I have another simple (if you know the answer) problem.

I have added buttons to a the Mob Select menu that I want to replicate the Main menu buttons and have no idea how to transfer the "state" of the button between the menus. To clarify the "Main menu" has, along with other buttons, a "grinder" on(green)/off(red) and same for "spawner". I want to have those buttons available on the "Mob Select" menu and retain and display the state they were in on the other menu.

If you have time and you need more info I have the code on pastebin.com/zCY4DVTf The new buttons are at lines 68 and 69, they display and work (I fixed my "spawnser" spelling error in the code) but show the opposite color. ie my grinders startup position is running (green) and my swawner is not running (red) but when I change menus the buttons are both red and the grinder is running so turning on the button (green) turns off the grinder

I am also trying to do a similar thing on the third menu "wool select" but only with "Spawner" but have not added the button yet, I figure having the solution to one solves the other.

ODDLY - to me anyway, as I am testing while I write I have discovered the "state" does transfer back to the main menu and the state is correct. So

Coding is annoying - you start just wanting to make something do what you want and then when it does you see other possibilities.
 

Niels Henriksen

New Member
Jul 29, 2019
502
0
1
I have added buttons to a the Mob Select menu that I want to replicate the Main menu buttons and have no idea how to transfer the "state" of the button between the menus.

You need to keep the current state of the button in a variable: eg. isPressed and then you can read if its true or false.

Coding is annoying - you start just wanting to make something do what you want and then when it does you see other possibilities.

I can give you 3 clues on how to make programming best: planning, planning and planning :) It has been my work for 16 years now and yes.... you start one place and suddenly are anohter place you didnt expect.
 

Ocker

New Member
Jul 29, 2019
441
0
0
Thanks again Niels, I will look into that and let you know how I go with it.
 

fandacreep

New Member
Jul 29, 2019
15
0
0
I can give you 3 clues on how to make programming best: planning, planning and planning :) It has been my work for 16 years now and yes.... you start one place and suddenly are anohter place you didnt expect.
Don't forget the research, too many people just start coding without knowing anything. :/