|
1 registered members (AndrewAMD),
6,385
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Error [STRINGS]
#339197
08/25/10 09:33
08/25/10 09:33
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
I saved name of the function and name of the model in two different strings, and then I try to create a model with the name and with the function from that strings. But I'm getting SYS error  What am I doing wrong here?!
STRING* s_view = "#30";
STRING* s_function = "#30";
function v_change()
{
ent_create(s_view,camera.x,s_function);
}
action v_model()
{
str_cpy(s_view, "v_model.mdl");
str_cpy(s_function, "v_model");
}
When I create model with the name from the string, but with function v_model, it works just perfect!
|
|
|
Re: Error
[Re: 3run]
#339198
08/25/10 09:37
08/25/10 09:37
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
ent_create wants a pointer to a function, not a STRING pointer. engine_getscript() is the function you are looking for
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Error
[Re: WretchedSid]
#339200
08/25/10 09:42
08/25/10 09:42
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I would do it this way. (untested)
STRING* s_view = "#30";
void* v_function = NULL;
function v_change()
{
ent_create(s_view,camera.x,v_function);
}
action v_model()
{
str_cpy(s_view, "v_model.mdl");
//or maybe : str_cpy(s_view, _str(my.type));
v_function = v_model;
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Error
[Re: 3run]
#339202
08/25/10 09:47
08/25/10 09:47
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
var is not a type that is supposed to hold a pointer. This should work:
STRING *s_view = "#30";
void *s_function;
function v_change()
{
if(!s_function)
{
error("s_function == NULL!");
return;
}
ent_create(s_view,camera.x,s_function);
}
action v_model()
{
s_function = engine_getscript("v_model");
str_cpy(s_view, "v_model.mdl");
}
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Error
[Re: WretchedSid]
#339203
08/25/10 09:49
08/25/10 09:49
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
I'm getting 'v_model' undeclared identifier  I could define all function before the 'v_model' action, but there are too many functions, and all of them will appear in WED... and I don't want them to. It will be two v_models in Behavior list that way... May be there is an other way to avoid getting undeclared identifier error?
Last edited by 3run; 08/25/10 10:00. Reason: ---
|
|
|
Re: Error
[Re: 3run]
#339209
08/25/10 10:49
08/25/10 10:49
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
If you have an action that you dont want to appear in WED, just make it a normal function. Your script wont care... eg:
action v_model() { ... }
//becomes
function v_model() { ... }
//or
var v_model() { ... }
//or
int v_model() { ... }
Did my code give an "undeclared identifier" error? Then try this.
var v_model(); //function prototype
STRING* s_view = "#30";
void* v_function = NULL;
function v_change()
{
ent_create(s_view,camera.x,v_function);
}
var v_model() //now a normal function to keep it out of WED
{
str_cpy(s_view, "v_model.mdl");
//or maybe : str_cpy(s_view, _str(my.type));
v_function = v_model;
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Error
[Re: EvilSOB]
#339214
08/25/10 11:18
08/25/10 11:18
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
I'm trying to call v_function inside other function, but I'm getting: "Call function v_function error". What is that? 
|
|
|
Re: Error
[Re: 3run]
#339221
08/25/10 11:41
08/25/10 11:41
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
No idea, not without see the code causing the problem... I dont know what you mean by trying to call the v_function? You cant CALL it through the v_function pointer, you can only assign it as an action to an entity...
Please explain EVERYTHING you are trying to achieve here...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Error
[Re: EvilSOB]
#339222
08/25/10 11:49
08/25/10 11:49
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
Ohh. You just said, what I'm trying to do  I've try to call if through the v_function pointer I've tried to store it with engine_getscript, and then to call, but same result  I'm trying to store and call function (they need to be store and change in every function, where I store it or change it to new function).
Last edited by 3run; 08/25/10 12:24.
|
|
|
|