|
4 registered members (Hartmann846, TipmyPip, 2 invisible),
5,361
guests, and 12
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: can anyone help me?
[Re: yunn]
#308772
02/04/10 21:18
02/04/10 21:18
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
You will need a var that will keep track of the total price, and then you add or subtract from that var to have a correct total as you add or remove items from display. So
if(mouse_left){ { unit = ent_create(f[my.skill2],my.x,act); vec_set(unit.pan,my.pan); grandtotal += price_of_f[my.skill2]; } if(mouse_right){//also make sure this only works when over an entity. ent_remove(blah blah) grandtotal -= price_of_f(blah blah); }
Another option is to create a manager that knew every item in the screen and have it add up a total each cycle. This one could be buggy if not done right but could be more simple depending.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Re: can anyone help me?
[Re: yunn]
#308945
02/05/10 23:05
02/05/10 23:05
|
Joined: Jun 2004
Posts: 2,234 Wisconsin USA
FoxHound
Expert
|
Expert
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
|
Putting it in the text field would display the the price but would not do anything to keeping track of how much is spent. You're best bet is to make a struct for the furniture and having an int to keep track of the price and have it added in the function that creates the furniture and places it in the level.
--------------------- There is no signature here.
QUIT LOOKING FOR ONE!
|
|
|
Re: can anyone help me?
[Re: FoxHound]
#309229
02/08/10 02:04
02/08/10 02:04
|
Joined: Dec 2009
Posts: 12
yunn
OP
Newbie
|
OP
Newbie
Joined: Dec 2009
Posts: 12
|
|
|
|
Re: can anyone help me?
[Re: yunn]
#309232
02/08/10 02:32
02/08/10 02:32
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
surely you could just save the price in one of the entities skills? #define cost skill1 action unit(){ my.cost = 15; } or just create an array to match your TEXT
TEXT* txt_furniture = {
string("nullunit.mdl","sofa.mdl","tv.mdl");
}
var var_cost[25] = { 0, 50, 25.5 };
var var_total;
//then give each item a value so it knows what it's referencing in the array
#define id skill1
action sofa(){
my.id = 1;
}
action tv(){
my.id = 2;
}
//do all these for each item
//then for performing the click
void select_item(){
if(!mouse_ent){ return; }
ENTITY* ent = mouse_ent;
//if not already added, add it
if(!is(ent, LIGHT)){
//glow green
vec_set(ent.blue, vector(128, 255, 128));
set(ent, LIGHT);
var_total += var_cost[ent.id];
}else{
reset(ent, LIGHT);
var_total -= var_cost[ent.id];
}
void main(){
on_click = select_item;
}
*untested* brackets may be missing  hope this helps
|
|
|
|