Page 1 of 1

I need help with my trade system

PostPosted: Tue Feb 11, 2014 10:06 pm
by Pengaboy
Hello, i started to create a game.
However i ran into the problems while wanted to add trade system.

How i can add system that indicates following:
when i press update button then it removes 2500 from cash (how to limitate that if my cash is less than 2500 then it just does nothing?)
when i press update button then it raises update price twice (how to indicate how many updates i have done?)
when i press update button then it changes the base image (if i have enough cash for that)?
how to set per update diffirent images while using single update button?

Thanks for help :)

Re: I need help with my trade system

PostPosted: Tue Feb 11, 2014 11:31 pm
by skydereign
Pengaboy wrote:Hello, i started to create a game.
However i ran into the problems while wanted to add trade system.

How i can add system that indicates following:
when i press update button then it removes 2500 from cash (how to limitate that if my cash is less than 2500 then it just does nothing?)
when i press update button then it raises update price twice (how to indicate how many updates i have done?)
when i press update button then it changes the base image (if i have enough cash for that)?
how to set per update diffirent images while using single update button?

Thanks for help :)

Do you know about if statements and variables? You can use an if statement and a few variables to do all of that. Here's a small example of an if statement.
Code: Select all
if(cash>=2500)
{
    // this code only runs when you have at least 2500
    // buy whatever item
    cash -= 2500; // removes extra cash
}

Re: I need help with my trade system

PostPosted: Wed Feb 12, 2014 2:54 am
by Pengaboy
skydereign wrote:
Pengaboy wrote:Hello, i started to create a game.
However i ran into the problems while wanted to add trade system.

How i can add system that indicates following:
when i press update button then it removes 2500 from cash (how to limitate that if my cash is less than 2500 then it just does nothing?)
when i press update button then it raises update price twice (how to indicate how many updates i have done?)
when i press update button then it changes the base image (if i have enough cash for that)?
how to set per update diffirent images while using single update button?

Thanks for help :)

Do you know about if statements and variables? You can use an if statement and a few variables to do all of that. Here's a small example of an if statement.
Code: Select all
if(cash>=2500)
{
    // this code only runs when you have at least 2500
    // buy whatever item
    cash -= 2500; // removes extra cash
}


cash is variable or actor?

Re: I need help with my trade system

PostPosted: Wed Feb 12, 2014 3:15 am
by skydereign
Pengaboy wrote:cash is variable or actor?

It is an integer variable. Though you'll need to create it to actually use it.

Re: I need help with my trade system

PostPosted: Wed Feb 12, 2014 3:25 am
by Pengaboy
skydereign wrote:
Pengaboy wrote:cash is variable or actor?

It is an integer variable. Though you'll need to create it to actually use it.


yeah. its working but i need that it print the value of cash on text actor.
here is the code i use at the moment, i think something wrong with that...
Code: Select all
if(cash >= 2500)
{
    statnumber_cash.textNumber = statnumber_cash.textNumber - 2500;
    cash -= 2500;
}

Re: I need help with my trade system

PostPosted: Wed Feb 12, 2014 4:26 am
by skydereign
Pengaboy wrote:here is the code i use at the moment, i think something wrong with that...

What is wrong exactly? What should it be doing instead of what it is doing now? That code should only let you decrease cash when it is greater than or equal to 2500, and when you press it it will update the textNumber's value and reduce cash. However if that is what you want it to do, I'd recommend setting it like follows (this way is slightly cleaner).
Code: Select all
if(cash >= 2500)
{
    cash -= 2500;
    statenumber_cash.textNumber = cash;
}

Re: I need help with my trade system

PostPosted: Wed Feb 12, 2014 5:03 am
by Pengaboy
tried that but i didnt work in some odd reason lol, but is there some way to print the value of cash variable instead of single updates so it updates itself automatically.
because that way i keep the code more clear :)

btw i shall explain about system a bit more though :D
Actors and Variable im using:
cash(variable/integer/global/array:no/save group:stats
statnumber_cash(text actor for numbers to show cash)
upgrade_button(button for sending commands to actors)

i mean when i click upgrade button then it works like upgrade_button -> cash -> statnumber_cash
and so on :D