| 07-09-2006, 04:47 PM | #1 |
HI! I have something like this, and I ask me how to make it work... The event is a research that finishes: (The name of the researching object is 'u00K') JASS:local integer A local location Loc set A=(GetObjectName(GetResearched())) call DisplayTextToForce( GetPlayersAll(), GetObjectName(GetResearched()) ) call DisplayTextToForce( GetPlayersAll(), I2S(A) ) call CreateNUnitsAtLoc(1,A,GetTriggerPlayer(),Loc, bj_UNIT_FACING) So when I try this, then WE gives me an error about a type-conflict. And yes that is obviously the integer A which is set to a string... but it is set to an object-id (namely the name: 'u00K') and don't work! What way else must I go to set A to this 'u00K'? I easily can say set A='u00K', but that fails the issue, I need it with GetObjectName, because there are different researching objects with different names. Perhaps the solution is apparent, but I don't see it, and that for already more than 2 hours... *argh* |
| 07-09-2006, 05:03 PM | #2 |
GetObjectName retuns a string, not the integer ID, GetResearched does. |
| 07-09-2006, 05:15 PM | #3 |
Yes, but the string from GetObjectName(GetResearched()) is 'u00K', the objectid I need! GetResearched() is just something like 1387452387! I need something like this (in fact same as above): JASS:call CreateNUnitsAtLoc(1,GetObjectName(GetResearched()),GetTriggerPlayer(),Loc, bj_UNIT_FACING) |
| 07-09-2006, 05:18 PM | #4 |
First you say it is set to string, then you say it is set to orderstring. 'u00K' ISN'T a string, it is an integer. Make sure if it returns "u00K" or 'u00K' (notice the ' and ") |
| 07-09-2006, 05:25 PM | #5 |
I can not check it, because WE don't let me, the editor says there is a conflict here: JASS:set A=(GetObjectName(GetResearched())) (The value of the researching objects Name is exactly: "'u00K'") So what can I do? EDIT: I tested this: JASS:local string s set s=GetObjectName(GetResearched()) call DisplayTextToForce( GetPlayersAll(), s ) But with this, the old error pops up: JASS:local string s set s=GetObjectName(GetResearched()) call DisplayTextToForce( GetPlayersAll(), s ) call CreateNUnitsAtLoc(1,"s",GetTriggerPlayer(),Loc, bj_UNIT_FACING) What now? |
| 07-09-2006, 07:01 PM | #6 |
If I get right, the upgrade name (not its id) is "u00K", and the unit you are trying to create in the later trigger has the 'u00K' id. An integer id ('1234') is not the same as a string ("1234") You are trying to do a parsing trick that doesn't seem to be possible. |
| 07-09-2006, 07:03 PM | #7 |
Unfortunatly, S2I does not convert rawcodes in string form, you will have to convert your rawcodes to integer form and then set them as the updates names', or use pitzer's function, IdString2DebugIdInteger, which converts string rawcodes to integers. |
| 07-10-2006, 01:42 PM | #8 | ||
@Alevice: Quote:
Quote:
@shadow1500: Wow! YES! That's what I need, PitzerMike's function!!! But how do I implement it? I tried to copy the code from the link to "own Script-Code" from Trigger Task, but then always the editor shuts down... EDIT: There is an error in the function from PitzerMike: JASS:if Char==""" then return 34 endif But I really don't know how you can fix it, so that you only get " as the respectively char ![]() |
| 07-10-2006, 03:09 PM | #9 |
Thats only an error in the jass editor, the WE parses it correctly. |
| 07-10-2006, 03:16 PM | #10 |
Change """ to "\"" and it should work. |
| 07-10-2006, 04:03 PM | #11 |
Oh yes i forgot, you have to escape the " char with a \ before it. Pitzer should fix this error. |
| 07-10-2006, 04:48 PM | #12 |
Actually, I designed a pair of functions called GetTrueIndex and GetFalseIndex which, with a bit of rigging, could transform a tiny string like "34" into a custom unit ID. I'm not sure if GetFalseIndex works, but feel free to try it. You could, theoretically, transform the upgrade's ID of 'u00K' to 'h00K' or whatever other id you like, thereby allowing you to fire all unit-spawning upgrades' effects from the same trigger. This would only work if you've arranged your unit-spawning upgrades into a specific order, though. Hope it helps. EDIT: fixed some serious bugs. Bleh. JASS://///////GETTRUEINDEX function GetTrueIndex takes integer ID, integer objtype returns integer local integer ind_i local integer ind_c local integer ind_t local integer ind_true = 0 if objtype == 1 then set ind_i = ID - 'h000' //if you want your index listing to begin from, say, 'h005', //just put "set ind_i = ind_i + 5" in this line. elseif objtype == 2 then set ind_i = ID - 'o000' elseif objtype == 3 then set ind_i = ID - 'e000' elseif objtype == 4 then set ind_i = ID - 'U000' elseif objtype == 5 then set ind_i = ID - 'I000' elseif objtype == 6 then set ind_i = ID - 'A000' elseif objtype == 7 then set ind_i = ID - 'B000' elseif objtype == 8 then set ind_i = ID - 'R000' endif set ind_c = ind_i / (256 * 256) set ind_t = ind_i - (ind_c * 256 * 256) if ind_c >= 17 then set ind_c = ind_c - 17 set ind_true = ind_true + 10 * 36 * 36 endif set ind_true = ind_true + (ind_c * 36 * 36) //I'm not using the Pow function for the sake of speed set ind_i = ind_t set ind_c = ind_i / 256 set ind_t = ind_i - (ind_c * 256) if ind_c >= 17 then set ind_c = ind_c - 17 set ind_true = ind_true + 10 * 36 endif set ind_true = ind_true + (ind_c * 36) //Final digit: set ind_i = ind_t if ind_i >= 17 then set ind_i = ind_i - 17 set ind_true = ind_true + 10 endif set ind_true = ind_true + ind_i return ind_true endfunction /////////GETFALSEINDEX function GetFalseIndex takes integer true_id, integer objtype returns integer local integer ind_true = true_id local integer ind_c local integer ind_false = 0 set ind_c = ind_true / (36 * 36) set ind_false = ind_false + ind_c * 256 * 256 if ind_c > 9 then set ind_false = ind_false + 8 * 256 * 256 endif set ind_true = ind_true - ind_c * 36 * 36 set ind_c = ind_true / 36 set ind_false = ind_false + ind_c * 256 if ind_c > 9 then set ind_false = ind_false + 8 * 256 endif set ind_true = ind_true - ind_c * 36 set ind_false = ind_false + ind_true if ind_true > 9 then set ind_false = ind_false + 8 endif if objtype == 1 then set ind_false = ind_false + 'h000' elseif objtype == 2 then set ind_false = ind_false + 'o000' elseif objtype == 3 then set ind_false = ind_false + 'e000' elseif objtype == 4 then set ind_false = ind_false + 'U000' elseif objtype == 5 then set ind_false = ind_false + 'I000' elseif objtype == 6 then set ind_false = ind_false + 'A000' elseif objtype == 7 then set ind_false = ind_false + 'B000' elseif objtype == 8 then set ind_false = ind_false + 'R000' endif return ind_false endfunction |
| 07-11-2006, 01:14 PM | #13 |
Big thanks to all, it works now! Thx especially to Alevice, shadow1500 and The)TideHunter( ! I needed that function from PitzerMike (if you read this one day: THX PitzerMike!) ( but also a workin' -> thx again TideHunter) ![]() |
| 07-11-2006, 03:37 PM | #14 | |
Or you could use the base 10 integer for the object name and S2I. Even more likely, just GetResearched as it is an integer just like the base-256 'u00K'. Quote:
|
| 07-11-2006, 04:11 PM | #15 |
Yeah, thanks for adding this, but then I always would have to check what number the object has I want to use. So, as for being lazy, I'm using PitzerMike's function. But nice to know that too, didn't think of that! Thanks PipeDream. |
