Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
in my game, there is a level system. when you have 10 money, the btn levelUpFa is enabling. you click it, you loose 10 money, and you earn +1 money each second. i did it with my old code, but with yours i dont really know where to check my money ect..can you help me?
thanks
kelyan
Hm, this is a completely new situation and may require some changes in your workflow.
What did you write in your old script?
Hm, let me see...
Maybe remove the givemoney handler from the button and put it into the stack script and let it accept one parameter,
so you can call it from everywhere.
global give_money_id
## So we can pass any number (also negative numbers like -10)
command give_me_your_money the_amount_of_money
## If we do not pass a number, the handler will use 1 (for your periodic money adding):
if the_amount_of_money = EMPTY then
put 1 into the_amount_of_money
end if
## Mouse is still DOWN.
## We can add something directly to a field, as long as the field contains a number!
add the_amount_of_money to fld "moneyfield"
## LC will first examine the values in parens, so we can do this "Boolean" trick :-)
set the enabled of btn "levelUp1" to (fld "moneyfield" > 9)
## We will SEND this handler only if we add 1 = periodic adding of money!
## This way we can use it to just add or subtract any value <> 1 from the "moneyfield"
if the_amount_of_money <> 1 then
exit give_me_your_money
end if
send "give_me_your_money" to me in 1 secs
put the result into give_money_id
end give_me_your_money
So when clicking the button which steals you 10 "money" you can:
Apologies if you misinterpret my post as "hijack".
The OP stated: "but the problem is that if you run a repeat, you cant press buttons or do anything." which is exactly the scenario I posted about too. I understand how the OP's question has developed into a somewhat different scenario but at the time I posted I did feel that I was discussing the same situation. Perhaps, adopting a positive and optimistic approach, it might be possible to share resources and benefit from each other's posts. Jean-Marc's assistance might be useful to the money game?
But I guess that is not the way this forum is supposed to function so, again, I apologise for upsetting you.
if aMoney > 9
then
enable btn "levelUpFa"
else
end if
so this works, but i copy paste it just after it to enable a btn when you are a 100, but didnt worked.. so: 1. is my code right? and 2. if it is not, what should i do? simply use your code?
thanks