level 2
violetjasa
楼主
___________________________________________
ERROR in
action number 1
of Mouse Event for Left Pressed
for object bbuilding:
In script build_buildings:
Error in code at line 6:
if(country_player.resource>the_building.cost)
^
at position 43: Unknown variable cost
我在游戏中设定了建筑所需的资源为cost,当可以建造时从国家的总资源resource里扣除。但程序运行时报错
这是建造建筑的脚本,其中argument0是我传进来的参数
var id_build;
var can_place;
var the_building;
the_building=argument0;
can_place=0;
if(country_player.resource>the_building.cost)
{
if place_empty(mouse_x,mouse_y)
{
can_place=1;
}
else
{
//cout....cantplace
}
if (can_place=1)
{
id_build=instance_create(mouse_x,mouse_y,the_building);
id_build.owner=1;
country_player.resource=country_player.resource-the_building.cost;
}
}
这里是我设置的farm变量



下面是我设置的国家变量,但是这个在上面那一段代码就没有报错
