Log In  


In my code, I used menuitems as a way of interaction with the game.

When you run it, if you go to the command line, set items.planks to true and go back to the game and pause, press level 1 and then press move, it shows an error, about trying to call _superyield with flip().

I don't know if this is something bad or not, as I don't understand yield(), _superyield and flip() since I never used any of these.

The error:

The code (tried to remove the useless stuff):

function _init()
	menuitem(1,"level 1",level1)
	items={
		planks=false
	}
end

function _draw()
end

function level1()
	menuitem(1,"move",move)
end

function move()
	return true
end


I am not able to recreate your error, but it looks like you are trying to figure out menuitems, which are a little tricky until you get the hang of them.

Here is a code snippet I came up with to play around with that may clarify how they work. Hit pause to bring up the menu. Use ⬅️ and ➡️ to cycle through options, then choose an option to update the screen.

function _init()
 fruit = {"apples","bananas","oranges","grapes"}
 i = 0
 screen = "hit pause to choose a fruit"
 pickfruit(2) --initialize the menu as if we hit ➡️
end

function pickfruit(b)
 if (b==1) i = (i-2)%#fruit+1 --move left in the list
 if (b==2) i = i%#fruit+1 --move right in the list
 if (b<=2) menuitem(1,fruit[i],pickfruit) --update item displayed in menu
 if (b>2) screen = "you last selected "..fruit[i] --update screen with selected fruit
end

function _draw()
 cls()
 ? screen
end


[Please log in to post a comment]