ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Pearls on July 10, 2014, 10:32:58 AM
-
Why does the first example work while the second one doesn't?
Here i set a namespace variable !dynamic to the concatenated result of 'carpentry' and '_crafting_gump_resource'.
set !resource iron
set !gump_type carpentry
set !dynamic !gump_type , _crafting_gump_resource ; !dynamic = string 'carpentry_crafting_gump_resource'
display % . !dynamic ; N/A = which is what i'm looking for
I want to check if the dynamic variable has ever been set before by checking if it's N/A.
I want it to be "if %carpentry_crafting_gump_resource = N/A"
set !resource iron
set !gump_type carpentry
if % . ( !gump_type , _crafting_gump_resource ) = N/A ; this makes a string %(carpentry_crafting_gump_resource)
{
set % . ( !gump_type , _crafting_gump_resource ) !resource
display %carpentry_crafting_gump_resource
}
halt
-
You'll find that the presidence doesn't work really well in EUO with regards to parenthesis. I'm sure there's an accurate explanation, but I never really got comfortable with the internal mechanics.
To get your example to work (hopefully, not tested) you need an interim step:
set !resource iron
set !gump_type carpentry
set !temp_str !gump_type , _crafting_gump_resource
if % . !temp_str = N/A ; this makes a string %(carpentry_crafting_gump_resource)
{
set % . !temp_str !resource
display %carpentry_crafting_gump_resource
}
halt
-
Aye that's exactly what i've been using as a temporary solution :) Guess it's permanent now hehe.
Thx
-
Rearrange the Order. When you are building arrays with EUO you always want the Part that Changes to be at the End .
set %Resource1
set %Resource2
set %REsource3 etc etc etc
So in your case you had
set %Carpentry_Crafting_Gump_Resource
with Carpentry being the part that Changes, so move that to the end instead of the Beginning.
%Crafting_Gump_Resource_Carpentry
set !resource iron
set !gump_type carpentry
set %Crafting_Gump_Resource_ , !Gump_Type !Resource
display %Crafting_Gump_Resource_Carpentry
halt
-
Actually i'm already using the array as you mention:
set %dynamic_gump_makelast !gump_type , _crafting_gump_makelast
if % . %dynamic_gump_makelast = N/A || % . %dynamic_gump_makelast <> !item_type
{
; check if we need to set the resource type
set %dynamic_gump_resource !gump_type , _crafting_gump_resource
if % . %dynamic_gump_resource = N/A || % . %dynamic_gump_resource <> !resource
{
set % . %dynamic_gump_resource !resource
gosub PEARLS_craft_set_resource !resource
}
; check if we need to set the category
set %dynamic_gump_category !gump_type , _crafting_gump_category
if % . %dynamic_gump_category = N/A || % . %dynamic_gump_category <> !category
{
set % . %dynamic_gump_category !category
gosub PEARLS_craft_set_category !category
}
; we always need to set page, so if page is not 1, set it :D
set %dynamic_gump_page !gump_type , _crafting_gump_page
if % . %dynamic_gump_page = N/A || % . %dynamic_gump_page <> !page
{
set % . %dynamic_gump_category !category
}
if !page > 1
{
gosub PEARLS_craft_set_page !page
}
set % . %dynamic_gump_makelast !item_type
set % . %dynamic_gump_selection !selection
gosub PEARLS_craft_set_item !selection
}
else
{
gosub PEARLS_craft_makelast
}
Basically a way of storing information on each crafting gump you have worked with to remember if you are making last item, what page, etc...
It's part of the first script i've ever written so it's a learning process hehe :D Once the script is ready for testing, i'll post it on the site :D