It is currently 19 Apr 2024, 19:54
   
Text Size

General DotP 2014 Coding Questions

Moderator: CCGHQ Admins

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 09:48

Thanks very much RiiakShiNal! sorry for my begginner questions but im learning quickly. :D
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby RiiakShiNal » 22 Feb 2014, 13:04

I wish I could have given more positive answers, but the question of whether overload could be coded has happened before and we've gone through many of these exact same points.

There are just some things that the DotP 2014 engine does not allow us to do properly (or at all). Maybe DotP 2015 will give us more to work with.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 18:50

Thanks anyway, i have another question.
I'm trying code this simple code and dont work, someone know what is bad?

Code: Select all
<SPELL_ABILITY linked_ability_group="1">
<RESOLUTION_TIME_ACTION>
   
   linkedDC():Set_Int(0,1)

   </RESOLUTION_TIME_ACTION>

   <RESOLUTION_TIME_ACTION>
   
   local message = "Test "
   EffectController():DisplayMessage(message..linkedDC():Get_Int(0))

   </RESOLUTION_TIME_ACTION>
...
and launch this error message:
[lua] [string "CYCLONIC_RIFT_666270798_TITLE (RESOLUTION_TIME_ACTION)~0x0000028c"]:3: attempt to call global 'linkedDC' (a nil value)
[lua] [string "CYCLONIC_RIFT_666270798_TITLE (RESOLUTION_TIME_ACTION)~0x0000028d"]:4: attempt to call global 'linkedDC' (a nil value)

I cant use globals properly.
Wit local variables works but with globals... :roll:

If for example i do this with locals its ok:
Code: Select all
<SPELL_ABILITY>

   <RESOLUTION_TIME_ACTION>
   
   local message = "Test "
local number = 1
   EffectController():DisplayMessage(message..number)

   </RESOLUTION_TIME_ACTION>
...
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby RiiakShiNal » 22 Feb 2014, 19:26

That is because you are trying to call linkedDC() instead of LinkedDC() (note the capitalized "L"). Names are CaSe SeNsItIvE so if you miss capitalizing or capitalize too much it won't work.

Granted, you could define a function in a LOL file to allow it to work, like this:
Code: Select all
linkedDC = function()
  return LinkedDC()
end
Though that seems pretty pointless to me as it would add several more bytes of overhead simply because you don't want to capitalize an "L".

You could also use EffectDC() instead of LinkedDC() if you only need the data chest inside that ability. Like this:
Code: Select all
<SPELL_ABILITY>
   <RESOLUTION_TIME_ACTION>
     EffectDC():Set_Int(0,1)
   </RESOLUTION_TIME_ACTION>
   <RESOLUTION_TIME_ACTION>
     local message = "Test "
     EffectController():DisplayMessage(message..EffectDC():Get_Int(0))
   </RESOLUTION_TIME_ACTION>
...
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 19:42

:D :D :D :D
It's crazy, i spend a lot of hours only for a capital letter.
I love to program
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby RiiakShiNal » 22 Feb 2014, 20:10

braquio wrote::D :D :D :D
It's crazy, i spend a lot of hours only for a capital letter.
I love to program
It has happened to me before, though I am much better about recognizing when I do that than I used to be (spending a lot of time in C++/C#/Java/PHP/Lua and other case sensitive languages will do that).
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 20:10

And is possible to pass string arguments instead Int arguments?
dont work but something like this:
Code: Select all
<RESOLUTION_TIME_ACTION>
   
   LinkedDC(500) = "1"

   </RESOLUTION_TIME_ACTION>

   <RESOLUTION_TIME_ACTION>
   
   local message = "Test "
   EffectController():DisplayMessage(message..LinkedDC(500))

   </RESOLUTION_TIME_ACTION>
or like this:
Code: Select all
<RESOLUTION_TIME_ACTION>
   
   global Number = "1"

   </RESOLUTION_TIME_ACTION>

   <RESOLUTION_TIME_ACTION>
   
   local message = "Test "
   EffectController():DisplayMessage(message..Number)

   </RESOLUTION_TIME_ACTION>
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby thefiremind » 22 Feb 2014, 20:49

braquio wrote:And is possible to pass string arguments instead Int arguments?
dont work but something like this:
LinkedDC, as well as the other data chests, are made to store only some variable types, and string isn't one of them, in fact I had to make a custom structure when I coded the "Name a card" functions in order to save the chosen name.
If you want to do something involving a string that needs to be carried through multiple actions we can discuss about it and find a solution.

Note that
Code: Select all
EffectController():DisplayMessage(message..LinkedDC(500):Get_Int(0))
works anyway: if you concatenate something that isn't a string, it will be automatically converted to string.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 21:19

The reason that i want a string argument is cause i still working in overload ability
Now i have this code:
| Open
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="CYCLONIC_RIFT_666270798" />
  <CARDNAME text="CYCLONIC_RIFT" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Cyclonic Rift]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Faille cyclonique]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Grieta ciclónica]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Rift des Sturmtiefs]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Squarcio Ciclonico]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[サイクロンの裂け目]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[회오리 균열]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Циклонический Разлом]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Fenda Ciclônica]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="666270798" />
  <ARTID value="666270798" />
  <ARTIST name="Chris Rahn" />
  <CASTING_COST cost="{1}{U}" />
  <FLAVOURTEXT>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[The Izzet specialize in unnatural disaster.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Les Izzet sont spécialisés dans les catastrophes artificielles.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Los ízzet se especializan en desastres no naturales.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Die Izzet sind auf unnatürliche Katastrophen spezialisiert.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Gli Izzet sono specializzati in catastrofi innaturali.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[イゼット団は不自然災害を専門としている。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[이젯 길드의 특기는 부자연스러운 재해다.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Иззеты являются мастерами неприродных катастроф.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[A especialidade dos Izzet são os desastres não naturais.]]></LOCALISED_TEXT>
  </FLAVOURTEXT>
  <TYPE metaname="Instant" />
  <EXPANSION value="RTR" />
  <RARITY metaname="R" />

  <UTILITY_ABILITY qualifier="Kicker" linked_ability_group="1">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Overload {6}{U}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Surcharge {6}{U} » par « chaque ».)]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Sobrecarga {6}{U}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Überlast {6}{U}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Sovraccarico {6}{U}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[超過 {6}{U}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[과부하 {6}{U}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Перегрузка {6}{U}]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Sobrecarga {6}{U}]]></LOCALISED_TEXT>
    <ABILITY_TEXT tag="OVERLOAD_QUERY_CYCLONIC_RIFT_OVERLOADED" secondary_tag="OVERLOAD_QUERY_CYCLONIC_RIFT_NO_OVERLOADED" />   
    <COST mana_cost="{5}" type="Mana" />
   
  </UTILITY_ABILITY>

    <SPELL_ABILITY linked_ability_group="1">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Return target nonland permanent you don’t control to its owner’s hand.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Renvoyez un permanent non-terrain ciblé que vous ne contrôlez pas dans la main de son propriétaire.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Regresa el permanente objetivo que no sea tierra que no controles a la mano de su propietario.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Bringe eine bleibende Karte deiner Wahl, die kein Land ist und die du nicht kontrollierst, auf die Hand ihres Besitzers zurück.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Fai tornare un permanente non terra bersaglio che non controlli in mano al suo proprietario.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[あなたがコントロールしていない土地でないパーマネント1つを対象とし、それをオーナーの手札に戻す。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[당신이 조종하지 않는 지속물 중 대지가 아닌 지속물 한 개를 목표로 정한다. 그 지속물을 소유자의 손으로 되돌린다.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Верните целевой не являющийся землей перманент, который не находится под вашим контролем, в руку его владельца.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Devolva a permanente alvo que não seja um terreno e que você não controle para a mão de seu dono.]]></LOCALISED_TEXT>
    <SFX text="TARGET_MAELSTROM_PLAY" />

    <MODE_SELECT  tag="MODE_CHOOSE_ONE">
       <MODE tag="NORMAL" index="1"/>
   <MODE tag="OVERLOAD" index="2"/>
    </MODE_SELECT>

   <TARGET_DEFINITION id="0">   
      local filter = ClearFilter()
        filter:Add( FE_TYPE, OP_NOT, CARD_TYPE_LAND)
      filter:Add( FE_IS_PERMANENT, true )
      filter:Add( FE_CONTROLLER, OP_NOT, EffectController())
   </TARGET_DEFINITION>      
   <TARGET tag="CARD_QUERY_CHOOSE_NONLAND_PERMANENT_TO_PUT_INTO_HAND" definition="0" compartment="0" mode ="1" count="1" />

   <RESOLUTION_TIME_ACTION mode="1">
      local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
      if  target ~= nil then
           target:PutInHand()
       end
    </RESOLUTION_TIME_ACTION>   

   <FILTER filter_id="1">          
        local filter = ClearFilter()
             filter:Add( FE_TYPE, OP_NOT, CARD_TYPE_LAND )
           filter:Add( FE_IS_PERMANENT, true )
      filter:Add( FE_CONTROLLER, OP_NOT, EffectController())
             filter:SetZone( ZONE_BATTLEFIELD )
        </FILTER>
   
   <RESOLUTION_TIME_ACTION filter_id="1" mode ="2">
        if FilteredCard() ~= nil then   
         FilteredCard():PutInHand()
      end
   </RESOLUTION_TIME_ACTION>
   
  </SPELL_ABILITY>

     <AI_AVAILABILITY type="in_response" response_source="1" />
   <AI_AVAILABILITY window_step="begin_combat" window_turn="their_turn" type="window" />
   <AI_AVAILABILITY window_step="declare_attackers" window_turn="their_turn" type="window" />
   <AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
   <AI_AVAILABILITY window_step="declare_blockers" type="window" />
   <AI_AVAILABILITY window_step="end_of_turn" type="window" />
   <AI_AVAILABILITY type="in_response" response_source="1" response_target="1" />
   <AI_BASE_SCORE score="900" zone="ZONE_HAND" />
</CARD_V2>

The idea is use a mode_selection, to disable normal effect or overload effect
but i want to choose that mode from an alternate cost or kicker cost instead the normal mode_selection,
so i want to pass "mode" argument to RESOLUTION_TIME_ACTION and TARGET blocks
but i need a global string argument
Last edited by braquio on 22 Feb 2014, 21:46, edited 1 time in total.
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 21:20

May be coding in LOL a global string variable with Get_str and Set_str functions.
But im not sure how to do it
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 21:31

I want to do something like this:
Code: Select all
<MODE_SELECT  tag="MODE_CHOOSE_ONE">
       <MODE tag="MODE_CHOOSE_ONE" index="1"/>
    </MODE_SELECT>
<RESOLUTION_TIME_ACTION>
global Newmode1 = ""
global Newmode2 = ""
if EffectSource():WasKicked then
Newmode1="2"
Newmode2="1"
else
Newmode1="1"
Newmode2="2"
end
</RESOLUTION_TIME_ACTION>
<TARGET tag="..." definition="0" compartment="0" mode =Newmode1 count="1" />
<RESOLUTION_TIME_ACTION mode=Newmode1>
Normal cost effect
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION mode=Newmode2>
Overload cost effect
</RESOLUTION_TIME_ACTION>
So with only 1 tag in MODE_SELECT we always have mode="1" active and mode ="2" inactive.
Then i choose wich effect has mode ="1" and which one has mode="2".
If i paid kicker Newmode2="1" so is active and the other one is inactive.
And if dont pay it the opposite
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 21:42

Withouth passing arguments the mode_select block with 2 tags, enable one and disable the other of those effect, works well.
So if i could pass string arguments im sure it works.
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby RiiakShiNal » 22 Feb 2014, 21:54

thefiremind wrote:
braquio wrote:And is possible to pass string arguments instead Int arguments?
dont work but something like this:
LinkedDC, as well as the other data chests, are made to store only some variable types, and string isn't one of them, in fact I had to make a custom structure when I coded the "Name a card" functions in order to save the chosen name.
If you want to do something involving a string that needs to be carried through multiple actions we can discuss about it and find a solution.

Note that
Code: Select all
EffectController():DisplayMessage(message..LinkedDC(500):Get_Int(0))
works anyway: if you concatenate something that isn't a string, it will be automatically converted to string.
Technically you can store strings by storing them as a list of numeric values for the characters, but as thefiremind said there is no inherent (easy) way to store them in a data chest.

For example if I wanted to store a string in a chest to be retrieved later I could use a couple of functions like this (untested, may need some adjustment):
Code: Select all
RSN_SetString = function( oDC, nIndex, sString )
   -- We default to no success in case we encounter a problem (oDC is nil).
   local bSuccess = false

   if (oDC ~= nil) then
      -- Make a sub-chest to store our string in.
      local oStringChest = oDC:Make_Chest( nIndex )

      -- Store our string length to make things somewhat easier later.
      local nLen = sString:len()
      oStringChest:Int_Set( 0, nLen )

      -- We support storing 0 length strings, but you can't iterate
      --  through a zero length string so we simply skip this part.
      if (nLen > 0) then
         -- Iterate through the length of the string writing each
         --  character to the data chest.
         local i
         for i = 1, nLen do
            oStringChest:Int_Set( i, sString:byte( i ) )
         end
      end

      -- Set that we stored the string successfully.
      bSuccess = true
   end

   -- Return whether we succeeded or not (should unless we were given a
   --  bad data chest).
   return bSuccess
end

RSN_GetString = function( oDC, nIndex )
   -- Set our default return value in case of problems.
   local sReturn = nil

   if (oDC ~= nil) then
      local oStringChest = oDC:Get_Chest( nIndex )
      if (oStringChest ~= nil) then
         -- Get our string length.
         local nLen = oStringChest:Int_Get( 0 )

         -- We got this far so we should go ahead and account
         --  for storing of an empty string.
         sReturn = ""

         if (nLen > 0) then
            -- We have more than one character so we need
            --  to iterate through and restore the string.
            local i
            for i = 1, nLen do
               sReturn = sReturn .. string.char( oStringChest:Int_Get( i ) )
            end
         end
      end
   end

   -- Return the string we ended up with or the default if we encountered
   --  a problem.
   return sReturn
end
Then write my card like this:
Code: Select all
<RESOLUTION_TIME_ACTION>
  RSN_SetString( EffectDC(), 500, "Test Message" )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
  local sTest = RSN_GetString( EffectDC(), 500 )
  if (sTest ~= nil) then
    EffectController():DisplayMessage( sTest )
  end
</RESOLUTION_TIME_ACTION>
braquio wrote:I want to do something like this:

...

So with only 1 tag in MODE_SELECT we always have mode="1" active and mode ="2" inactive.
Then i choose wich effect has mode ="1" and which one has mode="2".
If i paid kicker Newmode2="1" so is active and the other one is inactive.
And if dont pay it the opposite
You can't pass modes attributes from one ability to another, it simply can't be done. Code can't be executed until after the entire ability XML has been read in and by that point the attributes have already been set in stone which makes it too late to change.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 22:09

You can't pass modes attributes from one ability to another, it simply can't be done. Code can't be executed until after the entire ability XML has been read in and by that point the attributes have already been set in stone which makes it too late to change.
Well, may be ur right, but i want to test it.
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

Re: General DotP 2014 Coding Questions

Postby braquio » 22 Feb 2014, 23:05

Ok here it is, my last beginner question (i hope [-o< )
how i put that functions RSN_SetString and RSN_GetString in LOL archives?
I only copy it in a notepad and save it with .LOL extension in my custom/Functions folder or i have to compile it with LUA compiler?
____________________________________________________________________________________________________________________________
Braquio Dotp2014 DLC
Alternative Sealed Campaigns for DotP 2014
User avatar
braquio
 
Posts: 143
Joined: 16 Feb 2014, 19:21
Has thanked: 15 times
Been thanked: 9 times

PreviousNext

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 32 guests


Who is online

In total there are 32 users online :: 0 registered, 0 hidden and 32 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 32 guests

Login Form