wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 12-21-2009, 11:20 AM   #1
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default String to integer problem

Sup!

Collapse JASS:
local string test = "'hpea'"
local integer id = S2I(test)
call BJDebugMsg(I2S(id))

Why doesn't this work? I need to convert the integer from the string to an object ID.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 12-21-2009, 11:26 AM   #2
Toadcop
BuranX
 
Toadcop's Avatar
 
Join Date: Jul 2006
Posts: 1,886

Submissions (4)

Toadcop is just really nice (299)Toadcop is just really nice (299)

Approved Map: TcXSpell Making Session 10 Winner

Send a message via ICQ to Toadcop
Default

lol... maybe should S2I also conver 0xff ? (hexademical)

you need to write own algorithm (function) to convert raw to decimal. i have done this with a preprocessor.
__________________
Toadcop is offline   Reply With Quote
Old 12-21-2009, 11:51 AM   #3
Fledermaus
default string
 
Fledermaus's Avatar
 
Join Date: May 2006
Posts: 705

Submissions (1)

Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)

Send a message via MSN to Fledermaus
Default

Because 'hpea' isn't a string, it's an integer. just display I2S('hpea')
Fledermaus is offline   Reply With Quote
Old 12-21-2009, 12:01 PM   #4
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Toadcoap, could you help me?
I need to generate IDs out of a string.

For example:
"'hpea', 'Hpal'" should return 2 integers, 'hpea' and 'Hpal'.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 12-21-2009, 06:09 PM   #5
TriggerHappy
 
Join Date: Feb 2008
Posts: 405

Submissions (2)

TriggerHappy will become famous soon enough (43)TriggerHappy will become famous soon enough (43)

Default

Requires ASCII.

Collapse JASS:
    function String2Rawcode takes string s returns integer
        local integer i = StringLength(s)
        local integer j = 1
        local integer k = 0
        loop
            exitwhen i == 0
            set i = i-1
            set k = k+Char2Ascii(SubString(s, i, i+1))*j
            set j = j*256
        endloop
        return k
    endfunction
    function blah takes nothing returns nothing
        local string test = "'hpea'"
        local integer id = String2Rawcode(test)
        call BJDebugMsg(I2S(id))
    endfunction

Last edited by TriggerHappy : 12-21-2009 at 06:09 PM.
TriggerHappy is offline   Reply With Quote
Old 12-21-2009, 06:33 PM   #6
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Anachron
"'hpea', 'Hpal'" should return 2 integers, 'hpea' and 'Hpal'.
You mean "hpea" and "hpal". If you really need this (you really don't, but you can pretend that you do), then you will need the thing Trig posted in some form.
__________________
Rising_Dusk is offline   Reply With Quote
Old 12-21-2009, 06:38 PM   #7
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

Quote:
Originally Posted by Anachron
Toadcoap, could you help me?
I need to generate IDs out of a string.

For example:
"'hpea', 'Hpal'" should return 2 integers, 'hpea' and 'Hpal'.


unfortunately for you string to integer only seems to parse number in decimnal notation. i dont recall if i testd it, but its likely "010" would retrun 10 rather than 8
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.
Alevice is offline   Reply With Quote
Old 01-04-2010, 10:15 AM   #8
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

But is 'Hpal' exactly the same as the integer of the 'Hpal' id? Is is threated the same way? Because I would need this CreateItem(ID, 0., 0.) with a parsed string.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 01-04-2010, 11:10 AM   #9
DioD
obey
 
DioD's Avatar
 
Join Date: Feb 2006
Posts: 1,532

Submissions (4)

DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)

Send a message via ICQ to DioD
Default

you can enter integer as decimal hex or raw BUT game process decimal only.
DioD is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 12:12 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services