Adding numbers in game states

View: New views
4 Messages — Rating Filter:   Alert me  

Adding numbers in game states

by jfcwilson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
 
How does one add a number to a variable?
For example, here's a state, as defined in Main.lua:
state.blahhumblah=1
 
Now, in a node.lua, I want to do something to this effect:
 
state.blahhumblah=+1
 
So that whenever a function is run it'll increase the state's value by 1. Or subtract it, etc.
 
Anyone know how to do this? It's quite common in other systems, Python, TADS, Inform...
 
Thanks,
  James


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users

Re: Adding numbers in game states

by Christian Walther :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

James Wilson wrote:

> How does one add a number to a variable?
> For example, here's a state, as defined in Main.lua:
> state.blahhumblah=1
>  
> Now, in a node.lua, I want to do something to this effect:
>  
> state.blahhumblah=+1
>  
> So that whenever a function is run it'll increase the state's value by
> 1. Or subtract it, etc.

state.blahhumblah = state.blahhumblah + 1

  -Christian


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users

Re: Adding numbers in game states

by Aidan Gauland-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christian Walther wrote:

> James Wilson wrote:
>> How does one add a number to a variable?
>> For example, here's a state, as defined in Main.lua:
>> state.blahhumblah=1
>>  
>> Now, in a node.lua, I want to do something to this effect:
>>  
>> state.blahhumblah=+1
>>  
>> So that whenever a function is run it'll increase the state's value by
>> 1. Or subtract it, etc.
>
> state.blahhumblah = state.blahhumblah + 1
>
>   -Christian

For issues such as these, the Lua reference manual is your friend:
<http://www.lua.org/manual/> (Pipmak still uses Lua 5.0, not 5.1; this is
supposed to change at Pimak 0.3.0).  In my opinion, Lua is one of the weirder
languages--perhaps because it is not a general purpose language?--so keep it
on hand whenever using Lua ;).  (I still prefer it as a game engine's
interface, though.)

  --Aidan

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users

Re: Adding numbers in game states

by jfcwilson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah. Thanks a lot.
 
Thanks
  James

--- On Tue, 9/8/09, Christian Walther <cwalther@...> wrote:

From: Christian Walther <cwalther@...>
Subject: Re: Adding numbers in game states
To: pipmak-users@...
Date: Tuesday, September 8, 2009, 4:22 PM

James Wilson wrote:

> How does one add a number to a variable?
> For example, here's a state, as defined in Main.lua:
> state.blahhumblah=1

> Now, in a node.lua, I want to do something to this effect:

> state.blahhumblah=+1

> So that whenever a function is run it'll increase the state's value by
> 1. Or subtract it, etc.

state.blahhumblah = state.blahhumblah + 1

  -Christian


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users