WML Shop help
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
WML Shop help
What I'm trying to do is make text in the shop appear "white"/normal color if the character has the relevant amount of gold, but if not then it would appear red. I've tried different coding but they don't seem to work, and I can't figure it out. By the way, I'm a WML noob.... Here's what I've tried already...
First I tried this:
Then I tried:
That didn't work, didn't think it would. It was worth a try, so then I remembered "show_if" so I tried:
Here's a picture of the last try I did...
So what am I doing wrong? Thanks for any help you could give...
First I tried this:
Code: Select all
[if]
[variable]
greater_than_equal_to=150
[/variable]
[then]
[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[command]
[if]
[variable]
name=gold
greater_than_equal_to=150
[/variable]
[then]
[gold]
amount=-150
side=$side_number
[/gold]
[object]
silent=yes
[effect]
apply_to=new_attack
name=W. Longbow
range=ranged
type=pierce
damage=2
number=3
defense_weight=100
[/effect]
[/object]
[/then]
[/if]
[/command]
[/option]
[/then]
[else]
[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[/option]
[/else]
[/if]
Then I tried:
Code: Select all
[option]
[if]
[variable]
greater_than_equal_to=150
[/variable]
[then]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[command]
[if]
[variable]
name=gold
greater_than_equal_to=150
[/variable]
[then]
[gold]
amount=-150
side=$side_number
[/gold]
[object]
silent=yes
[effect]
apply_to=new_attack
name=W. Longbow
range=ranged
type=pierce
damage=2
number=3
defense_weight=100
[/effect]
[/object]
[/then]
[/if]
[/command]
[/then]
[else]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[/else]
[/if]
[/option]
Code: Select all
[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
greater_than_equal_to=150
[/variable]
[command]
[if]
[variable]
name=gold
greater_than_equal_to=150
[/variable]
[then]
[gold]
amount=-150
side=$side_number
[/gold]
[object]
silent=yes
[effect]
apply_to=new_attack
name=W. Longbow
range=ranged
type=pierce
damage=2
number=3
defense_weight=100
[/effect]
[/object]
[/then]
[/if]
[/command]
[/show_if]
[/option]
[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
less_than=150
[/variable]
[/show_if]
[/option]
Here's a picture of the last try I did...
So what am I doing wrong? Thanks for any help you could give...
Okay, I tested this, a simplified version of your two options. This code works perfectly fine.
Your problem is, you cannot stick everything in the [show_if]. You need to only put the variable in there. See how I put the message outside of the [show_if]s but inside the [command]s?
Secondly, you should also use "geater_than_equal_to" instead of "greater_than" because if someone goes to shop with exactly 150 gold, they won't be able to purchase the product, and it won't show in red for them either, even though they have the required gold.
Thirdly, now that [show_if] exists, you don't have to check and see if the player has enough gold. All you have to do is subtract the gold from them, since [show_if] already checked the gold amount.
Finally, I see you're using my map :P
Code: Select all
[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
less_than=150
[/variable]
[/show_if]
[/option]
[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
greater_than=150
[/variable]
[/show_if]
[command]
[message]
message=_ "Hi"
[/message]
[/command]
[/option]
Your problem is, you cannot stick everything in the [show_if]. You need to only put the variable in there. See how I put the message outside of the [show_if]s but inside the [command]s?
Secondly, you should also use "geater_than_equal_to" instead of "greater_than" because if someone goes to shop with exactly 150 gold, they won't be able to purchase the product, and it won't show in red for them either, even though they have the required gold.
Thirdly, now that [show_if] exists, you don't have to check and see if the player has enough gold. All you have to do is subtract the gold from them, since [show_if] already checked the gold amount.
Finally, I see you're using my map :P
thank you...
Quick question, would it allow them to buy the object and see it in white if I put:
And yea, I am using your map... its a simple map to work from... but its not the game map that I am going with
hopefully, I'll have a test of this game up by the end of the month, with just a few of my shops working... got lots and lots of shops with special items to put in there...
but the test will only have the map, and the general shops in the game... I want to see if it will be balanced...
thanks for your help!
Quick question, would it allow them to buy the object and see it in white if I put:
Code: Select all
[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
less_than=150
[/variable]
[/show_if]
[/option]
[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
[b]greater_than=149[/b]
[/variable]
[/show_if]
[command]
[message]
message=_ "Hi"
[/message]
[/command]
[/option]
hopefully, I'll have a test of this game up by the end of the month, with just a few of my shops working... got lots and lots of shops with special items to put in there...
but the test will only have the map, and the general shops in the game... I want to see if it will be balanced...
thanks for your help!
I tried the code, it didn't work for me. I mean, both options showed up at the same time, so it wasn't really working. Another problem that occurred, it would take gold from the character even after you don't have enough and just keep selecting it. Here's what I used:
I don't know if I messed it up or something, but I just dropped the idea for now. However, it would be good to know in case I decide to try it again. Plus I would like to have it shown in my new topic. I am going to put your last one in there for now though.
Code: Select all
[option]
message=_ "#Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
less_than=150
[/variable]
[/show_if]
[/option]
[option]
message=_ "Wooden Longbow (2-3 R, P): 150g"
[show_if]
[variable]
name=gold
[b]greater_than=149[/b]
[/variable]
[/show_if]
[command]
[gold]
amount=-150
side=$side_number
[/gold]
[object]
silent=yes
[effect]
apply_to=new_attack
name=W. Longbow
range=ranged
type=pierce
damage=2
number=3
defense_weight=100
[/effect]
[/object]
[/command]
[/option]
I quote myself because I answered this question already.Blueblaze wrote:Why do you have the bold code around the variable check? Without the b's it would work.
Code: Select all
[b]greater_than=149[/b]
Code: Select all
greater_than=149