Latest Posts

Topic: .resource and .resource_amount

Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-14, 21:37

Hi, I found another thing that does not behaves as expected. I am allocating resources like water or fish via f.resourse='xxx' and f.resource_amount=x, it seems that variables are changed (print confirms this), but there is no update within editor - no image of fish appears over the field...?

Also, how could I get rid of a resource on the field? I tried f.resource='' and f.resource=nill but to no avail....


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-01-15, 05:35

Removing the resource should work by setting the resource_amount to = 0. I do not think that the Editor is updating the overlays properly - have you tried to save and reload the map after changing the resources? Note that scripting in the Editor is not perfectly supported and pretty rough around the edges.


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-15, 22:20

Yes, reload of map helped. Not best solution ever but at least something...


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-15, 22:23

yet another (related) question: removal of immovables? (via lua scripting)


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-01-16, 17:33

Tibor wrote:

Yes, reload of map helped. Not best solution ever but at least something...

face-sad.png . It is what it is - as said, what you are doing right now is not really supported, more of a debug aid. Feel free to provide patches to make it more user friendly.


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-01-16, 17:33

Tibor wrote:

yet another (related) question: removal of immovables? (via lua scripting)

map:get_field(13,13).immovable:remove()


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-16, 21:11

SirVer wrote:

face-sad.png . It is what it is - as said, what you are doing right now is not really supported, more of a debug aid. Feel free to provide patches to make it more user friendly.

I would like to, but this is far behind my capabilities, if it was like 5 or 10 hours of my time... but I would end up with no result and only with frustration...


Top Quote
Tibor

Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2014-01-16, 21:51

Well, another problem, the code is:

if f.type==nil then
base.map:place_immovable(something,f)
end

gives error:

Node is no longer free!

Is this a problem of my code?


Top Quote
SirVer

Joined: 2009-02-19, 14:18
Posts: 1445
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2014-01-17, 05:21

Probably. It means that whatever you wanted to place on this node does not have enough space to be placed there, likely another immovable is already on the field.


Top Quote