Author Topic: Lua Q&A  (Read 104295 times)

0 Members and 2 Guests are viewing this topic.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Lua Q&A
« Reply #135 on: September 24, 2012, 05:44:02 am »
And if you're looking to implement that into a string manager, here's an example :
https://github.com/adriweb/EEPro-for-Nspire/blob/master/Global%20Libraries/widgets.lua#L145
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Bindle

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Re: Lua Q&A
« Reply #136 on: November 18, 2012, 09:50:44 am »
Hey guys, Im coding a game.

When I type xp = xp + 1 in the function SceneUpdate() my xp just turns away into a million xp points. I just want the increasment of one.

How do I do that?

Bindle

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Lua Q&A
« Reply #137 on: November 18, 2012, 09:55:59 am »
You're probably calling SceneUpdate() too often, then.
If SceneUpdate() is used to update graphical parts, don't increment the xp in there, rather in another function you call whenever it's needed :)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Bindle

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Re: Lua Q&A
« Reply #138 on: November 18, 2012, 09:59:08 am »
So where do I do that? Is this the way to call a function?

function SceneUpdate()
   if wormhp == 0 then run("level")
   end
end
   
function level()
   xp = xp + 1
   return
end
« Last Edit: November 18, 2012, 10:36:45 am by Bindle »

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Lua Q&A
« Reply #139 on: November 18, 2012, 06:11:02 pm »
Simply do

Code: [Select]
function SceneUpdate()
if wormhp == 0 then
level()
end
end

function level()
xp = xp + 1
end
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline mannuri

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Lua Q&A
« Reply #140 on: February 24, 2013, 08:28:55 am »
Hi all,

I think some of you have heard about timasterbox, http://code.google.com/p/timasterbox/.
The autor seems to be busy so im leave my question here.
Im not a lua programer, but im triing to creat my school programs using that tool.
My problem is How i get the values imputed at numberBox. I want use the comand var.store() but i dont know what is the imput table name.

When i put an image into lua string i lost to mush quality. Can someone show a way to keep most of that quality.

Please LuaGod's help me  :P

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Lua Q&A
« Reply #141 on: February 24, 2013, 09:02:04 am »
I don't know how his calls work, but with my lib and actually with any variable storage you can do var.store("varName", NumericUpDown_Name.num).
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline mannuri

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Lua Q&A
« Reply #142 on: February 24, 2013, 10:23:32 am »
Thanks, i know how to use var.store() i dont know what is the  NumericUpDown_Name.num name.

Code: [Select]
if widgetNoFocus == false then
            if self.widgets[self.widgetFocus].typeBox == "NumberBox" then
                -- Concatenamos el nuevo caracter.
                self.widgets[self.widgetFocus].text = self.widgets[self.widgetFocus].text .. char

i have many NumberBox, and the self.widgets[self.widgetFocus].text is the variable i think (learn from Nspire tutorial)

At start is some close to this:
Code: [Select]
    numberBoxj = NumberBox(70, "CENTER")
    numberBoxL = NumberBox(70, "CENTER")

    MASTERBOX:addWidget(numberBoxj)
    MASTERBOX:addWidget(numberBoxL)

and i want store the var from numberBoxj into "j".

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Lua Q&A
« Reply #143 on: February 24, 2013, 10:27:22 am »
that is your variable. The NumericUD is just a control from my lib. So for number box it may be var.store("variable", NumberBox_Name.text).
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline mannuri

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Lua Q&A
« Reply #144 on: February 24, 2013, 11:12:11 am »
Thanks,

If i use:
Code: [Select]
var.store("qi",NumberBox[numberBoxQ].text)I got that error:
Code: [Select]
attempt to index field '?' (a nil value)
If i use:
Code: [Select]
var.store("qi",NumberBox_numberBoxQ.text)I got that error:
Code: [Select]
attempt to index global 'NumberBox_numberBoxQ' (a nil value)
 :'(

Offline mannuri

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Lua Q&A
« Reply #145 on: February 24, 2013, 11:36:29 am »
Yeahh, thank you guys!  ;D

Im just putting the var.store at bad place  :w00t:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Lua Q&A
« Reply #146 on: February 24, 2013, 12:05:36 pm »
Heya and welcome here. I think I saw this software on Ticalc.org recently. It seemed pretty nice in general. There is also wzGUILib but I think that is for C programmers.

Good luck! :)

Offline mannuri

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Lua Q&A
« Reply #147 on: February 24, 2013, 12:50:55 pm »
People dont like to call programs like prog() and nspire dont have the dialog comand like voyage 200, i know a bit about ti basic but nothing about lua. So that tool is amazing because it solve the imput problem. Now i can prob to my friends Nspire is better than voyage 200. :)

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Lua Q&A
« Reply #148 on: February 24, 2013, 03:07:32 pm »
Heya and welcome here. I think I saw this software on Ticalc.org recently. It seemed pretty nice in general. There is also wzGUILib but I think that is for C programmers.

Good luck! :)

Nope, its lua. Although I have thought about porting it to C to give it more power.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Lua Q&A
« Reply #149 on: July 17, 2013, 05:20:56 am »
what does __varname mean?

example:
Code: [Select]
-- Class definition system
class = function(prototype)
    local derived = {}
    local derivedMT = {
        __index = prototype,
        __call  = function(proto, ...)
            local instance = {}
            local instanceMT = {
                __index = derived,
                __call = function()
                    return nil, "attempt to invoke an instance of a class"
                end,
            }
            setmetatable(instance, instanceMT)
            if instance.init then
                instance:init(...)
            end
            return instance
        end,
    }
    setmetatable(derived, derivedMT)
    return derived
end
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)