ID:178468
 
obj/var/cost = 1
obj/someitem
suffix = "[src.cost]"


Why does this compile with errors?

-ST
It needs to be called when obj is created.

obj
bah
New()
suffix="bah"
In response to Super16
Super16 wrote:
It needs to be called when obj is created.

obj
bah
New()
suffix="bah"

But it doesnt change, the cost changes after a while. So it just stays at 1 (the suffix)
Vars initialized outside of New() must be initialized with constants. src.cost is not a constant. You would have more luck inside your New() proc. (suffix = "blah" should work outside of New() though.)
In response to ACWraith
ACWraith wrote:
Vars initialized outside of New() must be initialized with constants. src.cost is not a constant. You would have more luck inside your New() proc. (suffix = "blah" should work outside of New() though.)

Ummm, what?
In response to Sariat
Sariat wrote:
ACWraith wrote:
Vars initialized outside of New() must be initialized with constants. src.cost is not a constant. You would have more luck inside your New() proc. (suffix = "blah" should work outside of New() though.)

Ummm, what?

You cannot have a variables intial variable contain another variable. You would have to assign it at run time.
obj/New()
. = ..()
suffic = "[cost]"
In response to Ebonshadow
Ebonshadow wrote:
Sariat wrote:
ACWraith wrote:
Vars initialized outside of New() must be initialized with constants. src.cost is not a constant. You would have more luck inside your New() proc. (suffix = "blah" should work outside of New() though.)

Ummm, what?

You cannot have a variables intial variable contain another variable. You would have to assign it at run time.
obj/New()
. = ..()
suffic = "[cost]"

I know, I have done that, but it doesnt update, the cost changes.

So if the cost changes to 2, the suffix is still 1...

PS- whats a suffic? :)
In response to Sariat
Sariat wrote:
[snip]
I know, I have done that, but it doesnt update, the cost changes.

So if the cost changes to 2, the suffix is still 1...
[snip]

Sorry. I was still answering the first question.

There is no way to directly link suffix and cost that I know of. There is the issue of the conversion from num to text to contend with. However, even if cost was also text, a change in one text would not affect the other text. You probably have to make sure to update suffix manually whenever the cost changes.
In response to Sariat
Sariat wrote:
I know, I have done that, but it doesnt update, the cost changes.

So if the cost changes to 2, the suffix is still 1...

Well thats because you have to update suffix everytime you want it to update (duh).

PS- whats a suffic? :)
A typo of suffix
A typo of sufic(mystic monk like)
or
The first half of a word that ends with ate that you should go do right now ;).
In response to Sariat
You may want to assign the obj's Stat proc so that it updates its suffix to its cost.
obj/someitem
Stat()
suffix = num2text(cost) //might just want to do that for safety's sake

That way, it will update automatically. The only problem is that it might give a tiny bit of lag.
In response to Sariat
Sariat wrote:
I know, I have done that, but it doesnt update, the cost changes.

Of course it doesn't update, for the same reason that setting x=sqrt(y) doesn't update x every time you change y. The engine has no way of knowing if you wanted to stick with that value or keep it connected somehow with the cost var; the language has no capability built in to tie the vars together like that--and most don't. Therefore, you have to create a new string every time cost changes.

One way you could do that, as suggested, would be the Stat() proc, since that's where you'd see a suffix displayed anyway. Another choice is to use another proc for that:
proc/SetCost(x)
cost=x
suffix="[x]"

Lummox JR
In response to Lummox JR
Gah! Thanks I was trying to do something like this before I saw this. Well, thanks alot!