Log In  


I decided to start a library of scripts to help those transitioning from visual scripting to lua.

You should be able to copy and paste code into your new script object put object in the room and run it with "Crt+R"

If something doesn't work please let me know.

Feel free to ask questions.

Have fun

/Digital Monkey


Lua scrip to print.
place scrip object in the room.

function draw()
    boxfill(0,0,63,128,128,63,3)
    set_draw_slice(120, true)
    print("printing", 48, 11, 7)
    print("in voxatron 3.5b", 40, 20, 7)

end

This is basic player controllers
control the box with arrows, z and x

x = 64  y = 64
updown = 30	

	function _update()

	 if (btn(0)) then x=x-1 end
	 if (btn(1)) then x=x+1 end
	 if (btn(2)) then y=y-1 end
	 if (btn(3)) then y=y+1 end
	 if (btn(4)) then updown=updown-1 end
	 if (btn(5)) then updown=updown+1 end
	end

	function _draw()

	clv()
	boxfill(x,y,updown,x+10,y+10,updown+10,14)
	boxfill(0,0,63,128,128,63,3)
	set_draw_slice(50)
	print("control the box", 33, 10, 7)
	print("using arrows, z and x keys", 10, 100, updown-1)

        end

Scrip to change rooms made with "function draw()"
on J and K button press
(It's a flip book to go back and forth between rooms)

I made this by looking at script from GARDENING by: PROGRAM_IX

thx PROGRAM_IX :)

function _init()

	state = 0
	debounce = 0 
end 	

function draw()
	if(state == 0) then
		draw_title()
	elseif(state == 1) then
		draw_instructions()
	elseif(state == 2) then
		draw_monkeys()
	elseif(state == 3) then
		draw_apples()
	elseif(state == 4) then
		draw_game()
	elseif(state <0) then
		draw_game()
	elseif(state >4) then
		draw_title()			
	end

end

function draw_title()
	set_display_camera(-1)
	boxfill(0,0,63,128,128,63,3)
	set_draw_slice(120, true)
	print(state, 40, 20, 7)
	print("press j or l", 52, 30, state+15)
	state = 0
end

function draw_instructions()
	set_display_camera(-1)
	boxfill(0,0,63,128,128,63,14)
	set_draw_slice(120, true)
	print(state, 20, 11, 7)
	print("press j or l", 52, 30, state+15)

end

function draw_monkeys()
	set_display_camera(1)
	boxfill(0,0,63,128,128,63,24)
	set_draw_slice(60)
	print(state, 20, 120, 7)
	print("press j or l", 52, 30, state+15)

end

function draw_apples()
	set_display_camera(1)
	boxfill(0,0,63,128,128,63,28)
	set_draw_slice(60)
	print(state, 20, 120, 7)
	print("press j or l", 52, 30, state+15)

end

function draw_game()
		set_display_camera(-1)
		boxfill(0,0,63,128,128,63,55)
		set_draw_slice(120, true)
		print(state, 52, 20, 7)
		state = 4
		print("press j or l", 52, 30, state+15)

end

function _update()
	if(state < 5) then
		if(btn(7) and debounce > 10) then
			state += 1
			debounce = 0
		else
		if(btn(6) and debounce > 10) then
			state -= 1
			debounce = 0
		else
		end			

		debounce += 1
		end

	end
end

This script spawns a player at the position of the entry platform at any room...

function draw()

        local x,y,z = this:get_xyz()
        spawn("ROBOT", x,y,z)

end
3


hi- not sure if possible via lua/shaders, but could say all blue voxels have "Water" property (ripple etc), all red voxels have "fire" attributes, all so on and so forth?


@zartan917 @MBoffin

I would love to have a custom water scrip
There was discussion about it see the link below.

discussion

There was no follow up on it yet
I also like your idea of setting damage as a parameter :)

/Cheers


hi thanks yes i hope maybe the color matching idea will work- i dont know lua though- is there a place on this forum to offer someone to help (I can pay a bit). keep on voxing!


@zartan917

Try posting in pico-8 section since pico runs on Lua and pico-8 users are strong coders.

Voxatron and Pico-8 both have chat and colaboration sections.

/G


1

Thanks for this, @digitalmonkey . Very useful.



[Please log in to post a comment]