[Mod] basic_robot [basic_robot]

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:UPDATES:
0. everything now works with 0.4.15, added lots of features
Thanks - that is an impressive list.
3. 2 players can do battle with tanks that shoot
I'm not into PvP.
Can the bots detect and shoot at mobs too ?
Ballistic shooting in 3D (i.e. at ghosts) might be a fun challenge...

Also, I made a fork/patch/pull-request some time ago.
Did you notice it, were there any problems with it ?

Edit:
I was just checking the programs from my tutorial with the new version,
and noticed that some simple programs now don't work as expected,
e.g. RC4b - Dig6

Code: Select all

--Dig one block in every direction
dig.forward()  dig.backward()
dig.left()  dig.right()
dig.up()   dig.down()
does only 1 or 2 digs when run.
So, it probably ran against basic_robot.maxdig

Likewise, Build3 runs against the execution-limit.

How exactly should a program check for success/errors/restrictions ?

I think it would be nice to have at least some more feedback,
e.g. instead of

Code: Select all

return false
also return a message, like

Code: Select all

return false, "exceeded maxdig"
So, I came up with Build3a, that is essentially a turtle/l-system - interpreter
with some canned example-programs for building houses.
How about putting something like that interpreter into the standard basic_robot ?

The exact instruction-set for that interpreter is of course open for discussion.
The one in Build3a uses too many instruction-chars for digging and building, so
perhaps "build with material #0=air means digging", to streamline the set of commands.

I also would like to add simple macros, e.g. ":x=[fff>]" to define char x as a macro for "fff>".
And maybe "*4x" for repeating an instruction, and something like
"?xy" for 'check condition, if true do x, else do y'.
Also, a stack and/or a few registers :)

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

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

As it turns out, buttons can have colored text.
And the remote didn't have buttons for placeing/building,
so I added them - see wiki:
Image

Also, I noticed that read_book() only return the contents, not the title.
Is there a reason for that?
The book-lister in the spawner/library lists titles just fine.

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: too much too list, just some stuff. To see new features visit ROBOTS server.
- rom to store persistent robot data ( persistent between robot restarts, clears only on server shutdown)
- robots have now built in console that can display 256 modified ascii chars
Image

Code: Select all

if not s then s=1;text = ""; for i=0,255 do text=text..string.char(i) end; self.display_text(text,16,1) end
- robots can activate things
- robot with id 0 wont spawn entity and can be used as a powerful CPU - it only runs when activated by mesecons/basic_machines signal
-------------------

1. i want to keep robots as simple as possible. This means very basic system without "featuritis".
Robot coding is kept simple - it just runs the code 1x per second - thats it. If you want to do stuff that only runs 1x you can just use lua property: variables are nil until value is given and write

Code: Select all

if not init then DO STUFF init = true end
that takes good care of init. If something needs to be added you can make admin robot that implements it and sends program to client robots ( yes thats possible too )

2. digging its not bugged - its intentionaly limited to 1 dig per operation. before that i had players dig 32 or more blocks each operation causing BIG LAG GRIEF in mines. no thx..

3. l-system is nice, good work. I will add area for robot programs on github. Btw admin robot can run any minetest/lua command so there is nothing you cant do with it. On ROBOTS server there is for example SHOP robot and even property selling robot which will make you owner of protector you buy.

4. If you use basic_machines mod you can use keypad machine as an input device for robot ( keypad writes your input to block, robot reads it)
Attachments
robot_display.jpg
robot_display.jpg (120.81 KiB) Viewed 1257 times
Last edited by rnd on Fri Jan 13, 2017 13:37, edited 1 time in total.
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

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

robot shop on ROBOTS server
-it scans nearby shops to know what to sell/buy
-use chat commands to buy stuff
-displays time and prices on large display

Image
Spoiler

Code: Select all

if not s then
	s=0;item = 1; price =""; buyer = ""
	_G.minetest.forceload_block(self.pos(),true)
	_G.basic_robot.data[self.name()].obj:set_properties({nametag = ""})
	self.listen(1);self.spam(1)
	shoplist = {};
	--scan shops:
	pos = self.pos(); pos.y=pos.y-5; pos.x=pos.x-6
	pos1 = {x=pos.x-8,y=pos.y-2,z=pos.z-8};pos2 = {x=pos.x+8,y=pos.y+2,z=pos.z+8};
	local shoppos = _G.minetest.find_nodes_in_area(pos1, pos2, "shop:shop");
	--say("scanning... i found " .. #shoppos .. " shops ");
	count = 0
	for _,p in pairs(shoppos) do
		local inv = _G.minetest.get_meta(p):get_inventory()
		local s = inv:get_list("sell");local b = inv:get_list("buy")
		local k = s[1]:to_string();
		local v = b[1]:to_string();
		count = count +1
		if (k and k~="") and (v and v~="") then shoplist[count] = {k,v}  end
	end
	
	--say(_G.dump(shoplist))
	itemlist = ""; count = 0;
	shopinventory = {};
	for k,v in pairs(shoplist) do
		if v[1] then
			count = count +1
			itemlist = itemlist .. "ITEM " .. k .. ": " .. v[1] .. " PRICE " .. v[2] .. "\n";
		end
	end
	t = 0; ct = 0;	ci = 0
	say("scanning shops ... completed. Added " .. count .. " items for sale ");
end


ct=ct+1
if ct%5 == 0 then
	ct=0
	ctext = "say #shop to buy";
	if ci>0 and ci<=count then
		if shoplist[ci] then
			iname = shoplist[ci][1];local p=string.find(iname,":");	if p then iname = string.sub(iname,p+1) end
			sname = shoplist[ci][2];p=string.find(sname,":");	if p then sname = string.sub(sname,p+1) end
			ctext = "#SHOP ".. ci .."\n" ..iname .. "\nPRICE\n" .. sname
		end
		ci=ci+1
	elseif ci == count+1 then ci=0
	elseif ci == 0 then ci=1
	end
	
	text = "SHOP ROBOT"..os.date("%x") .."  " .. os.date("%H:%M:%S").. "\n\n"..ctext
	self.display_text(text,10,3);
end

speaker,msg = self.listen_msg()

	if s == 0 then
		if msg and string.sub(msg,1,5)=="#shop" then
			if msg == "#shop" then
				say("say #shop command, where command is list OR item number. Example: #shop list or #shop 1")
			elseif string.sub(msg,7) == "list" then
				local form = "size [8,7] textarea[0,0;8.6,8.5;shlist;SHOP LIST;".. itemlist.. "\n\nsay #shop 1 to buy item 1]"
				_G.minetest.show_formspec(speaker, "robot_shop", form);
				--say(itemlist)
			else
				local select = tonumber(string.sub(msg,7)) or 1;
				if shoplist[select] then
					item,price = shoplist[select][1],shoplist[select][2]; s=1;
					buyer = speaker;
					_G.minetest.chat_send_player(speaker,"#SHOP ROBOT: you want to buy " .. item .. " for price " ..  price .. ". say yes if this is correct"); s=1; t = 0;
				else
					_G.minetest.chat_send_player(speaker,"#SHOP ROBOT: select valid item")
				end
				
			end
		end
	elseif s == 1 then 
		if msg~="yes" then 
			t=t+1; if t>10 then say("timeout. trade cancelled."); s = 0 end
		else
			
			local player = _G.minetest.get_player_by_name(buyer);
			if player then
				local inv = player:get_inventory();
				if inv:contains_item("main", price ) then 
					inv:remove_item("main",price)
					inv:add_item("main",item)
					_G.minetest.chat_send_player(buyer,item .. "#SHOP ROBOT: sold to " .. buyer .. " for " .. price)
				else 
					_G.minetest.chat_send_player(buyer,"#SHOP ROBOT: you dont have " .. price .. " in inventory ")
				end
			end
			s=0
		end
end
Attachments
robot shop.jpg
robot shop.jpg (102.18 KiB) Viewed 1257 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:UPDATES: too much too list, just some stuff.
No update on github yet.
To see new features visit ROBOTS server.
When is it usually online,
is there a webpage for the server ?
1. i want to keep robots as simple as possible.
This means very basic system without "featuritis".
This robot with the current design is way beyond "basic". (*)
OTOH, it still needs some more features. (**)
Seriously, we should consider splitting it into a "basic" and an "advanced" fork.
2. digging its not bugged - its intentionaly limited to 1 dig per operation.
before that i had players dig 32 or more blocks each operation causing BIG LAG GRIEF in mines. no thx..
It is, from the viewpoint of a schoolkid / programmer-newbie.
I understand the motivation, but the player needs a way to check.

Maybe use "action-points per second",
and a command to just wait until enough are available again ?
4. If you use basic_machines mod you can use keypad machine as an input device
I will try that.

(*) For "basic features", look at turtleminer: just move/turn/mine/build, and a remote.
It still needs commands to set which stuff to build.
Also yet missing are all the control-structures, and lua.
Nevertheless, it can be used as a flexible, programmable mining-tool.

(**) There are some 'simple' tasks that cannot be done with the current commands, e.g. :
  • * Follow / Move to the player (simple move in the direction, and follow terrain up/down)

    * "Look around, run to the next torch / red flower / fully-grown wheat"
    (direct line/shortest path, as opposed to blind area-search)
    - this needs a variant of read_node() for nodes a few blocks away

    * "If ore X is in range, move/dig towards it, and mine it." (might need flying / support-building)

    * Look for mobs / sound alarm / shoot at them (Guard / watchdog)

    * Custom skin for the robot - maybe include the textures from existing mobs,
    such as Workers and/or CUTE CUBIC MOBS just to choose as skins ?

    * play error-sound
Including rubenward's editor (persistent, multifile) would be very useful,
as well as simple, user-configurable remote.

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

* Follow / Move to the player (simple move in the direction, and follow terrain up/down)

* "Look around, run to the next torch / red flower / fully-grown wheat"
(direct line/shortest path, as opposed to blind area-search)
- this needs a variant of read_node() for nodes a few blocks away

* "If ore X is in range, move/dig towards it, and mine it." (might need flying / support-building)

* Look for mobs / sound alarm / shoot at them (Guard / watchdog)

* Custom skin for the robot - maybe include the textures from existing mobs,
such as Workers and/or CUTE CUBIC MOBS just to choose as skins ?

* play error-sound
players on server already did all of this and much more ingame with robots. If it isnt included, do it yourself; ingame - means no mod change just write program for 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:
* "Look around, run to the next torch / red flower ..
- this needs a variant of read_node() for nodes a few blocks away
* Look for mobs ..
* Custom skin for the robot
players on server already did all of this and much more ingame with robots.
If it isnt included, do it yourself; ingame - means no mod change just write program for robot.
You mean accessing the minetest-api directly ?
How would that work, without breaking out from the sandbox ?

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

There is mail system and robot placed by admin can access global enviroment _G. So it is possible for admin robot to simply send anything other robot might need - like minetest.sound_play for example - it works like client/server
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:There is mail system and robot placed by admin can access global enviroment _G.
That is fine for singleplayer.
So it is possible for admin robot to simply send anything other robot might need
This system is very flexible, because it makes available the whole minetest-api.
OTOH, it needs a system to announce/document what is available where, and how.

I looked at a few of the robots stationed at your server, and it is impressive
what they do.

But to make all that accessable and useful, to more than some developers,
that needs a lot of documentation, examples with comments etc.

I haven't seen any documents etc. outside your github-download,
so my tutorial-page at the wiki was an attempt to improve on that.

But I think there must be more docs somewhere ?

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

There is complete reference inside robot
Image
so you can quickly see the commands and what they do
Image

UPDATES:
-keyboard events for robot: place special key blocks that intercept punch events. Robot can read those and react to them. Here a simple demo sokoban like game where you push blocks around with simple rules: when block lands it takes the color of bottom block, unless it lands on yellow. Red blocks are immovable. Goal is to make all blocks blue.
Image

code for game
Spoiler

Code: Select all

if not s then
	s=1
	draw_chessboard = function()
		pos = self.spawnpos(); pos.y=pos.y+1; pos.x = pos.x-4; pos.z=pos.z-1;
		for i = 1,8 do for j =1,8 do
			local type = ((i+j)%2)+1
			keyboard.set({x=pos.x+i,y=pos.y,z=pos.z-j},type)
		end	end
	end
	--draw_chessboard()
end

event = keyboard.get()
if event then 
	
	p = player.getpos(event.puncher);
	q = {x=event.x, y=event.y, z=event.z};
	if p.y<q.y and p.y>q.y-2 then -- correct height
		self.label(event.type)
		dir = 0
		if math.abs(p.x-q.x) < 0.5 then 
			if p.z>q.z and p.z<q.z+1 then dir=-1 elseif p.z<q.z and p.z>q.z-1 then dir=1 end
		elseif math.abs(p.z-q.z) < 0.5 then 
			if p.x>q.x and p.x<q.x+1 then dir=-2 elseif p.x<q.x and p.x>q.x-1 then dir=2 end
		end
		
		if dir~=0 and event.type~=3 then
			canmove = true; node = ""
			if dir == 1 or dir == -1 then q.z=q.z+dir else q.x = q.x+dir/2 end
				
				if keyboard.read(q)=="air" then 
					node = keyboard.read({x=q.x,y=q.y-1,z=q.z})
					if node =="air" then canmove = false end 
				else
					q.y=q.y+1;if keyboard.read(q)~="air" then canmove = false else node = keyboard.read({x=q.x,y=q.y-1,z=q.z}) end
				end
			
			if canmove then	
				if node == "basic_robot:button8080FF" then event.type = 5
				elseif node == "basic_robot:buttonFFFFFF" then event.type = 1 
				elseif node == "basic_robot:button808080" then event.type = 2
				elseif node == "basic_robot:buttonFF8080" then event.type = 3
				elseif node == "basic_robot:button80FF80" then event.type = 4
				--elseif node == "basic_robot:buttonFFFF80" then event.type = 6
				end  
				keyboard.set({x=event.x,y=event.y,z=event.z},0);keyboard.set({x=q.x,y=q.y,z=q.z},event.type) 
			end
		end
	end
end
Attachments
robot keys.jpg
robot keys.jpg (72.46 KiB) Viewed 1257 times
robot_help.jpg
robot_help.jpg (55.71 KiB) Viewed 1257 times
robot_help_0.jpg
robot_help_0.jpg (63.23 KiB) Viewed 1257 times
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

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

UPDATE:
-prevention of infinite loops/recursion:
replaced "expensive" function call to check that steps weren't exceeded with cheap conditional "if" checking sandbox local variable. This should give considerable speed increase
- builtin book browser/editor/code loader
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: ..
Nice !
- builtin book browser/editor/code loader
I need to look at that part some more,
see also debug-screenshot

Brummi
Member
Posts: 41
Joined: Fri Mar 25, 2016 07:21

Re: [Mod] basic_robot [basic_robot]

by Brummi » Post

Ein Mesesignal lässt den Server crashen.

Code: Select all

ERROR[Main]: stack traceback:
ERROR[Main]: ...Minetest-Survival\bin\..\mods\_test\basic_robot\init.lua:779: in function 'action_on'
ERROR[Main]: ...test-Survival\bin\..\mods\mesecons\mesecons/internal.lua:190: in function <...test-Survival\bin\..\mods\mesecons\mesecons/internal.lua:183>
ERROR[Main]: ...t-Survival\bin\..\mods\mesecons\mesecons/actionqueue.lua:93: in function 'execute'
ERROR[Main]: ...t-Survival\bin\..\mods\mesecons\mesecons/actionqueue.lua:84: in function <...t-Survival\bin\..\mods\mesecons\mesecons/actionqueue.lua:61>
ERROR[Main]: ...rdner\Minetest-Survival\bin\..\builtin\game\register.lua:369: in function <...rdner\Minetest-Survival\bin\..\builtin\game\register.lua:349>

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

update: mesecons compatibility: can be activated by mesecons signal and can activate mesecons blocks. to turn on wires use delayer first

1. Here a switch activates wire which turns robot on and makes it work continuously. If wire turns off robot disappears.
Image

2. Here robot activates (on/off) delayer, which activates wire which makes piston work
Image
see also debug-screenshot
Inside library left side there is a list of books from specified library ( coordinates ). On right side it shows "inventory list" in current block. So 2 totally different things ( if coordinates same then same ).

This makes it possible to edit books in other ppl library ( you need building rights at their spawner )
Attachments
robot_mesecons_2.jpg
robot_mesecons_2.jpg (64.17 KiB) Viewed 1257 times
robot_mesecons_1.jpg
robot_mesecons_1.jpg (59.56 KiB) Viewed 1257 times
1EvCmxbzl5KDu6XAunE1K853Lq6VVOsT

Brummi
Member
Posts: 41
Joined: Fri Mar 25, 2016 07:21

Re: [Mod] basic_robot [basic_robot]

by Brummi » Post

Mesecons is updated, the server crashes.

blinkyplant & robot spwnwer - Evil guys on the multiplayer server are happy.

Bild 1.png

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

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

Now on the minetest-wiki:
* Mods/basic_robot - User-docu, with introduction to programming
* Basic_robot/Tutorial - Programs from the tutorial-area at the ROBOTS-server
* ROBOTS-server - Server-portrait

Also:
* Mods/basic_machines - documentation about the mod basic_machines,
** with some examples.

Suggestions/additions/corrections/more details welcome...

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:* ROBOTS-server - Server-portrait .. Suggestions/additions/
* A map at the top of that page would look nice (like that from Cash's World).

Ideas for some more buildings:
* Bar (perhaps with juice/drinks), e.g. at the area behind the Casino and shop
* Public library, with some bookshelves
* Stairs at the 'tower' by the divingpool
* Minecart-Rollercoaster (with an elevated start-rail)

* Armory - weapons on display (with signs like "steel sword, X damage")
* Zoo - mobs on display (with signs like "common dirtmonster, 20 HP" :)

* some public teleporter-booths on the streets, about 250 nodes away from center
The teleporter to the counterstrike-arena uses the movers from basic_machines ?

Also, is that server based on rnd's lab server (without magic, spells etc.) ?
Last edited by hajo on Sat Feb 04, 2017 13:07, edited 1 time in total.

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:* ROBOTS-server - Server-portrait .. Suggestions/additions
* A map at the top of that page ..
Ideas for some more buildings ...
More Ideas:

Bank
* with deposit-boxes, using combination-locks
Could be done with a set of 'box'-chests, a second set of 'safe'-chests in the basement,
a keypad for entering the number, and a mover to swap the contents of safe and box.

* Board listing the nearest unclaimed spots of land
** maybe as a bot that scans the landscape around the town,
** and announces the nearest places in north/east/south/west direction

Info-point
* with greeter-bot / tour-guide
That guide would follow a player,
leads him around "follow me to our next attraction, X",
and when arriving there, tell some info-text.

Could be done mostly with the code of follower-bot,
plus a set of attractions/Points-Of-Interests (coordinates and text to speak),
and maybe commands "+", "-", "thanks"/"bye" for going to next/prev, and dismiss.

While leading a player, the bot would switch the target between player and
the next POI every few seconds, to not lose him.

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

Re: [Mod] basic_robot [basic_robot]

by hajo » Post

Bugs found so far in v01/18:

* robot keeps running after self.remove():

Code: Select all

say("done.")  self.remove()  say("Bye") say("bye")
should stop after saying "done.",
but it keeps running, and also outputs "Bye" and "bye".

* self.display_text("",0.0) -- crashes minetest

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

UPDATE:

-bug fixes
-robot now has "energy", each round of execute gives 1 energy up to max 1. to dig stuff, 1 energy is expended
-find_player, pickup, player.connected now all return list or nil
-check_inventory can look at i-th item in inventory and return its name
-robot can turn on furnaces with "activate.direction(1)"
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: .. -bug fixes
statements after self.remove() are still executed
-robot now has "energy", .. to dig stuff, 1 energy is expended
is there a way to query the current energylevel, and/or a wait/sleep-statement ?

E.g. making a 1x3 tunnel

Code: Select all

 dig.forward()
 move.forward()
 dig.up() 
 dig.down() 
currently doesn't work right, because only the first dig is excuted.

Also, I get the impression that digging only works correctly
upto a certain distance between spawner and robot.
Beyond that, the item/ore that was dug
doesn't get into the inventory, and is lost.

For simple stone etc. I wouldn't mind too much,
but it might be valuable ore, and there is no message/warning/error.

About that new farming/fertilizer mod - is that an existing mod,
or do you plan to publish it as a new mod ?

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

statements after self.remove() are still executed
yes it just removes the robot entity, but running program step completes. Just use goto like:

self.remove(); goto end
PROGRAM CODE
::end::
is there a way to query the current energylevel, and/or a wait/sleep-statement ?
Each new running step robot has 1 energy. that is all. If you want to pause robot thats trivial:

if not pause then ... PROGRAM CODE .. end
Also, I get the impression that digging only works correctly upto a certain distance between spawner and robot.
This is not because of robot mod but because minetest shuts down all activity thats far from player location ( depends on settings in minetest.conf, on my server around 3 chunks = 3*16=48 nodes)
About that new farming/fertilizer mod - is that an existing mod,
or do you plan to publish it as a new mod ?
This is very simple modification of farming redo mod. It adds fertilizer and nutrients in dirt and makes farming much more realistic. Now its just super boring "put seed in dirt and forget about it" - this is not how it works in "real life". I can publish it if there is interest
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:
is there a way to query the current energylevel, and/or a wait/sleep-statement ?
Each new running step robot has 1 energy. that is all. If you want to pause robot thats trivial:
if not pause then ... PROGRAM CODE .. end
With 'pause' I meant 'sleep/wait before each dig, until there is enough energy available,
then continue with dig', preferably with sleep=do-nothing, instead of busy waiting like

Code: Select all

while self.energy() < 1.0 do wait(500) end; dig.up()
(or wait/sleep until the next 'running step' starts).

After all, how does the bot know the settings of maxdig, energy-allowance / -requirements, etc. ?
Last edited by hajo on Thu Feb 09, 2017 14:18, edited 1 time in total.

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:
digging only works correctly upto a certain distance between spawner and robot.
minetest shuts down all activity thats far from player location ( depends on
settings in minetest.conf, on my server around 3 chunks = 3*16=48 nodes)
When mining with a remote (and no program running on the spawner),
I'm near the robot, so the only thing the spawner needs to 'do' is receiving the drops.

So, to detect the condition where a dig fails to add something to the inventory,
do we need to do an inventory-check after each dig ?

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

hajo wrote:
rnd wrote:
is there a way to query the current energylevel, and/or a wait/sleep-statement ?
Each new running step robot has 1 energy. that is all. If you want to pause robot thats trivial:
if not pause then ... PROGRAM CODE .. end
With 'pause' I meant 'sleep/wait before each dig, until there is enough energy available,
then continue with dig', preferably with sleep=do-nothing, instead of busy waiting like

Code: Select all

while self.energy() < 1.0 do wait(500) end; dig.up()
(or wait/sleep until the next 'running step' starts).

After all, how does the bot know the settings of maxdig, energy-allowance / -requirements, etc. ?
It would require using coroutines and I think rnd has said that he didn't want to use them for basic_robot.
Every time a mod API is left undocumented, a koala dies.

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests