/apps/twnlua: ctx.udata preservation in reload, no export in .so, ignore /data/scripts/twnapi.lua
This commit is contained in:
		@@ -4,16 +4,39 @@ offset = { x = 0, y = 0 }
 | 
			
		||||
angle = 0
 | 
			
		||||
 | 
			
		||||
function game_tick()
 | 
			
		||||
    if ctx.udata == nil then
 | 
			
		||||
        ctx.udata = {
 | 
			
		||||
            frame_count = 0,
 | 
			
		||||
            nest = {
 | 
			
		||||
                frame_count = 0,
 | 
			
		||||
            },
 | 
			
		||||
            arr = { [0] = 0 },
 | 
			
		||||
        }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    draw_text {
 | 
			
		||||
        string = tostring(ctx.udata.frame_count),
 | 
			
		||||
        position = { x = 0, y = 0 },
 | 
			
		||||
        font = "/fonts/kenney-pixel.ttf",
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    draw_text {
 | 
			
		||||
        string = tostring(ctx.udata.nest.frame_count),
 | 
			
		||||
        position = { x = 0, y = 14 },
 | 
			
		||||
        font = "/fonts/kenney-pixel.ttf",
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    draw_text {
 | 
			
		||||
        string = tostring(ctx.udata.arr[0]),
 | 
			
		||||
        position = { x = 0, y = 28 },
 | 
			
		||||
        font = "/fonts/kenney-pixel.ttf",
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    input_action {
 | 
			
		||||
        name = "press",
 | 
			
		||||
        control = "A"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    draw_rectangle {
 | 
			
		||||
        rect = { x = 0, y = 0, w = 640, h = 360 },
 | 
			
		||||
        color = { r = 127, g = 0, b = 127, a = 255 },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    draw_sprite {
 | 
			
		||||
        texture = "/assets/title.png",
 | 
			
		||||
        rect = {
 | 
			
		||||
@@ -32,6 +55,10 @@ function game_tick()
 | 
			
		||||
        }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    ctx.udata.frame_count = ctx.udata.frame_count + 1
 | 
			
		||||
    ctx.udata.nest.frame_count = ctx.udata.nest.frame_count + 1
 | 
			
		||||
    ctx.udata.arr[0] = ctx.udata.arr[0] + 1
 | 
			
		||||
 | 
			
		||||
    offset.x = ORIGIN.x + (math.cos(angle) * RADIUS)
 | 
			
		||||
    offset.y = ORIGIN.y + (math.sin(angle) * RADIUS)
 | 
			
		||||
    angle = angle + 0.1
 | 
			
		||||
 
 | 
			
		||||
@@ -6,5 +6,6 @@ dev_id = "somebody"
 | 
			
		||||
 | 
			
		||||
[game]
 | 
			
		||||
resolution = [ 640, 360 ]
 | 
			
		||||
background_color = [ 127, 0, 127, 255 ]
 | 
			
		||||
 | 
			
		||||
[engine]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user