missing something?

new topic     » topic index » view thread      » older message » newer message

Hey I am trying to creat an inventory type of thing for my game. In 
order to do this I am useing this script:

with trace
include win32lib.ew
without warning

integer slot1, slot2, slot3, gold

slot1 = 0
slot2 = 0
slot3 = 0
gold  = 0

integer hp, mp

hp = 20
mp = 10

constant cr = { 13, 10 }

constant
    Main       = create( Window, "Dragon", 0, Default, Default, 130, 
300, 0 ),
    GP         = create( PushButton, "Gold", Main, 10, 10, 50, 50, 0 ),
    Healthpos  = create( PushButton, "Hp pos", Main, 10, 70, 50, 50, 0 
),
    Magicpos   = create( PushButton, "Mag pos", Main, 10, 140, 50, 50, 0 
),
    OkButton   = create( PushButton, "OK", Main, 10, 210, 100, 50, 0 ),
    Gl         = create( PushButton, "Close", Main, 70, 10, 50, 180, 0 )

procedure Gold()
    if slot1 = gold then
        gold = gold + 1
    elsif slot1 = 0 then
        gold = gold + 1
        slot1 = gold
    elsif slot1 != 0 then
        if slot2 = gold then
            gold = gold + 1
        elsif slot2 = 0 then
            gold = gold + 1
            slot2 = gold
        elsif slot2 != 0 then
            if slot3 = gold then
                gold = gold + 1
            elsif slot3 = 0 then
                gold = gold + 1
                slot3 = gold
            end if
        end if
    end if
end procedure
onClick[GP] = routine_id( "Gold" )


procedure Winopen()
    object result
    result = message_box( 
        sprintf( "Slot1 = %d ", {slot1} ) & cr &
        sprintf( "Slot2 = %d ", {slot2} ) & cr &
        sprintf( "Slot3 = %d ", {slot3} )
        , "List Information", 0 ) 
end procedure
onClick[OkButton] = routine_id( "Winopen" )

procedure close(integer self, integer event, sequence params)
    closeWindow( Main )
end procedure
setHandler({Gl}, w32HClick, routine_id("close"))

WinMain( Main, Normal )

one is also occoupied then the item will go to "slot3". well "slot1 = 0" 
is suposta mean that "slot1 is empty. When you run that script and click 
"gold" one time and then click "ok" everything is set to 0 witch should 
mean that it is empty, but you just "picked up a pice of gold" which 
should set the value to "1" but it dose not.

If you click "gold" a second time then click "Ok" the "slot1" is equal 
to "2" and that is correct. now it appears to be working but it is not. 

If you click a 3rd time nothing changes from the 2nd time you clicked 
"gold" and if you click "gold" a 4th time then "slot1" is = to "2" and 
"slot2" is = to "4", and it SHOULD be where "slot1" is = to "4" and 
"slot2" is = to "0", as well as "slot3" being = to "0" as it is but if 
you click "gold" 6 times then click "ok", "slot1" = "2", "slot2" = "4", 
"slot3" = "6" this just ain't funny guys what did I do wrong? Please 
show me how to fix this problem.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu