[Mod] basic_robot [basic_robot]

User avatar
rnd
Member
Posts: 220
Joined: Sun Dec 28, 2014 12:24
GitHub: ac-minetest
IRC: ac_minetest
In-game: rnd

Re: [Mod] basic_robot [basic_robot]

by rnd » Post

Code: Select all

I would suggest just using sethook to set up a count hook. It will run much faster than inserting function calls everywhere,
1. i know, but he intentionaly disables luajit otherwise counts dont register ( look at his code ). so is a question how much faster it really is, cause is not luajit. Plus is fun to modify code this way ..

2. can you give me concrete example how to run code in other thread in lua(jit)
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] basic_robot [basic_robot]

by Byakuren » Post

Here's an example:

Code: Select all

local function bad()
        while true do
        end
end

-- Need this if you have luajit (only turns it off for the function)
if jit then
        jit.off(bad, true)
end

local thread = coroutine.create(bad)
debug.sethook(thread, function() error("Spent too much time") end, "", 10000)
print(coroutine.resume(thread))
Output:

Code: Select all

➜  temp luajit blah.lua
false   blah.lua:12: Spent too much time
I also used the C version of sethook to implement preemptive scheduling in my new computers mod. I had to use the C API because hooks set from Lua cannot yield through the hook.
Every time a mod API is left undocumented, a koala dies.

User avatar
rnd
Member
Posts: 220
Joined: Sun Dec 28, 2014 12:24
GitHub: ac-minetest
IRC: ac_minetest
In-game: rnd

Re: [Mod] basic_robot [basic_robot]

by rnd » Post

updates:

-gui redo
-has library inventory, containing 32 books
-can read books or write to them
-can compile code from books and run it
-can work with inventories ( take coal from chest, walk to furnace, put it in furnace)
-can attach listener to robot that stores last chat message and retrieve it later

new gui and math quiz bot
Image
Attachments
math_quiz.jpg
math_quiz.jpg (51.5 KiB) Viewed 857 times
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

rnd wrote:update: fixes, can sense players around, new direction forward_down for place and read_node..
Nice - but at github, the latest commit c51bf32 doesn't have those features, and also no updated gui etc.

BTW, can the robot query his own state, like direction he is facing or hp ?
Also, some pause/walt/sleep would be nice (as opposed to "turn.left(20)" or similar).

As a quick fix for the "dig.down()"-problem, how about treating the spawner as protected ?

User avatar
rnd
Member
Posts: 220
Joined: Sun Dec 28, 2014 12:24
GitHub: ac-minetest
IRC: ac_minetest
In-game: rnd

Re: [Mod] basic_robot [basic_robot]

by rnd » Post

updates:
remote control - programmable : when you use it anything can happen

example of remote controlled gun that can be rotated, shoot and move forward using 4 remote controls: turret left, fire, turret right, move forward

Image

when you use control a projectile is fired ( fire code )
Image
Attachments
remove_control 2.jpg
remove_control 2.jpg (78.15 KiB) Viewed 857 times
remove_control.jpg
remove_control.jpg (82.43 KiB) Viewed 857 times
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

For the command 'place.up("default.torch")',
I got the errormessage "attempt to index a nil value".

Sure, the item to be placed should have been "default:torch",
but with the font used in the formspec, the difference is hard to see,
and the text of the errormessage is not very helpful.

So, before place(), a check for valid items seems to be in order.
Probably with an option "may place anything" / "place only items from inventory".
rnd wrote:-has library inventory, containing 32 books
-can read books or write to them
The spawner cannot be picked up when items are still in its inventory or library.
I'm not sure how that is supposed to work - moving all stuff in&out every time would be impractical.
I had assumed the library-books would be located in a bookshelf at the players home.


Also, good work !
This has been an amazing progress in the last few days.

User avatar
rnd
Member
Posts: 220
Joined: Sun Dec 28, 2014 12:24
GitHub: ac-minetest
IRC: ac_minetest
In-game: rnd

Re: [Mod] basic_robot [basic_robot]

by rnd » Post

1.
hajo"]For the command 'place.up("default.torch")',
I got the errormessage "attempt to index a nil value".
if you play as "admin" it doesnt check if item is in inventory, it just gives it

2. if i were allow spawner dig with stuff in it, comments would be:

omg, i had so much books and stuff, now its all gone. The quickest way to remove spawner is just eat it with another robot
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

rnd wrote:1.
hajo"]For the command 'place.up("default.torch")',
I got the errormessage "attempt to index a nil value".
if you play as "admin" it doesnt check if item is in inventory, it just gives it
Instead of an option, you could just check if game is running in creative-mode.

But my point was that mis-spelled items don't give a meaningful error.
2. if i were allow spawner dig with stuff in it, comments would be:
omg, i had so much books and stuff, now its all gone.
Yes, but then the user has to carry around his library-books in his inventory,
and plug/unplug them into the spawner every time he goes to some other place.

Why not look for books with titles like "library X" in the users bookshelf ?

Also, I set up a github-account, and made a little patch,
to add description.txt, and top/front-textures for the cpu-box.

I haven't used github yet, so I hope that's the correct way to do collaboration here.


Also, I had the robot digging stairs downward, and it has already found
several "ignore"-blocks. Mapgen used was v5.

Edit:
I made a "User-documentation"-page on the wiki,
with some example-programs as an introduction.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

hajo wrote:I made a "User-documentation"-page on the wiki,
with some example-programs as an introduction.
I also figured out how the remotecontrol works,
and made an new chapter about it.

Github is still missing the texture for the control,
and sometimes the form doesn't come up when rightclicking an rc.

The manual-mode of the remote is very useful to get the bot
to a new place to do some action (without pickup/place spawner, re-enter program, etc).

I was thinking of an alternate layout, e.g.

Code: Select all

TLeft   FWD   TRight
DigUp   Up    BuildFwd
DigFwd  Down  BuildDownFwd
DigDown info  Action/change build-stuff
but how about a table of strings (filled with some default),
where each button just gets a text and a line of code ?
So the player just needs to change that table to customize his remote.
This setting would also make a good candidate for saving into a library-book.

Also, it would be nice if the remotes could have different names,
and maybe colors, to tell them apart.

Can the robot sense mobs as well as players ?
Last edited by hajo on Wed Nov 23, 2016 20:17, edited 2 times in total.

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [Mod] basic_robot [basic_robot]

by Desour » Post

hajo wrote: Also, I set up a github-account, and made a little patch,
to add description.txt, and top/front-textures for the cpu-box.

I haven't used github yet, so I hope that's the correct way to do collaboration here.
its not, make a pull request on github
hajo wrote: Also, I had the robot digging stairs downward, and it has already found
several "ignore"-blocks. Mapgen used was v5.
so, it got "ignore" items in storage. unloaded mapblocks are made of ignore nodes. the robot dug into an unloaded mapblock.
hajo wrote:sometimes the form doesn't come up when rightclicking an rc.
the formspec doesnt come if you are pointing a node while right clicking
this is good, you can right click nodes with rc
hajo wrote:Also, it would be nice of the remotes could have different names,
and maybe colors, to tell them apart.
this isnt possible that easy
hajo wrote:Can the robot sense mobs as well as players ?
only players, i think
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

DS-minetest wrote:make a pull request on github
I think I did, but then there was no further activity (on github and here),
so I just assumed everybody was busy elsewhere.
hajo wrote:it would be nice of the remotes could have different names,
and maybe colors, to tell them apart.
this isnt possible that easy
Maybe just use a bunch of colored textures (like the wool-colors)
or at least different textures for empty-rc and rc-with-code (like book/with text) ?

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [Mod] basic_robot [basic_robot]

by Desour » Post

hajo wrote:
DS-minetest wrote:make a pull request on github
I think I did, but then there was no further activity (on github and here),
so I just assumed everybody was busy elsewhere.
hajo wrote:it would be nice of the remotes could have different names,
and maybe colors, to tell them apart.
this isnt possible that easy
Maybe just use a bunch of colored textures (like the wool-colors)
or at least different textures for empty-rc and rc-with-code (like book/with text) ?
there are no open pull requests https://github.com/ac-minetest/basic_robot/pulls
you would have to add many new items : |
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] basic_robot [basic_robot]

by Byakuren » Post

I noticed the earlier freeze exploit I posted doesn't work. I found two more, and I've tested in-game that they will freeze the game: https://github.com/ac-minetest/basic_robot/issues/5
Every time a mod API is left undocumented, a koala dies.

User avatar
rnd
Member
Posts: 220
Joined: Sun Dec 28, 2014 12:24
GitHub: ac-minetest
IRC: ac_minetest
In-game: rnd

Re: [Mod] basic_robot [basic_robot]

by rnd » Post

updates:
-remote control displays move/dig controls in case there are no user set commands
-better ingame help
-robots can now send messages to each other with self.send_mail and read them with read_mail
-fixes various sandbox exploits ( thanks to Byakuren for discovering them)
-fixes string modification problem, i.e. can use stuff like say("while i<5 do say(1)") inside programs
-robot can now only dig limited number of nodes per operation ( default 1) to make programming dig operations more interesting

remote control movement/dig commands
Image
Attachments
robot_control.jpg
robot_control.jpg (71.46 KiB) Viewed 857 times
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] basic_robot [basic_robot]

by Byakuren » Post

You closed the Github issue without solving all the freeze exploits. Did you even test that they were fixed?

In particular, this one

Code: Select all

while (function(f) return f(f) end)(function(f) return f(f) end) do print("a") end
will still freeze the server.
Every time a mod API is left undocumented, a koala dies.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

DS-minetest wrote:there are no open pull requests https://github.com/ac-minetest/basic_robot/pulls
I made a fresh attempt, starting with basic_robot v11/26a.

* Texture for front and top of cpubox, to show the direction robot would point when spawned
* Texture for the remotecontrol
* Save-button now doesn't exit, so you can go on to press Start without another click on spawner
* write entry to logfile "robot started"
* "GO" --> "FWD"
* bigger/wider textbox for help
* empty lines before each chapter
* added "function" to helptext
* slightly bigger editbox for rc - now 7 lines, and shows frame of box at bottom
* added type() to list of sandbox-functions
* some formatting/aligning of code
* added metafiles for mod, e.g. depends.txt and description.txt
* (still missing a good,small screenshot.png, showing spawner+robot+rc)

As the texture for the remote was missing on github (so mt makes up a green blob),
I whipped up something based on the rc from kaeza's rc-car (CC-BY-SA).

Edit:
I noticed some issues with the robot's inventory:
* the itemcount is not always correct
** e.g. the bot digs 2 oreblocks, but only 1 ore shows up in inventory
* moving stuff from one space to another doesn't always work
* moving stuff with shift-click doesn't work

Also, I checked the new Minetest 0.4.14-785a9a6 by sfan5 - 2016-11-26.

It comes packaged with the games Carbone-ng and Voxelgarden,
and when run with basic_robot, I get some messages:

Code: Select all

WARNING[Server]: Assignment to undeclared global "placename" inside a function at ...test-0.4.14_785a9a6\bin\..\mods\basic_robot/commands.lua:217.
..
WARNING[Server]: Assignment to undeclared global "script" inside a function at ...minetest-0.4.14_785a9a6\bin\..\mods\basic_robot\init.lua:1057.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

I have been playing a bit with TurtleMiner, and it has
a rather nice editor with tabs, that supports multiple 'files'.

I think that editor would be a good addition to basic_robot.

In fact, it enhances the usefulness of those turtles,
almost like a remote with programmable buttons.

rgh
Member
Posts: 46
Joined: Fri Oct 07, 2016 13:32

Re: [Mod] basic_robot [basic_robot]

by rgh » Post

Do robots stop working when they get a certain distance away from their owner, or an observer?

The first thing I tried was just building an endless column. The robot seems to go up & then stop. However, If I fly up alongside it, the robot continues.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

rgh wrote:Do robots stop working when they get a certain distance away from their owner, or an observer?

The first thing I tried was just building an endless column. The robot seems to go up & then stop.
However, If I fly up alongside it, the robot continues.
Same problem as above:
the robot got to an unloaded mapblock.
When you are around, the server keeps loading them.

User avatar
rnd
Member
Posts: 220
Joined: Sun Dec 28, 2014 12:24
GitHub: ac-minetest
IRC: ac_minetest
In-game: rnd

Re: [Mod] basic_robot [basic_robot]

by rnd » Post

robots are minetest entities and will as such vanish when noone is around - but they will reactivate and restart once players come nearby. You can save/recall data using the self.send_mail/self.read_mail feature

ONLINE PLAY: possible on ROBOTS server

UPDATES:

0. everything now works with 0.4.15, added lots of features like: robot can read/write text to other blocks, admin robot (can run any minetest command, but only admin can edit its code), ability to grab players, ability to receive/send other robots data ("email")...

1.improved library (contains books, robots can read/write persistent data to books), can use remote library now. Library shows list of books with titles, double click title to see book contents
Image

2. normal players can have up to 2 robots while players with "robot" priv can have up to 16. Simply enter id inside spawner or remote control to choose which robot to activate/control.
Image

3. it is possible to do interesting games with available features: here 2 players can do battle with tanks that shoot fire. If you hit nearby enemy player their tank is destroyed. You can control direction and pitch of fire, other parameters are random
Image
Attachments
robot3.jpg
robot3.jpg (33.74 KiB) Viewed 857 times
robot2.jpg
robot2.jpg (72.38 KiB) Viewed 857 times
robot1.jpg
robot1.jpg (65.98 KiB) Viewed 857 times
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

User avatar
ManElevation
Member
Posts: 896
Joined: Tue Aug 02, 2016 22:04
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation
Location: Madrid,Spain

Re: [Mod] basic_robot [basic_robot]

by ManElevation » Post

thats cool ;), Happy Xmas rnd
My Public Mods! Discord: Rottweiler Games#3368

rgh
Member
Posts: 46
Joined: Fri Oct 07, 2016 13:32

Re: [Mod] basic_robot [basic_robot]

by rgh » Post

hajo wrote: Same problem as above:
the robot got to an unloaded mapblock.
When you are around, the server keeps loading them.
Is is predictable what happens when that occurs? When I experimented (0.4.14) having a robot build a never ending column, sometimes the robot was paused at the top & resumed building when I flew up to look at it, sometimes the robot had I think vanished from the top.

User avatar
rnd
Member
Posts: 220
Joined: Sun Dec 28, 2014 12:24
GitHub: ac-minetest
IRC: ac_minetest
In-game: rnd

Re: [Mod] basic_robot [basic_robot]

by rnd » Post

Is is predictable what happens when that occurs?
all minetest objects hide when no player around. areas will unload after some time if noone around.

Robot always checks what its moving into. It cant move into solid wall for example. If it tries to move into unloaded area, it sees that node name is "ignore" and stops. Same with digging - it wont dig "ignore" nodes.
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

rgh
Member
Posts: 46
Joined: Fri Oct 07, 2016 13:32

Re: [Mod] basic_robot [basic_robot]

by rgh » Post

ok, but when a chunk reloads, any robot in that chunk should reappear where it last was?
It can't get somehow moved back to the robot spawner from which it came?

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

rgh wrote:It can't get somehow moved back to the robot spawner from which it came?
Just press the stop-button.
Then press Start/Run to get a fresh robot at the spawner.

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests