English Scripting Questions

2,429 replies
Goto Page
To the start Previous 1 2 ... 10 11 12 ... 121 122 Next To the start
31.10.07 01:41:02 pm
Up
Ice
User
Offline Off
hmm, sorry, I'm a big noob there, but how do I create a global variable?
31.10.07 01:42:14 pm
Up
bizzl
User
Offline Off
Ice has written:
hmm, sorry, I'm a big noob there, but how do I create a global variable?

either use s2 cmd global , or just set it to a value without defining it at all before
ACCOUNT IS DEAD, DO NOT CONTACT ME VIA PM, PLZ!
31.10.07 01:55:58 pm
Up
Ice
User
Offline Off
my code in Game.inf:

Code:
1
2
3
4
5
6
7
8
9
on:keyhit01 {
          $IDMainResearch=create("object",240); 
          addscript "object",$IDMainResearch,"sys/scripts/anw_research.s2s";
          msg "Script added to MainResearch $IDMainResearch",3;
          Setlocal "object", $IDMainResearch, "$ID_MainResearch" , $IDMainResearch;
          event doresearch,"object",$IDMainResearch;
          free "object",$IDMainResearch;
          freevar $IDMainResearch;
     }


my code in anw_research.s2s:

Code:
1
2
3
4
on:doresearch {
     msg "Mainresearch= $IDmainResearch",3;
     msg "Mainresearch= $ID_mainResearch",3;
}


So I should have $IDMainResearch as a global variable, and anyway $ID_mainResearch as a local with the same value as $IDmainResearch, right?

Well the first msg, without the event call, is good (260+)
The two other msg, to test the values in the event, are always 0
31.10.07 01:59:17 pm
Up
Flying Lizard
User
Offline Off
in the one code you wrote $ID_MainResearch, in the other $ID_mainResearch, those are 2 different variables.

But you don't need the local variable anyway, since it contains the ID of the object they are assigned to, it would be much simpler to use s2 cmd currentid

EDIT:
it anyway is better NOT to use capital letters in variable-names
Worte sind wie Pfeile, man kann sie nicht zurücknehmen.
31.10.07 02:08:30 pm
Up
Ice
User
Offline Off
Flying Lizard has written:
in the one code you wrote $ID_MainResearch, in the other $ID_mainResearch, those are 2 different variables.

But you don't need the local variable anyway, since it contains the ID of the object they are assigned to, it would be much simpler to use s2 cmd currentid


Arghhhh I didnt thought about the case! In delphi the variables are not case sensitive!

Ok, after more test, the setlocal work, but the global variable seems to not be reachable from another object/event, and the currentid return 0???

I will work with setlocal, and will pay attention to the case!
31.10.07 02:11:58 pm
Up
Flying Lizard
User
Offline Off
o.O somehow you're making really strange mistakes.

this should work doesn't it?

on:doresearch {
$id=currentid ();
msg "$id";
}
Worte sind wie Pfeile, man kann sie nicht zurücknehmen.
31.10.07 02:33:19 pm
Up
Ice
User
Offline Off
yeah currentid work. I dont know how the hell I managed to make it go wrong the first time

When a script is running, and is calling an event. Does it "pause" until the event have finished running?
Same question with "process"?

My first guess with the few tests I did would be "yes" and "no", but I have some strange things with process.
31.10.07 02:41:31 pm
Up
bizzl
User
Offline Off
nope. the event function just add an event caller at the end of the event queue, and your script will be executed sometime after the current script is finished.
Similiar with the process function: the process bar actually shows up after your script get executed, and will add an event caller to the event queue.
I'm not sure about timers, but since BB3D is a non-threaded language I don't think DC was able to implement real timers, so it should behave similiar (the event queue is mostly empty anyway)
ACCOUNT IS DEAD, DO NOT CONTACT ME VIA PM, PLZ!
31.10.07 06:22:29 pm
Up
Satis
User
Offline Off
great to see that you are making progress with my bug

anyway... I will not be working on my mod for aboud 2 days, since my PSU exploded last night :S
Hopefuly it only my PSU that broke and nothing else.

New PSU have been ordered and should arive at my home in 1-2 days

Just a quick info for you

//Satis
4 years PHP coding ½-1 year Delphi Pascal Coding
01.11.07 01:45:19 am
Up
Ice
User
Offline Off
hehe I'll not work on it either, I'm away for 4 days

So far, I think your code could use a major overhaul. Basically, the trick I found to prevent any lag due to large files, is to create a temporary object and to load into it the script from a .s2s file
This way, the game only load the code needed. My only problem is the backward communication. I can start the script of the temporary object, but I have a hard time to start another object script from this last one! (dont know if I'm understandable here...)

Anyway, look at the "addscript" command, I think it can be the correct solution.
02.11.07 03:09:01 am
Up
Mc Leaf
Ice has written:
I can start the script of the temporary object, but I have a hard time to start another object script from this last one! (dont know if I'm understandable here...)

If I'm understanding you right, you'll have to know the "class" and "id" of the object, where you'll have to trigger an event. For example by
Code:
1
event "unit",100;

where "unit" is the class of the object and 100 the id of itself.
15.12.07 01:30:13 pm
Up
HudaJan
Super User
Offline Off
It's not very "scripting" question, but is it possible to create new models? Ok, I'll tell you. I tried to make the gunpowder. I used upgraded icon of flour. I also used model of flour, than i assigned script "colour etc.". It works perfectly. The new item is in menu and when it is on the ground it is like dark flour. But if I take it, then drop it, the colour is again white. I understend why, but how can I avoid this? Is it possible? Thx
New version of "Kidnap mod" I'm sorry to everyone who asked me for permission to use my stuff by PMs, I hadn't been online for a long time. Anyone can use it without permission
15.12.07 02:07:22 pm
Up
Flying Lizard
User
Offline Off
Try using the corresponding definition parameter

color=r,g,b
Farbe (je 0-255)

anyway you should remember that if you make a map with this gunpowder, other people will not be able to play the map.
Worte sind wie Pfeile, man kann sie nicht zurücknehmen.
15.12.07 02:23:11 pm
Up
Don Philippe
User
Offline Off
I have a little question! If I had the figure 18.2 ('cause of command getplayervalue), what can I do to transfer this number to the next highest one, in this case 19.

Thanks
15.12.07 02:23:56 pm
Up
HudaJan
Super User
Offline Off
Flying Lizard has written:
anyway you should remember that if you make a map with this gunpowder, other people will not be able to play the map.

Yes I know that, it's for my personal usage (for now).
I know how to work with the script color, so I'll give you exact term:
on:start {//I tried also on:load
color 30,30,30;
}
This is not my problem, my problem is, that model of the gunpowder(flour) does't have dark color, only on start, but not after I drop it...(It's a bit chaotic I know )
New version of "Kidnap mod" I'm sorry to everyone who asked me for permission to use my stuff by PMs, I hadn't been online for a long time. Anyone can use it without permission
15.12.07 02:30:11 pm
Up
Flying Lizard
User
Offline Off
I know exactly what you kean, if you use my solution in the definition of the object it works.
(Look, there is a = wich means it is a definition parameter)
Worte sind wie Pfeile, man kann sie nicht zurücknehmen.
15.12.07 02:32:54 pm
Up
HudaJan
Super User
Offline Off
Yes I misunderstood you. It works perfectly. Thx very much!!
New version of "Kidnap mod" I'm sorry to everyone who asked me for permission to use my stuff by PMs, I hadn't been online for a long time. Anyone can use it without permission
16.12.07 05:57:09 pm
Up
HudaJan
Super User
Offline Off
Ehm, another problem.

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
on:start {
     local $id;
     $id=create("item",120,0,0,5);
     store $id,"self";
     freevar $id;
}
on:use {
     exchange "self",1;
}
on:kill {
     if (count_stored("self",120)>0){
     explosion getx("self"),gety("self"),getz("self"),$radius,$damage;
     }
}

first two parto works(from on:start to exchange..)
But my "if" doesn't work and I don't know why(it doe's nothing). I think the problem is in "count_stored", but where. Please I tried almost everything:-)
New version of "Kidnap mod" I'm sorry to everyone who asked me for permission to use my stuff by PMs, I hadn't been online for a long time. Anyone can use it without permission
16.12.07 06:43:52 pm
Up
bizzl
User
Offline Off
$radius and $damage are not initialized and therefor counts as 0.
If you don't need variable values, uses number instead of variables -> explosion getx("self"),gety("self"),getz("self"),50,50; (or something like that )
ACCOUNT IS DEAD, DO NOT CONTACT ME VIA PM, PLZ!
16.12.07 08:53:18 pm
Up
HudaJan
Super User
Offline Off
No no, this is not a problem. This is changeable value, what is deafutly set on something(in this case it is 100,50). As you maybe recognized it is explosive barrel. I wanted to make him explode only if there are some amount of item(120 its gunpowder from post before:-) ). Im'quite sure, that the problem is in "count_stored".
So at start, there are 5 pieces of gunpowder. If I use it, it opens an exchange menu. But when I "kill" it, do nothing. I tried also:
on:kill {
local $gnp
$gnp=(count_stored("self",120));
msg "$gnp gunpowders in the barrel";
}
And message always reads 0 gunpowders in the barrel, so this might be the problem, but where ?
New version of "Kidnap mod" I'm sorry to everyone who asked me for permission to use my stuff by PMs, I hadn't been online for a long time. Anyone can use it without permission
To the start Previous 1 2 ... 10 11 12 ... 121 122 Next To the start